This commit is contained in:
Matthew Dean
2018-07-03 19:38:31 -07:00
parent d821a3754f
commit 6fa7980cfe
3 changed files with 5 additions and 2 deletions

View File

@@ -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(', '));

View File

@@ -8,6 +8,7 @@
multiline: 2;
}
.scope {
empty: ;
var: 42;
escaped: 7px;
}

View File

@@ -9,6 +9,7 @@
return x})()`;
}
.scope {
empty: `+function(){}`;
@foo: 42;
var: `parseInt(this.foo.toJS())`;
escaped: ~`2 + 5 + 'px'`;