From b9c5dee3f015d7f9276e7e35d4b6022993c93e64 Mon Sep 17 00:00:00 2001
From: Anne van Kesteren
Date: Tue, 2 May 2023 16:19:45 +0200
Subject: [PATCH] Allow to be used inside as a separator
This is a long-standing WebKit feature that regressed as part of the standardized HTML parser effort. This suggests bringing it back with optional semantics, but a mandatory HTML parser change.
The HTML parser change is not expected to be significant for existing content or XSS. When the feature is correctly used it will also not hurt HTML parsers that have not yet incorporated the change. I.e., it should be fully backwards compatible.
Tests: https://github.com/html5lib/html5lib-tests/pull/167.
Fixes #3410.
---
source | 65 ++++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 52 insertions(+), 13 deletions(-)
diff --git a/source b/source
index c1da72677b9..95e5ddc7864 100644
--- a/source
+++ b/source
@@ -19364,6 +19364,7 @@ and is further discussed below.</div>
Flow content .
Contexts in which this element can be used :
Where flow content is expected.
+ As a child of a select
element.
Content model :
Nothing .
Content attributes :
@@ -19385,8 +19386,9 @@ interface HTMLHRElement : HTMLElement {
The hr
element represents a paragraph -level thematic
- break, e.g. a scene change in a story, or a transition to another topic within a section of a
- reference book.
+ break, e.g., a scene change in a story, or a transition to another topic within a section of a
+ reference book; alternatively, it represents a separator between a set of options of a
+ select
element.
@@ -52319,7 +52321,7 @@ interface HTMLButtonElement : HTMLElement {
Contexts in which this element can be used :
Where phrasing content is expected.
Content model :
- Zero or more option
, optgroup
, and script-supporting elements.
+ Zero or more option
, optgroup
, hr
, and script-supporting elements.
Content attributes :
Global attributes
autocomplete
@@ -52873,6 +52875,19 @@ interface HTMLSelectElement : HTMLElement {
+
+
Occasionally it can be useful to have a separator:
+
+
<label>
+ Select the song to play next:
+ <select required name="next">
+ <option value="sr">Random
+ <hr>
+ <option value="s1">It Sucks to Be Me (Reprise)
+ <option value="s2">There is Life Outside Your Apartment
+ …
+
+
The datalist
element
@@ -112874,10 +112889,11 @@ dictionary StorageEventInit : EventInit {
below can handle the non- case if we ever allow it) -->
An optgroup
element's end tag may be omitted
if the optgroup
element is
- immediately followed by another optgroup
element, or if there is no more content in
- the parent element.
+ immediately followed by another optgroup
element, if it is immediately followed by an
+ hr
element, or if there is no more content in the parent
+ element.
An option
element's end tag may be omitted if
- the option
element is immediately followed by another option
element, or
- if it is immediately followed by an optgroup
element, or if there is no more content
- in the parent element.
+ the option
element is immediately followed by another option
element, if
+ it is immediately followed by an optgroup
element, if it is immediately followed by
+ an hr
element, or if there is no more content in the parent element.
A colgroup
element's start tag may be
@@ -121080,6 +121096,25 @@ document.body.appendChild(text);
Insert an HTML element for the token.
+ A start tag whose tag name is "hr"
+
+
+ If the current node is an option
element, pop that node from the
+ stack of open elements .
+
+
+
+ If the current node is an optgroup
element, pop that node from the
+ stack of open elements .
+
+
+ Insert an HTML element for the token. Immediately pop the current
+ node off the stack of open elements .
+
+ Acknowledge the token's self-closing flag , if it is set.
+
+
An end tag whose tag name is "optgroup"
@@ -125976,6 +126011,9 @@ progress { appearance: auto; }
data-x="concept-option-label">label, indented under its optgroup
element if it
has one.
+ Each sequence of one or more child hr
element siblings may be rendered as a single
+ separator.
+
The width of the select
's labels is the wider of the width necessary to
render the widest optgroup
, and the width necessary to render the widest
option
element in the element's list of
@@ -134187,16 +134225,16 @@ INSERT INTERFACES HERE
Dean Edridge,
Dean Edwards,
Dean Jackson,
- Debanjana Sarkar ,
+ Debanjana Sarkar,
Debi Orton,
- Delan Azabani,
+ Delan Azabani,
Derek Featherstone,
Derek Guenther,
Devarshi Pant,
Devdatta,
Devin Rousso,
Diego Ferreiro Val,
- Diego González Zúñiga ,
+ Diego González Zúñiga,
Diego Ponce de León,
Dimitri Glazkov,
Dimitry Golubovsky,
@@ -134240,6 +134278,7 @@ INSERT INTERFACES HERE
Eric Portis,
Eric Rescorla,
Eric Semling,
+ Eric Shepherd,
Eric Willigers,
Erik Arvidsson,
Erik Charlebois,