From a5f905f4d3a637dc2dcc1bbe11fd1b59b4e8af81 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 3 May 2023 09:04:07 -0400 Subject: [PATCH 1/3] test: update to latest html5lib-tests with the hr-in-select tests --- test/html5lib-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/html5lib-tests b/test/html5lib-tests index 66f49b1de04..c67f90eacac 160000 --- a/test/html5lib-tests +++ b/test/html5lib-tests @@ -1 +1 @@ -Subproject commit 66f49b1de0487b8077f73813137149d15dc43af4 +Subproject commit c67f90eacac14e022b1f2c2e5ac559879581e9ff From 443dcc02db6a41231a341abd12db2b0d737027df Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 3 May 2023 08:48:52 -0400 Subject: [PATCH 2/3] test: improve failure message for tree construction where before we saw: TestHtml5TreeConstructionWebkit02#test_31 [/home/flavorjones/code/oss/nokogiri/test/html5/test_tree_construction.rb:35] Minitest::Assertion: Element has wrong number of children ["option"] in
has wrong number of children ["option"] Input:
| | |
| . Expected: 2 Actual: 1 --- test/html5/test_tree_construction.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/html5/test_tree_construction.rb b/test/html5/test_tree_construction.rb index ac4684227ee..7e01be866c8 100644 --- a/test/html5/test_tree_construction.rb +++ b/test/html5/test_tree_construction.rb @@ -35,7 +35,12 @@ def compare_nodes(node, ng_node) assert_equal( node[:children].length, ng_node.children.length, - "Element <#{node[:tag]}> has wrong number of children #{ng_node.children.map(&:name)} in #{@test[:data]}", + [ + "Element <#{node[:tag]}> has wrong number of children #{ng_node.children.map(&:name)}", + " Input: #{@test[:data]}", + "Expected: #{@test[:raw].join("\n ")}", + " Parsed: #{ng_node.to_html}", + ].join("\n"), ) when Nokogiri::XML::Node::TEXT_NODE, Nokogiri::XML::Node::CDATA_SECTION_NODE # We preserve the CDATA in the tree, but the tests represent it as text. @@ -205,9 +210,12 @@ def self.parse_test(test_data) children: [], } open_nodes = [document] + test[:raw] = [] while index < lines.length raise(BadHtml5libFormat, "Expected '| ' but got #{lines[index]}") unless /^\| ( *)([^ ].*$)/ =~ lines[index] + test[:raw] << lines[index] + depth = $LAST_MATCH_INFO[1].length if depth.odd? raise(BadHtml5libFormat, "Invalid nesting depth") From 68ededfe4d3054dc8ab81cc404494094bac8ecb6 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Wed, 3 May 2023 08:55:24 -0400 Subject: [PATCH 3/3] feat: gumbo support for
in ` [[whatwg/html#3410](https://github.com/whatwg/html/issues/3410), [whatwg/html#9124](https://github.com/whatwg/html/pull/9124)] ### Deprecated diff --git a/gumbo-parser/src/parser.c b/gumbo-parser/src/parser.c index 0ed8731a8c4..67812b23fe4 100644 --- a/gumbo-parser/src/parser.c +++ b/gumbo-parser/src/parser.c @@ -3964,6 +3964,18 @@ static void handle_in_select(GumboParser* parser, GumboToken* token) { insert_element_from_token(parser, token); return; } + if (tag_is(token, kStartTag, GUMBO_TAG_HR)) { + if (node_html_tag_is(get_current_node(parser), GUMBO_TAG_OPTION)) { + pop_current_node(parser); + } + if (node_html_tag_is(get_current_node(parser), GUMBO_TAG_OPTGROUP)) { + pop_current_node(parser); + } + insert_element_from_token(parser, token); + pop_current_node(parser); + acknowledge_self_closing_tag(parser); + return; + } if (tag_is(token, kEndTag, GUMBO_TAG_OPTGROUP)) { GumboVector* open_elements = &parser->_parser_state->_open_elements; if (