Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Accept Ogham Space Mark as whitespace character

  • Loading branch information...
commit fba675a3b4b3ec985acf9812b1cd72506967c554 1 parent db27559
@michaelficarra michaelficarra authored committed
Showing with 34 additions and 7 deletions.
  1. +3 −7 esprima.js
  2. +31 −0 test/test.js
View
10 esprima.js
@@ -229,18 +229,14 @@ parseStatement: true, parseSourceElement: true */
// 7.2 White Space
function isWhiteSpace(ch) {
- return (ch === 32) || // space
- (ch === 9) || // tab
- (ch === 0xB) ||
- (ch === 0xC) ||
- (ch === 0xA0) ||
- (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);
+ return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) ||
+ (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0);
}
// 7.3 Line Terminators
function isLineTerminator(ch) {
- return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);
+ return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029);
}
// 7.6 Identifier Names and Identifiers
View
31 test/test.js
@@ -16797,6 +16797,37 @@ var testFixture = {
},
+ 'Whitespace': {
+
+ 'new\x20\x09\x0B\x0C\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFFa': {
+ type: "ExpressionStatement",
+ expression: {
+ type: "NewExpression",
+ callee: {
+ type: "Identifier",
+ name: "a",
+ range: [25, 26],
+ loc: {
+ start: {line: 1, column: 25},
+ end: {line: 1, column: 26}
+ }
+ },
+ arguments: [],
+ range: [0, 26],
+ loc: {
+ start: {line: 1, column: 0},
+ end: {line: 1, column: 26}
+ }
+ },
+ range: [0, 26],
+ loc: {
+ start: {line: 1, column: 0},
+ end: {line: 1, column: 26}
+ }
+ }
+
+ },
+
'Source elements': {
'': {
Please sign in to comment.
Something went wrong with that request. Please try again.