Skip to content

Commit c4a83e7

Browse files
committed
XRegExp.exec: preserve groups obj that comes from native ES2018 named capture
1 parent 7fea476 commit c4a83e7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/xregexp.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1408,9 +1408,6 @@ fixed.exec = function(str) {
14081408
}
14091409

14101410
// Attach named capture properties
1411-
if (XRegExp.isInstalled('namespacing')) {
1412-
match.groups = undefined;
1413-
}
14141411
if (this[REGEX_DATA] && this[REGEX_DATA].captureNames) {
14151412
let groupsObject = match;
14161413
if (XRegExp.isInstalled('namespacing')) {
@@ -1425,6 +1422,9 @@ fixed.exec = function(str) {
14251422
groupsObject[name] = match[i];
14261423
}
14271424
}
1425+
// Preserve any existing `groups` obj that came from native ES2018 named capture
1426+
} else if (!match.groups && XRegExp.isInstalled('namespacing')) {
1427+
match.groups = undefined;
14281428
}
14291429

14301430
// Fix browsers that increment `lastIndex` after zero-length matches

0 commit comments

Comments
 (0)