[Pkg-javascript-commits] [less.js] 23/50: Ignore quote type when comparing values. Fixes #1992

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


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

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

commit 5647d4d27614a1d18e331eecb20fe53032ca994e
Author: Luke Page <luke.a.page at gmail.com>
Date:   Tue May 6 06:20:07 2014 +0100

    Ignore quote type when comparing values. Fixes #1992
---
 lib/less/tree/quoted.js      | 16 ++++++++++++----
 test/css/mixins-guards.css   | 14 +++++++++++---
 test/less/mixins-guards.less | 10 +++++++---
 3 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/lib/less/tree/quoted.js b/lib/less/tree/quoted.js
index 131bfad..b8f63b9 100644
--- a/lib/less/tree/quoted.js
+++ b/lib/less/tree/quoted.js
@@ -33,14 +33,22 @@ tree.Quoted.prototype = {
         if (!x.toCSS) {
             return -1;
         }
-        
-        var left = this.toCSS(),
+
+        var left, right;
+
+        // when comparing quoted strings allow the quote to differ
+        if (x.type === "Quoted" && !this.escaped && !x.escaped) {
+            left = x.value;
+            right = this.value;
+        } else {
+            left = this.toCSS();
             right = x.toCSS();
-        
+        }
+
         if (left === right) {
             return 0;
         }
-        
+
         return left < right ? -1 : 1;
     }
 };
diff --git a/test/css/mixins-guards.css b/test/css/mixins-guards.css
index 25e6f28..27fa976 100644
--- a/test/css/mixins-guards.css
+++ b/test/css/mixins-guards.css
@@ -67,9 +67,17 @@
   content: is not #0000ff its #800080;
 }
 .stringguardtest {
-  content: is theme1;
-  content: is not theme2;
-  content: is theme1 no quotes;
+  content: "theme1" is "theme1";
+  content: "theme1" is not "theme2";
+  content: "theme1" is 'theme1';
+  content: "theme1" is not 'theme2';
+  content: 'theme1' is "theme1";
+  content: 'theme1' is not "theme2";
+  content: 'theme1' is 'theme1';
+  content: 'theme1' is not 'theme2';
+  content: theme1 is not "theme2";
+  content: theme1 is not 'theme2';
+  content: theme1 is theme1;
 }
 #tryNumberPx {
   catch: all;
diff --git a/test/less/mixins-guards.less b/test/less/mixins-guards.less
index 6a02067..62dc39d 100644
--- a/test/less/mixins-guards.less
+++ b/test/less/mixins-guards.less
@@ -116,13 +116,17 @@
 	.colorguard(purple);
 }
 
-.stringguard(@str) when (@str = "theme1")					{ content: is theme1; }
-.stringguard(@str) when not ("theme2" = @str)				{ content: is not theme2; }
-.stringguard(@str) when (~"theme1" = @str)					{ content: is theme1 no quotes; }
+.stringguard(@str) when (@str = "theme1")					{ content: @str is "theme1"; }
+.stringguard(@str) when not ("theme2" = @str)				{ content: @str is not "theme2"; }
+.stringguard(@str) when (@str = 'theme1')					{ content: @str is 'theme1'; }
+.stringguard(@str) when not ('theme2' = @str)				{ content: @str is not 'theme2'; }
+.stringguard(@str) when (~"theme1" = @str)					{ content: @str is theme1; }
 .stringguard(@str)											{}
 .stringguardtest {
     .stringguard("theme1");
 	.stringguard("theme2");
+    .stringguard('theme1');
+    .stringguard('theme2');
 	.stringguard(theme1);
 }
 

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