Skip to content

Commit

Permalink
XRegExp.exec: preserve groups obj that comes from native ES2018 named…
Browse files Browse the repository at this point in the history
… capture
  • Loading branch information
slevithan committed Jan 10, 2021
1 parent 7fea476 commit c4a83e7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/xregexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,9 +1408,6 @@ fixed.exec = function(str) {
}

// Attach named capture properties
if (XRegExp.isInstalled('namespacing')) {
match.groups = undefined;
}
if (this[REGEX_DATA] && this[REGEX_DATA].captureNames) {
let groupsObject = match;
if (XRegExp.isInstalled('namespacing')) {
Expand All @@ -1425,6 +1422,9 @@ fixed.exec = function(str) {
groupsObject[name] = match[i];
}
}
// Preserve any existing `groups` obj that came from native ES2018 named capture
} else if (!match.groups && XRegExp.isInstalled('namespacing')) {
match.groups = undefined;
}

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

0 comments on commit c4a83e7

Please sign in to comment.