New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support indices.groups
when compiling named groups in regexps
#15092
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53301/ |
I'm marking this as a bugfix because it just adds a missing piece of a proposal we already implemented (duplicate named groups), and it only works in browsers that already support |
For the failing tests: Node.js 14 and older don't support
|
If a RegExp has the /d flag (hasIndices), match objects should have an extra property .indices with an array of the character indices that each subgroup matched. The indices array itself has a property .groups giving the matched character indices (or undefined) for each named capturing group. This doesn't do anything to enable support for the /d flag, the hasIndices property, or the returned indices object, if the environment does not support it, but it will populate .indices.groups in _wrapRegExp if .indices is present, so that the transform-named-capturing-groups-regex and proposal-duplicate-named-capturing-groups-regex plugins can take advantage of that support if it exists.
indices.groups
when compiling named groups in regexps
If a RegExp has the
/d
flag (hasIndices
), match objects should have an extra property.indices
with an array of the character indices that each subgroup matched. The indices array itself has a property.groups
giving the matched character indices (or undefined) for each named capturing group.This doesn't do anything to enable support for the
/d
flag, the.hasIndices
property, or the returned indices object, if the environment does not support it, but it will populate.indices.groups
in_wrapRegExp
if.indices
is present, so that the transform-named-capturing-groups-regex and proposal-duplicate-named-capturing-groups-regex plugins can take advantage of that support if it exists.