Skip to content

Commit d24e64d

Browse files
Allow <input> in <select> before <option>s
This patch allows behind a flag and UseCounts when an <input> is parsed inside a <select> before any <option> elements were parsed inside the <select>. Before this patch, <input> would close their ancestor <select> before being inserted. Bug: 396300371 Change-Id: Ia2e3aeb4894e798a950d1b3732208134908f8fdc Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7804988 Reviewed-by: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1625031}
1 parent 3218d1f commit d24e64d

2 files changed

Lines changed: 50 additions & 22 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<link rel=author href="mailto:jarhar@chromium.org">
3+
<link rel=help href="https://github.com/whatwg/html/issues/12050">
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
7+
<select class=test
8+
data-description='Input tags should parse inside select if there are no options first.'
9+
data-expect='<button>button</button><input>'>
10+
<button>button</button>
11+
<input>
12+
</select>
13+
14+
<select class=test
15+
data-description='Input tags should parse inside select if nested in another tag'
16+
data-expect='<div><input></div>'>
17+
<div>
18+
<input>
19+
</div>
20+
</select>
21+
22+
<select class=test
23+
data-description='Input tags should close select when directly inside an <option>'
24+
data-expect='<option></option>'>
25+
<option>
26+
<input>
27+
</option>
28+
</select>
29+
30+
<select class=test
31+
data-description='Input tags should close select when placed after an <option>'
32+
data-expect='<option></option>'>
33+
<option></option>
34+
<input>
35+
</select>
36+
37+
<script>
38+
function removeWhitespace(t) {
39+
return t.replace(/\s/g,'');
40+
}
41+
document.querySelectorAll('select.test').forEach(s => {
42+
assert_true(!!s.dataset.description.length);
43+
test(() => {
44+
// The document.body check here and in the other tests is to make sure that a
45+
// previous test case didn't leave the HTML parser open on another element.
46+
assert_equals(s.parentNode, document.body);
47+
assert_equals(removeWhitespace(s.innerHTML),removeWhitespace(s.dataset.expect));
48+
},s.dataset.description)
49+
});
50+
</script>

html/semantics/forms/the-select-element/customizable-select/select-parsing.html

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,34 +84,12 @@
8484
</div>
8585
</select>
8686

87-
<select class=test
88-
data-description='Input tags should not parse inside select instead of closing the select'
89-
data-expect=''>
90-
<input>
91-
</select>
92-
9387
<select class=test
9488
data-description='textarea tags should parse inside select instead of closing the select'
9589
data-expect='<textarea></textarea>'>
9690
<textarea></textarea>
9791
</select>
9892

99-
<select class=test
100-
data-description='Input tags should parse inside select if nested in another tag'
101-
data-expect='<div><input></div>'>
102-
<div>
103-
<input>
104-
</div>
105-
</select>
106-
107-
<select class=test
108-
data-description='Input tags should close select when directly inside an <option>'
109-
data-expect='<option></option>'>
110-
<option>
111-
<input>
112-
</option>
113-
</select>
114-
11593
<select class=test
11694
data-description='hr should generate implied end tags inside select'
11795
data-expect='<option>A</option><hr><option>B</option>'>

0 commit comments

Comments
 (0)