Skip to content

Specifying the "u" flag to pattern attribute may cause backward compatibility issue #439

@arai-a

Description

@arai-a

https://html.spec.whatwg.org/multipage/forms.html#the-pattern-attribute

ES6 requires more strict syntax when "u" flag is specified for RegExp (see the difference between [+U] and [~U] there), and it rejects some patterns that was working without "u" flag.

for example, escaping single-quote is disallowed when "u" flag is set, and following case does no pattern matching, because of SyntaxError.

var input = document.getElementById("id_of_input");
input.pattern = "foo\\'bar";
input.value = "foo\\'bar";    // the input is not suffered
input.value = "baz";           // the input is not suffered (!)

IIUC, the flag for pattern attribute is changed at some point from "", and this may cause backward compatibility issue.
Also, it could be hard to figure out the regression, for web content authors, because the SyntaxError is not reported, according to the spec.

(this is originally reported to https://bugzilla.mozilla.org/show_bug.cgi?id=1227906)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions