Skip to content

Commit 4183453

Browse files
committed
Use strict definition of whitespace.
This is a rebase and update of Jarek Foksa's patch in PR#16.
1 parent 08d0b3c commit 4183453

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/css/TokenStream.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
var h = /^[0-9a-fA-F]$/,
44
nonascii = /^[\u0080-\uFFFF]$/,
5-
nl = /\n|\r\n|\r|\f/;
5+
nl = /\n|\r\n|\r|\f/,
6+
whitespace = /\u0009|\u000a|\u000c|\u000d|\u0020/;
67

78
//-----------------------------------------------------------------------------
89
// Helper functions
@@ -18,7 +19,7 @@ function isDigit(c){
1819
}
1920

2021
function isWhitespace(c){
21-
return c !== null && /\s/.test(c);
22+
return c !== null && whitespace.test(c);
2223
}
2324

2425
function isNewLine(c){

tests/css/TokenStream.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@
6161
" " : [CSSTokens.S],
6262
"\n" : [CSSTokens.S],
6363
"\n \t" : [CSSTokens.S],
64-
"\f \n" : [CSSTokens.S]
64+
"\f \n" : [CSSTokens.S],
65+
// Not legal whitespace (PR#16)
66+
"\v\u00A0\u1680": [CSSTokens.CHAR, CSSTokens.IDENT]
6567
}
6668
}));
6769

0 commit comments

Comments
 (0)