slevithan/xregexp

`groups` property of matchObj for regex without named capture should have value `undefined`

slevithan opened this issue · 2 comments

Native:

/./.exec('.').groups; // undefined

(Note that the value is undefined, but the groups property is present.)

Vs XRegExp v4.4.1 with namespacing on:

XRegExp.exec('.', /./).groups; // {}

This should be updated to match native ES2018 handling.

Note that XRegExp.replace already has the correct handling (replacement callbacks are only given the groups arg if namespacing is on and there are named captures in the regex).

@josephfrazier this should probably go out with other named capture changes in v5.

Interesting, I guess the motivation is to be able to check !!match.groups to see if there's any?

In any case, thanks for fixing!