Modified selector regexen to support CSS character escapes, added test files to verify change

Closes #78, closes #105
This commit is contained in:
Ian Beck
2010-11-11 07:54:42 +08:00
committed by Alexis Sellier
parent 86d2d98466
commit 97b3def8a9
3 changed files with 51 additions and 3 deletions

View File

@@ -661,7 +661,7 @@ less.Parser = function Parser(env) {
if (s !== '.' && s !== '#') { return }
while (e = $(/^[#.][\w-]+/)) {
while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
elements.push(new(tree.Element)(c, e));
c = $('>');
}
@@ -697,7 +697,7 @@ less.Parser = function Parser(env) {
if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||
peek(/^[^{]*(;|})/)) return;
if (match = $(/^([#.][\w-]+)\s*\(/)) {
if (match = $(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)) {
name = match[1];
while (param = $(this.entities.variable) || $(this.entities.literal)
@@ -778,7 +778,7 @@ less.Parser = function Parser(env) {
var e, t;
c = $(this.combinator);
e = $(/^[.#:]?[\w-]+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/);
e = $(/^[.#:]?(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) || $('*') || $(this.attribute) || $(/^\([^)@]+\)/);
if (e) { return new(tree.Element)(c, e) }
},

20
test/css/css-escapes.css Normal file
View File

@@ -0,0 +1,20 @@
.escape\|random\|char {
color: red;
}
.mixin\!tUp {
font-weight: bold;
}
.\34 04 {
background: red;
}
.\34 04 strong {
color: fuchsia;
font-weight: bold;
}
.trailingTest\+ {
color: red;
}
/* This hideous test of hideousness checks for the selector "blockquote" with various permutations of hex escapes */
\62\6c\6f \63 \6B \0071 \000075o\74 e {
color: silver;
}

View File

@@ -0,0 +1,28 @@
@ugly: fuchsia;
.escape\|random\|char {
color: red;
}
.mixin\!tUp {
font-weight: bold;
}
// class="404"
.\34 04 {
background: red;
strong {
color: @ugly;
.mixin\!tUp;
}
}
.trailingTest\+ {
color: red;
}
/* This hideous test of hideousness checks for the selector "blockquote" with various permutations of hex escapes */
\62\6c\6f \63 \6B \0071 \000075o\74 e {
color: silver;
}