You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update HTML parser changes in select explainer (#1077)
* Update HTML parser changes in select explainer
Based on discussion and developer feedback in the WHATWG issue about
HTML parser changes for <select>, we are not requiring <datalist> to be
added to the author HTML for most cases. This PR updates the explainer
to remove <datalist> in a bunch of places.
whatwg/html#10310
* say slotted instead of put in
Copy file name to clipboardExpand all lines: site/src/pages/components/customizableselect.mdx
+53-66Lines changed: 53 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,18 +62,16 @@ And here the same `<select>` with opt ins to the new stylability behavior which
62
62
63
63
## HTML parser changes
64
64
65
-
The current behavior in the HTML parser for `<select>` is to remove all tags which aren't `<option>` or `<optgroup>`. We will change the HTML parser to allow `<datalist>` and `<button>` as a child of `<select>`, and allow any other content within that `<datalist>`or `<button>`. The `<button>` allows authors to replace the in-page button which opens the popup, and the `<datalist>` allows authors to replace the popup element containing the options.
65
+
The current behavior in the HTML parser for `<select>` is to remove all tags which aren't `<option>` or `<optgroup>`. We will change the HTML parser to allow almost all tags as descendants of `<select>`. Adding `<button>`as a child of `<select>` allows authors to replace the in-page button which opens the popup, and all other tags are slotted into the popover element containing the options.
66
66
67
67
Here is a basic example which uses the parser changes:
68
68
```html
69
69
<selectstyle="appearance:base-select">
70
70
<button>
71
71
<selectedoption></selectedoption>
72
72
</button>
73
-
<datalist>
74
-
<option>one</option>
75
-
<option>two</option>
76
-
</datalist>
73
+
<option><imgsrc="..."alt="">one</option>
74
+
<option><imgsrc="..."alt="">two</option>
77
75
</select>
78
76
```
79
77
@@ -87,14 +85,11 @@ This example changes the fonts and colors of various parts of the button and lis
87
85
<divclassName="code-container">
88
86
```html
89
87
<select>
90
-
<datalist>
91
-
<option>one</option>
92
-
<option>two</option>
93
-
</datalist>
88
+
<option>one</option>
89
+
<option>two</option>
94
90
</select>
95
91
<style>
96
-
selectdatalist,
97
-
selectbutton {
92
+
select, select::select-fallback-button {
98
93
font-family: monospace;
99
94
font-size: 12px;
100
95
}
@@ -117,20 +112,18 @@ This example adds "rich content" inside option elements in the form of country f
117
112
<div>
118
113
```html
119
114
<select>
120
-
<datalist>
121
-
<option>
122
-
<imgsrc="usa.jpg"alt="flag of USA">
123
-
USA
124
-
</option>
125
-
<option>
126
-
<imgsrc="germany.jpg"alt="flag of Germany">
127
-
Germany
128
-
</option>
129
-
<option>
130
-
<imgsrc="spain.jpg"alt="flag of Spain">
131
-
Spain
132
-
</option>
133
-
</datalist>
115
+
<option>
116
+
<imgsrc="usa.jpg"alt="flag of USA">
117
+
USA
118
+
</option>
119
+
<option>
120
+
<imgsrc="germany.jpg"alt="flag of Germany">
121
+
Germany
122
+
</option>
123
+
<option>
124
+
<imgsrc="spain.jpg"alt="flag of Spain">
125
+
Spain
126
+
</option>
134
127
</select>
135
128
```
136
129
</div>
@@ -177,14 +170,12 @@ This example uses the customizable `<select>` element with custom CSS to target
0 commit comments