Skip to content

Commit

Permalink
HTML: allowed <hr> to be used inside <select>.
Browse files Browse the repository at this point in the history
Discussion:
whatwg/html#3410

Specification changes:
whatwg/html@b9c5dee

This related lexbor#256 issue on GitHub.
  • Loading branch information
lexborisov committed Jan 18, 2025
1 parent e58e1e8 commit f94d97a
Show file tree
Hide file tree
Showing 2 changed files with 178 additions and 2 deletions.
34 changes: 34 additions & 0 deletions source/lexbor/html/tree/insertion_mode/in_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,37 @@ lxb_html_tree_insertion_mode_in_select_optgroup(lxb_html_tree_t *tree,
return true;
}

lxb_inline bool
lxb_html_tree_insertion_mode_in_select_hr(lxb_html_tree_t *tree,
lxb_html_token_t *token)
{
lxb_html_element_t *element;
lxb_dom_node_t *node = lxb_html_tree_current_node(tree);

if (lxb_html_tree_node_is(node, LXB_TAG_OPTION)) {
lxb_html_tree_open_elements_pop(tree);
}

node = lxb_html_tree_current_node(tree);

if (lxb_html_tree_node_is(node, LXB_TAG_OPTGROUP)) {
lxb_html_tree_open_elements_pop(tree);
}

element = lxb_html_tree_insert_html_element(tree, token);
if (element == NULL) {
tree->status = LXB_STATUS_ERROR_MEMORY_ALLOCATION;

return lxb_html_tree_process_abort(tree);
}

lxb_html_tree_open_elements_pop(tree);

lxb_html_tree_acknowledge_token_self_closing(tree, token);

return true;
}

lxb_inline bool
lxb_html_tree_insertion_mode_in_select_optgroup_closed(lxb_html_tree_t *tree,
lxb_html_token_t *token)
Expand Down Expand Up @@ -319,6 +350,9 @@ lxb_html_tree_insertion_mode_in_select(lxb_html_tree_t *tree,
case LXB_TAG_OPTGROUP:
return lxb_html_tree_insertion_mode_in_select_optgroup(tree, token);

case LXB_TAG_HR:
return lxb_html_tree_insertion_mode_in_select_hr(tree, token);

case LXB_TAG_SELECT:
return lxb_html_tree_insertion_mode_in_select_select(tree, token);

Expand Down
146 changes: 144 additions & 2 deletions test/files/lexbor/html/html5_test/webkit02.ton
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
/* Test count: 21 */
/* Test count: 31 */
/* Test number: 1 */
{
"data": $DATA{ ,12}
Expand Down Expand Up @@ -336,4 +336,146 @@
"<div>foo</div>"
$DATA
},
]
/* Test number: 22 */
{
"data": "<select><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<select>
<hr>
$DATA
},
/* Test number: 23 */
{
"data": "<select><option><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<select>
<option>
<hr>
$DATA
},
/* Test number: 24 */
{
"data": "<select><optgroup><option><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<select>
<optgroup>
<option>
<hr>
$DATA
},
/* Test number: 25 */
{
"data": "<select><optgroup><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<select>
<optgroup>
<hr>
$DATA
},
/* Test number: 26 */
{
"data": "<select><option><optgroup><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<select>
<option>
<optgroup>
<hr>
$DATA
},
/* Test number: 27 */
{
"data": "<table><tr><td><select><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<table>
<tbody>
<tr>
<td>
<select>
<hr>
$DATA
},
/* Test number: 28 */
{
"data": "<table><tr><td><select><option><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<table>
<tbody>
<tr>
<td>
<select>
<option>
<hr>
$DATA
},
/* Test number: 29 */
{
"data": "<table><tr><td><select><optgroup><option><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<table>
<tbody>
<tr>
<td>
<select>
<optgroup>
<option>
<hr>
$DATA
},
/* Test number: 30 */
{
"data": "<table><tr><td><select><optgroup><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<table>
<tbody>
<tr>
<td>
<select>
<optgroup>
<hr>
$DATA
},
/* Test number: 31 */
{
"data": "<table><tr><td><select><option><optgroup><hr>",
"result": $DATA{ ,12}
<html>
<head>
<body>
<table>
<tbody>
<tr>
<td>
<select>
<option>
<optgroup>
<hr>
$DATA
}
]

0 comments on commit f94d97a

Please sign in to comment.