Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: MDB 4.5 SCSS Error & error when minifying mdb.js

belu pro asked 6 years ago


Hi, I just wanted to migrate my project to 4.5 but got the following error at generating the css from scss:

 

/*
Error: Functions may not be defined within control directives or other mixins.
        on line 215 of core/_mixins.scss
        from line 35 of mdb.scss

210: }
211: 
212: // Make badge
213: @mixin make-badge($name, $color) {
214:   .badge-#{$name} {
215:     @function set-notification-text-color($color) {
216:       @if (lightness($color) > 70) {
217:         @return $black; // Lighter backgorund, return dark color
218:       } @else {
219:         @return $white; // Darker background, return light color
220:       }

Backtrace:
core/_mixins.scss:215
mdb.scss:35
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/check_nesting.rb:15:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `map'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/check_nesting.rb:51:in `visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:38:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/check_nesting.rb:17:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `map'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/check_nesting.rb:51:in `visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:36:in `block in visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/check_nesting.rb:75:in `visit_mixindef'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:36:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/check_nesting.rb:17:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `map'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/check_nesting.rb:51:in `visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:36:in `block in visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/check_nesting.rb:59:in `visit_root'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:36:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/check_nesting.rb:17:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:24:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:328:in `block in visit_import'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/stack.rb:88:in `block in with_import'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/stack.rb:135:in `with_frame'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/stack.rb:88:in `with_import'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:326:in `visit_import'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:36:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:162:in `block in visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/stack.rb:79:in `block in with_base'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/stack.rb:135:in `with_frame'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/stack.rb:79:in `with_base'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:162:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `map'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:171:in `block in visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:183:in `with_environment'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:170:in `visit_children'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:36:in `block in visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:190:in `visit_root'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/base.rb:36:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:161:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/visitors/perform.rb:10:in `visit'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/root_node.rb:36:in `css_tree'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/tree/root_node.rb:29:in `render_with_sourcemap'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/engine.rb:389:in `_render_with_sourcemap'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/engine.rb:307:in `render_with_sourcemap'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/plugin/compiler.rb:462:in `update_stylesheet'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/plugin/compiler.rb:215:in `block in update_stylesheets'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/plugin/compiler.rb:209:in `each'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/plugin/compiler.rb:209:in `update_stylesheets'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/plugin.rb:82:in `update_stylesheets'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/exec/sass_scss.rb:340:in `watch_or_update'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/exec/sass_scss.rb:51:in `process_result'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/exec/base.rb:52:in `parse'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/lib/sass/exec/base.rb:19:in `parse!'
/usr/local/var/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/sass-3.5.5/bin/scss:13:in `<top (required)>'
/usr/local/var/rbenv/versions/2.2.0/bin/scss:23:in `load'
/usr/local/var/rbenv/versions/2.2.0/bin/scss:23:in `<main>'
*/
body:before {
  white-space: pre;
  font-family: monospace;
  content: "Error: Functions may not be defined within control directives or other mixins.A         on line 215 of core/_mixins.scssA         from line 35 of mdb.scssA A 210: }A 211: A 212: // Make badgeA 213: @mixin make-badge($name, $color) {A 214:   .badge-#{$name} {A 215:     @function set-notification-text-color($color) {A 216:       @if (lightness($color) > 70) {A 217:         @return $black; // Lighter backgorund, return dark colorA 218:       } @else {A 219:         @return $white; // Darker background, return light colorA 220:       }"; }


---------------------
And the following error when minifying the mdb.js

/Applications/PhpStorm.app/Contents/jdk/Contents/Home/jre/bin/java -jar /Users/Bernhard/node_modules/yuicompressor/build/yuicompressor-2.4.8.jar mdb_mat.js -o mdb_mat.min.js
[ERROR] in mdb_mat.js
  4835:72:missing name after . operator
[ERROR] in mdb_mat.js
  4840:39:missing name after . operator
[ERROR] in mdb_mat.js
  5953:14:missing name after . operator
[ERROR] in mdb_mat.js
  5956:6:missing ; before statement
[ERROR] in mdb_mat.js
  10889:9:invalid property id
[ERROR] in mdb_mat.js
  10889:10:syntax error
[ERROR] in mdb_mat.js
  10890:5:syntax error
[ERROR] in mdb_mat.js
  10891:5:syntax error
[ERROR] in mdb_mat.js
  12110:38:missing name after . operator
[ERROR] in mdb_mat.js
  12115:38:missing name after . operator
[ERROR] in mdb_mat.js
  1:0:Compilation produced 10 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 10 syntax errors.
at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:172)
at org.mozilla.javascript.Parser.parse(Parser.java:396)
at org.mozilla.javascript.Parser.parse(Parser.java:340)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:315)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:536)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:147)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
Process finished with exit code 2

 


Jakub Strebeyko staff answered 6 years ago


Hi there Bernhard, The issue has been filed and shall be taken care of shortly. Meanwhile - thanks a ton for letting us know! To get rid of this compiling issue it seems enough to just move the said @function set-notification-text-color out of the @mixin's scope. With Best Regards, Kuba

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags