Skip to content

Commit cacd493

Browse files
committed
parse invalid chars as invalid
1 parent 32ee034 commit cacd493

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/parse.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ function attributeMatch(match, content) {
113113
});
114114
}
115115

116+
function invalidMatch(match) {
117+
this.selector.nodes.push({
118+
type: "invalid",
119+
value: match
120+
});
121+
}
122+
116123
function irrelevantSpacingStartMatch(match) {
117124
this.selector.before = match;
118125
}
@@ -171,7 +178,8 @@ var parser = new Parser({
171178
"(\\s*),(\\s*)": nextSelectorMatch,
172179
"\\s+$": irrelevantSpacingEndMatch,
173180
"^\\s+": irrelevantSpacingStartMatch,
174-
"\\s+": spacingMatch
181+
"\\s+": spacingMatch,
182+
".": invalidMatch
175183
},
176184
inBrackets: {
177185
"/\\*[\\s\\S]*?\\*/": addToCurrent,

test/test-cases.js

+15
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,21 @@ module.exports = {
300300
])
301301
],
302302

303+
"invalid chars": [
304+
"a'b/c\"d[e",
305+
singleSelector([
306+
{ type: "element", name: "a" },
307+
{ type: "invalid", value: "'" },
308+
{ type: "element", name: "b" },
309+
{ type: "invalid", value: "/" },
310+
{ type: "element", name: "c" },
311+
{ type: "invalid", value: "\"" },
312+
{ type: "element", name: "d" },
313+
{ type: "invalid", value: "[" },
314+
{ type: "element", name: "e" }
315+
])
316+
],
317+
303318
"invalid nesting": [
304319
"a ) b",
305320
singleSelector([

0 commit comments

Comments
 (0)