TAG review of the proposal to use the RegExp v
flag instead of u
for the HTML pattern
attribute
#832
Closed
1 task done
Labels
Progress: propose closing
we think it should be closed but are waiting on some feedback or consensus
Topic: HTML
Venue: WHATWG
こんにちは TAG-さん!
I'm requesting a TAG review of the proposal to use the RegExp
v
flag instead ofu
for the HTMLpattern
attribute.Summary
Using the new RegExp
v
flag instead ofu
would enable the use of set notation, string literal syntax, and Unicode properties of strings withinpattern
attribute values.Explainer
This proposal makes the
pattern
attribute more powerful, enabling the use of set notation, string literal syntax, and Unicode properties of strings.Differences with the previous
u
flag-based behavior:[FEATURE] Previously invalid patterns now become valid, e.g.
For more useful examples of the RegExp
v
flag, see the relevant feature explainer.[BREAKING CHANGE] Some previously valid patterns are now errors, specifically those with a character class including either an unescaped special character
(
)
[
]
{
}
/
-
\
|
or a double punctuator:Throwing patterns result in
inputElement.validity.valid === true
for any input value, so the only compatibility risk is that some value/pattern combinations that would previously result ininputElement.validity.valid === false
now result ininputElement.validity.valid === true
.Other previously valid patterns still behave the same. (Other than the abovementioned features, the
v
flags only differs in behavior from theu
flag w.r.t. case-insensitive matching, but thepattern
attribute uses case-sensitive matching.)Note that the breaking changes mostly apply to somewhat esoteric edge cases that can easily be avoided. In the worst case, this could cause previously invalid input to now be considered valid (since throwing patterns result in
inputElement.validity.valid === true
for any input value, as if thepattern
attribute wasn’t there). In other words, the only Web Compat risk is that a website without server-side validation would suddenly allow submission of values that would previously be prevented by the client-sidepattern
. All currently allowed inputs would still be accepted, just as they did previously.IMHO making the change is worth it given the powerful new functionality it brings, and the relatively small compatibility risk. This is reminiscent of the discussion in whatwg/html#439 (but in a different direction).
For context, here’s a few pointers w.r.t. when we decided to implicitly enable the
u
flag for thepattern
attribute in the first place:Checklist
v
flag instead ofu
forpattern
RegExps whatwg/html#7908v
flag web-platform-tests/wpt#38547Further details
pattern
attribute. The work is in the form of a PR to the WHATWG HTML Standard.UseCounter
giving us the upper bound of potential compat issues. None of theUseCounter
hits so far (see analysis starting with comment #11 on the crbug) constitute an issue in practice.We'd prefer the TAG provide feedback as (please delete all but the desired option):
💬 leave review feedback as a comment in this issue and @-notify
mathiasbynens
The text was updated successfully, but these errors were encountered: