Skip to content

Commit

Permalink
Merge pull request #99 from JLHwung/fix-98
Browse files Browse the repository at this point in the history
allow - in classEscape when unicode flag is enabled
  • Loading branch information
jviereck committed Dec 21, 2019
2 parents 9bc130f + 10b8de0 commit 1da8afa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@

// For ClassEscape
if (insideCharacterClass) {
// b
if (match('b')) {
// 15.10.2.19
// The production ClassEscape :: b evaluates by returning the
Expand All @@ -718,6 +719,10 @@
// c ClassControlLetter
return createEscaped('controlLetter', res[1] + 16, res[1], 2);
}
// [+U] -
if (match('-') && hasUnicodeFlag) {
return createEscaped('singleEscape', 0x002d, '\\-');
}
}

res = parseCharacterEscape();
Expand Down
15 changes: 15 additions & 0 deletions test/test-data-unicode.json
Original file line number Diff line number Diff line change
Expand Up @@ -904,5 +904,20 @@
"name": "SyntaxError",
"message": "atomEscape at position 1\n \\a\n ^",
"input": "\\a"
},
"[\\-]": {
"type": "characterClass",
"body": [
{
"type": "value",
"kind": "singleEscape",
"codePoint": 45,
"range": [1, 3],
"raw": "\\-"
}
],
"negative": false,
"range": [0, 4],
"raw": "[\\-]"
}
}

0 comments on commit 1da8afa

Please sign in to comment.