Skip to content

Commit 74308d5

Browse files
committed
Match updated spec for /\W/iu
Per ES6, `/\W/iu` matched U+017F, U+212A, and, surprisingly, `K` and `S`. This is no longer the case now that tc39/ecma262#525 is merged. Ref. #8. Ref. mathiasbynens/regexpu-fixtures@81eeb14.
1 parent 71f3fe7 commit 74308d5

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

data/character-class-escape-sets.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ exports.UNICODE_IGNORE_CASE = new Map([
9595
.addRange(0x30, 0x39)
9696
.addRange(0x41, 0x5A)
9797
.addRange(0x61, 0x7A)],
98-
['W', regenerate(0x4B, 0x53, 0x60)
98+
['W', regenerate(0x60)
9999
.addRange(0x0, 0x2F)
100100
.addRange(0x3A, 0x40)
101101
.addRange(0x5B, 0x5E)
102-
.addRange(0x7B, 0x10FFFF)]
102+
.addRange(0x7B, 0x17E)
103+
.addRange(0x180, 0x2129)
104+
.addRange(0x212B, 0x10FFFF)]
103105
]);

scripts/character-class-escape-sets.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ function addCharacterClassEscape(lower, set) {
2626
ESCAPE_CHARS[lower] = ESCAPE_CHARS_UNICODE[lower] = set;
2727
const upper = lower.toUpperCase();
2828
ESCAPE_CHARS[upper] = BMP_SET.clone().remove(set);
29-
const uExcludeSet = UNICODE_SET.clone().remove(set);
30-
ESCAPE_CHARS_UNICODE[upper] = uExcludeSet;
29+
ESCAPE_CHARS_UNICODE[upper] = UNICODE_SET.clone().remove(set);
3130
// Check if one or more symbols in this set fold to another one. If so,
3231
// a copy of the set including the mapped symbols is created for use with
3332
// regular expressions that have both the `u` and `i` flags set.
3433
const codePoints = set.toArray();
3534
const iuSet = regenerate();
3635
let containsFoldingSymbols = false;
37-
codePoints.forEach(function(codePoint) {
36+
for (const codePoint of codePoints) {
3837
let folded = caseFold(codePoint);
3938
if (folded) {
4039
containsFoldingSymbols = true;
@@ -44,13 +43,13 @@ function addCharacterClassEscape(lower, set) {
4443
iuSet.add(folded);
4544
}
4645
}
47-
});
48-
ESCAPE_CHARS_UNICODE_IGNORE_CASE[lower] = containsFoldingSymbols ?
46+
}
47+
const iuLowerSet = containsFoldingSymbols ?
4948
iuSet.clone().add(set) :
5049
set;
51-
ESCAPE_CHARS_UNICODE_IGNORE_CASE[upper] = containsFoldingSymbols ?
52-
iuSet.clone().add(uExcludeSet) :
53-
uExcludeSet;
50+
const iuUpperSet = UNICODE_SET.clone().remove(iuLowerSet);
51+
ESCAPE_CHARS_UNICODE_IGNORE_CASE[lower] = iuLowerSet;
52+
ESCAPE_CHARS_UNICODE_IGNORE_CASE[upper] = iuUpperSet;
5453
}
5554

5655
// Prepare a Regenerate set for every existing character class escape.

0 commit comments

Comments
 (0)