Skip to content

Commit c41fa87

Browse files
mathiasbynensmarcoscaceres
authored andcommitted
Add <input pattern> tests for RegExp u flag (#38281)
This patch adds a test verifying that <input pattern> is Unicode code point-aware (rather than dealing with individual surrogate halves), and another test verifying that <input pattern> supports Unicode property escape syntax. These two pieces of functionality are part of the RegExp `u` flag in JavaScript. References: - https://www.w3.org/Bugs/Public/show_bug.cgi?id=26915 - whatwg/html@0fa7138
1 parent a270e43 commit c41fa87

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
<!DOCTYPE html>
2+
<meta charset="utf-8">
23
<title>pattern attribute</title>
34
<meta name=viewport content="width=device-width">
45
<link rel="author" title="Fabrice Clari" href="mailto:[email protected]">
56
<link rel="author" title="Dimitri Bocquet" href="mailto:[email protected]">
7+
<link rel="author" title="Mathias Bynens" href="https://mathiasbynens.be/">
68
<link rel="help" href="https://html.spec.whatwg.org/multipage/#attr-input-pattern">
79
<script src="/resources/testharness.js"></script>
810
<script src="/resources/testharnessreport.js"></script>
911
<h1><code>pattern</code> attribute</h1>
1012
<div style="display: none">
11-
<input pattern="[a-z]{3}" value="abcd" title="three letters max">
13+
<input pattern="[a-z]{3}" value="abcd" id="basic">
14+
<input pattern="a.b" value="a&#x1D306;b" id="unicode-code-points">
15+
<input pattern="\p{ASCII_Hex_Digit}+" value="c0ff33" id="unicode-property-escape">
1216
</div>
1317
<div id="log"></div>
1418
<script>
15-
test(function() {
16-
const input = document.querySelector("input");
19+
test(() => {
20+
const input = document.querySelector("#basic");
1721

1822
assert_idl_attribute(input, "pattern");
1923
assert_equals(input.pattern, "[a-z]{3}");
@@ -22,5 +26,17 @@ <h1><code>pattern</code> attribute</h1>
2226
assert_false(input.validity.valid);
2327

2428
assert_true(input.matches(":invalid"));
25-
}, "pattern attribute support on input element");
29+
}, "basic <input pattern> support");
30+
31+
test(() => {
32+
const input = document.querySelector("#unicode-code-points");
33+
assert_true(input.validity.valid);
34+
assert_true(input.matches(":valid"));
35+
}, "<input pattern> is Unicode code point-aware");
36+
37+
test(() => {
38+
const input = document.querySelector("#unicode-property-escape");
39+
assert_true(input.validity.valid);
40+
assert_true(input.matches(":valid"));
41+
}, "<input pattern> supports Unicode property escape syntax");
2642
</script>

0 commit comments

Comments
 (0)