diff --git a/lib/less/tree/call.js b/lib/less/tree/call.js index 942436e6..4db9faf9 100644 --- a/lib/less/tree/call.js +++ b/lib/less/tree/call.js @@ -48,10 +48,16 @@ Call.prototype.eval = function (context) { } if (result !== null && result !== undefined) { - // All returned results must be Nodes, - // so anything other than a Node is a null Node + // Results that that are not nodes are cast as Anonymous nodes + // Falsy values or booleans are returned as empty nodes if (!(result instanceof Node)) { - result = new Anonymous(null); + if (!result || result === true) { + result = new Anonymous(null); + } + else { + result = new Anonymous(result.toString()); + } + } result._index = this._index; result._fileInfo = this._fileInfo; diff --git a/test/css/functions.css b/test/css/functions.css index 4f806122..ab5df5bb 100644 --- a/test/css/functions.css +++ b/test/css/functions.css @@ -38,7 +38,7 @@ saturate-filter: saturate(5%); contrast-white: #000000; contrast-black: #ffffff; - contrast-red: #000000; + contrast-red: #ffffff; contrast-green: #000000; contrast-blue: #ffffff; contrast-yellow: #000000; @@ -49,11 +49,11 @@ contrast-light-thresh: #111111; contrast-dark-thresh: #eeeeee; contrast-high-thresh: #eeeeee; - contrast-low-thresh: #eeeeee; + contrast-low-thresh: #111111; contrast-light-thresh-per: #111111; contrast-dark-thresh-per: #eeeeee; contrast-high-thresh-per: #eeeeee; - contrast-low-thresh-per: #eeeeee; + contrast-low-thresh-per: #111111; replace: "Hello, World!"; replace-captured: "This is a new string."; replace-with-flags: "2 + 2 = 4"; diff --git a/test/css/plugin.css b/test/css/plugin.css index 71db6864..0c6ebe71 100644 --- a/test/css/plugin.css +++ b/test/css/plugin.css @@ -50,4 +50,7 @@ val1: foo; val2: foo; } +.test-simple { + value: 3.141592653589793; +} @arbitrary value after (); diff --git a/test/less/plugin.less b/test/less/plugin.less index 1089be4b..285c1649 100644 --- a/test/less/plugin.less +++ b/test/less/plugin.less @@ -91,6 +91,10 @@ test-collapse(); val2: foo; } +.test-simple { + @plugin "./plugin/plugin-simple"; + value: pi(); +} test-atrule("@charset"; '"utf-8"'); test-atrule("@arbitrary"; "value after ()"); diff --git a/test/less/plugin/plugin-simple.js b/test/less/plugin/plugin-simple.js new file mode 100644 index 00000000..340b9b3a --- /dev/null +++ b/test/less/plugin/plugin-simple.js @@ -0,0 +1,3 @@ +functions.add('pi', function() { + return Math.PI; +}); \ No newline at end of file