Ignore quote type when comparing values. Fixes #1992

This commit is contained in:
Luke Page
2014-05-06 06:20:07 +01:00
parent 1ccb489866
commit 5647d4d276
3 changed files with 30 additions and 10 deletions

View File

@@ -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;
}
};

View File

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

View File

@@ -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);
}