[Pkg-javascript-commits] [less.js] 07/58: allow colour keywords to serve as variable names (for @@)

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


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

js pushed a commit to annotated tag v2.3.0
in repository less.js.

commit f0d7b6a9fac050ac5973a78ff25ee1c073a0b541
Author: seven-phases-max <seven.phases.max at gmail.com>
Date:   Sun Jan 11 04:45:30 2015 +0400

    allow colour keywords to serve as variable names (for @@)
---
 lib/less/functions/color.js |  2 +-
 lib/less/tree/color.js      |  8 ++++----
 test/css/variables.css      |  8 +++++++-
 test/less/variables.less    | 20 +++++++++++++++++---
 4 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/lib/less/functions/color.js b/lib/less/functions/color.js
index 5158132..2499dcd 100644
--- a/lib/less/functions/color.js
+++ b/lib/less/functions/color.js
@@ -259,7 +259,7 @@ colorFunctions = {
             return new Color(c.value.slice(1));
         }
         if ((c instanceof Color) || (c = Color.fromKeyword(c.value))) {
-            c.keyword = undefined;
+            c.value = undefined;
             return c;
         }
         throw {
diff --git a/lib/less/tree/color.js b/lib/less/tree/color.js
index cfaccf3..fe4cea3 100644
--- a/lib/less/tree/color.js
+++ b/lib/less/tree/color.js
@@ -56,11 +56,11 @@ Color.prototype.genCSS = function (context, output) {
 Color.prototype.toCSS = function (context, doNotCompress) {
     var compress = context && context.compress && !doNotCompress, color, alpha;
 
-    // `keyword` is set if this color was originally
+    // `value` is set if this color was originally
     // converted from a named color string so we need
     // to respect this and try to output named color too.
-    if (this.keyword) {
-        return this.keyword;
+    if (this.value) {
+        return this.value;
     }
 
     // If we have some transparency, the only way to represent it
@@ -179,7 +179,7 @@ Color.fromKeyword = function(keyword) {
     }
 
     if (c) {
-        c.keyword = keyword;
+        c.value = keyword;
         return c;
     }
 };
diff --git a/test/css/variables.css b/test/css/variables.css
index 9c704a4..1ce6bd6 100644
--- a/test/css/variables.css
+++ b/test/css/variables.css
@@ -22,7 +22,13 @@
   multi-important: #888888 #888888, 'Trebuchet' !important;
   multi: something 'A', B, C, 'Trebuchet';
 }
-.variable-names {
+.variable-names .quoted {
+  name: 'hello';
+}
+.variable-names .unquoted {
+  name: 'hello';
+}
+.variable-names .color-keyword {
   name: 'hello';
 }
 .alpha {
diff --git a/test/less/variables.less b/test/less/variables.less
index f0b92ea..e2a2bea 100644
--- a/test/less/variables.less
+++ b/test/less/variables.less
@@ -51,9 +51,23 @@
 }
 
 .variable-names {
-    @var: 'hello';
-    @name: 'var';
-    name: @@name;
+    .quoted {
+        @var: 'hello';
+        @name: 'var';
+        name: @@name;
+    }
+
+    .unquoted {
+        @var: 'hello';
+        @name: var;
+        name: @@name;
+    }
+    
+    .color-keyword {
+        @red: 'hello';
+        @name: red;
+        name: @@name;
+    }
 }
 
 .alpha {

-- 
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