@@ -1078,7 +1078,7 @@ XRegExp.matchChain = (str, chain) => (function recurseChain(values, level) {
1078
1078
1079
1079
if ( isNamedBackref && XRegExp . isInstalled ( 'namespacing' ) ) {
1080
1080
// `groups` has `null` as prototype, so using `in` instead of `hasOwnProperty`
1081
- if ( ! ( item . backref in match . groups ) ) {
1081
+ if ( ! ( match . groups && item . backref in match . groups ) ) {
1082
1082
throw new ReferenceError ( ERR_UNDEFINED_GROUP ) ;
1083
1083
}
1084
1084
} else if ( ! match . hasOwnProperty ( item . backref ) ) {
@@ -1408,13 +1408,16 @@ fixed.exec = function(str) {
1408
1408
}
1409
1409
1410
1410
// Attach named capture properties
1411
- let groupsObject = match ;
1412
1411
if ( XRegExp . isInstalled ( 'namespacing' ) ) {
1413
- // https://tc39.github.io/proposal-regexp-named-groups/#sec-regexpbuiltinexec
1414
- match . groups = Object . create ( null ) ;
1415
- groupsObject = match . groups ;
1412
+ match . groups = undefined ;
1416
1413
}
1417
1414
if ( this [ REGEX_DATA ] && this [ REGEX_DATA ] . captureNames ) {
1415
+ let groupsObject = match ;
1416
+ if ( XRegExp . isInstalled ( 'namespacing' ) ) {
1417
+ // https://tc39.github.io/proposal-regexp-named-groups/#sec-regexpbuiltinexec
1418
+ match . groups = Object . create ( null ) ;
1419
+ groupsObject = match . groups ;
1420
+ }
1418
1421
// Skip index 0
1419
1422
for ( let i = 1 ; i < match . length ; ++ i ) {
1420
1423
const name = this [ REGEX_DATA ] . captureNames [ i - 1 ] ;
0 commit comments