[Pkg-javascript-commits] [less.js] 23/25: Fix property interpolation for `@*` values

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:11 UTC 2015


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag v1.7.5
in repository less.js.

commit 36383dc89b2eecd06349fefc005dd33cb8b1e629
Author: seven-phases-max <seven.phases.max at gmail.com>
Date:   Tue Sep 2 00:02:49 2014 +0400

    Fix property interpolation for `@*` values
---
 lib/less/tree/rule.js               | 11 +++++++----
 test/css/property-name-interp.css   |  1 +
 test/less/property-name-interp.less |  5 ++++-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/less/tree/rule.js b/lib/less/tree/rule.js
index 4e1ccde..8e62c40 100644
--- a/lib/less/tree/rule.js
+++ b/lib/less/tree/rule.js
@@ -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') {
diff --git a/test/css/property-name-interp.css b/test/css/property-name-interp.css
index 2082b81..315815e 100644
--- a/test/css/property-name-interp.css
+++ b/test/css/property-name-interp.css
@@ -1,5 +1,6 @@
 pi-test {
   border: 0;
+  @not-variable: @not-variable;
   ufo-width: 50%;
   *-z-border: 1px dashed blue;
   -www-border-top: 2px;
diff --git a/test/less/property-name-interp.less b/test/less/property-name-interp.less
index 9886e65..46e3379 100644
--- a/test/less/property-name-interp.less
+++ b/test/less/property-name-interp.less
@@ -6,8 +6,11 @@ pi-test {
     @c_c:    left;
     @d-d4: radius;
     @-:         -;
-    
+
+    @var: ~'@not-variable';
+
     @{a}: 0;
+    @{var}: @var;
     @{prefix}width: 50%;
     *-z-@{a} :1px dashed blue;
     -www-@{a}-@{bb}: 2px;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git



More information about the Pkg-javascript-commits mailing list