modify javascript eval to be compatible with e()

This commit is contained in:
cloudhead
2010-07-08 19:28:34 +02:00
parent e36080a3ff
commit cc82887c9f
2 changed files with 3 additions and 4 deletions

View File

@@ -84,7 +84,7 @@ tree.functions = {
return this.desaturate(color, new(tree.Dimension)(100));
},
e: function (str) {
return new(tree.Anonymous)(str);
return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
},
'%': function (quoted /* arg, arg, ...*/) {
var args = Array.prototype.slice.call(arguments, 1),

View File

@@ -6,7 +6,7 @@ tree.JavaScript = function (string, index) {
};
tree.JavaScript.prototype = {
toCSS: function () {
return this.evaluated;
return JSON.stringify(this.evaluated);
},
eval: function (env) {
var result,
@@ -18,8 +18,7 @@ tree.JavaScript.prototype = {
}
try {
result = expression.call(context);
this.evaluated = JSON.stringify(result);
this.evaluated = expression.call(context);
} catch (e) {
throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" ,
index: this.index };