Skip to content

Commit

Permalink
Merge pull request #3257 from matthew-dean/bugfix-3182
Browse files Browse the repository at this point in the history
Fixes #3182
  • Loading branch information
matthew-dean authored Jul 6, 2018
2 parents c20e8ce + 6fa7980 commit be048e7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/less/tree/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ JavaScript.prototype = new JsEvalNode();
JavaScript.prototype.type = 'JavaScript';
JavaScript.prototype.eval = function(context) {
var result = this.evaluateJavaScript(this.expression, context);
var type = typeof result;

if (typeof result === 'number') {
if (type === 'number' && !isNaN(result)) {
return new Dimension(result);
} else if (typeof result === 'string') {
} else if (type === 'string') {
return new Quoted('"' + result + '"', result, this.escaped, this._index);
} else if (Array.isArray(result)) {
return new Anonymous(result.join(', '));
Expand Down
1 change: 1 addition & 0 deletions test/css/javascript.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
multiline: 2;
}
.scope {
empty: ;
var: 42;
escaped: 7px;
}
Expand Down
1 change: 1 addition & 0 deletions test/less/javascript.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
return x})()`;
}
.scope {
empty: `+function(){}`;
@foo: 42;
var: `parseInt(this.foo.toJS())`;
escaped: ~`2 + 5 + 'px'`;
Expand Down

0 comments on commit be048e7

Please sign in to comment.