-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
normative changeAffects behavior required to correctly evaluate some ECMAScript source textAffects behavior required to correctly evaluate some ECMAScript source textproposalThis is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4.This is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4.web reality
Description
Update: Link to proposal: https://github.com/tc39/proposal-regexp-legacy-features
All web browsers expose non-standard properties on the RegExp constructor, that are updated each time a match is done.
The list of properties that are exposed by all common browsers are the following. They typically expose other properties not mentioned here, but not shared by all implementations:
$1, $2, $3, $4, $5, $6, $7, $8, $9,
and (in pairs, where the first and the second one return the same value):
input, $_
lastMatch, $&
lastParen, $+
leftContext, $`
rightContext, $'
Some observations:
- their value is always a string;
- some implementations expose them as data properties, others as accessor properties;
- those properties are non-enumerable;
- they cannot be deleted or modified manually.
It would be useful to specify them. I think that the following should be required:
- Those properties should be accessors. That would be more honest about the changing nature of their value;
- They should be deletable. Indeed, they represent global communication channels that may be unwanted in some environments;
- It should be specified when they are updated, presumably sometime during the execution of the builtin
RegExp#exec
method. This is useful if we want, in some future, separate the part ofRegExp#exec
that does the real work, and the part that does stateful updates on various objects.
Metadata
Metadata
Assignees
Labels
normative changeAffects behavior required to correctly evaluate some ECMAScript source textAffects behavior required to correctly evaluate some ECMAScript source textproposalThis is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4.This is related to a specific proposal, and will be closed/merged when the proposal reaches stage 4.web reality