Fix property interpolation for @* values

This commit is contained in:
seven-phases-max
2014-09-02 00:02:49 +04:00
parent e045362c90
commit 36383dc89b
3 changed files with 12 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
(function (tree) {
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline) {
tree.Rule = function (name, value, important, merge, index, currentFileInfo, inline, variable) {
this.name = name;
this.value = (value instanceof tree.Value || value instanceof tree.Ruleset) ? value : new(tree.Value)([value]);
this.important = important ? ' ' + important.trim() : '';
@@ -8,7 +8,8 @@ tree.Rule = function (name, value, important, merge, index, currentFileInfo, inl
this.index = index;
this.currentFileInfo = currentFileInfo;
this.inline = inline || false;
this.variable = name.charAt && (name.charAt(0) === '@');
this.variable = (variable !== undefined) ? variable
: (name.charAt && (name.charAt(0) === '@'));
};
tree.Rule.prototype = {
@@ -30,13 +31,14 @@ tree.Rule.prototype = {
},
toCSS: tree.toCSS,
eval: function (env) {
var strictMathBypass = false, name = this.name, evaldValue;
var strictMathBypass = false, name = this.name, variable = this.variable, evaldValue;
if (typeof name !== "string") {
// expand 'primitive' name directly to get
// things faster (~10% for benchmark.less):
name = (name.length === 1)
&& (name[0] instanceof tree.Keyword)
? name[0].value : evalName(env, name);
variable = false; // never treat expanded interpolation as new variable name
}
if (name === "font" && !env.strictMath) {
strictMathBypass = true;
@@ -54,7 +56,8 @@ tree.Rule.prototype = {
evaldValue,
this.important,
this.merge,
this.index, this.currentFileInfo, this.inline);
this.index, this.currentFileInfo, this.inline,
variable);
}
catch(e) {
if (typeof e.index !== 'number') {