mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb: Append attributes to the correct element
The spec indicates we should append attributes to the top element of the stack of open elements. We were appending the attribute to the bottom.
This commit is contained in:
parent
9fe35ddddf
commit
657bbd1542
Notes:
github-actions[bot]
2024-07-30 07:42:32 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/657bbd1542c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/894
3 changed files with 5 additions and 4 deletions
|
@ -1 +1 @@
|
||||||
PASS (didn't crash)
|
HTML element has '<head' attribute: true
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
<script src="include.js"></script>
|
<script src="include.js"></script>
|
||||||
<script>
|
<script>
|
||||||
test(() => {
|
test(() => {
|
||||||
println("PASS (didn't crash)");
|
println(`HTML element has '<head' attribute: ${document.documentElement.hasAttribute('<head')}`);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1719,9 +1719,10 @@ void HTMLParser::handle_in_body(HTMLToken& token)
|
||||||
|
|
||||||
// Otherwise, for each attribute on the token, check to see if the attribute is already present on the top element of the stack of open elements.
|
// Otherwise, for each attribute on the token, check to see if the attribute is already present on the top element of the stack of open elements.
|
||||||
// If it is not, add the attribute and its corresponding value to that element.
|
// If it is not, add the attribute and its corresponding value to that element.
|
||||||
|
auto& top_element = m_stack_of_open_elements.first();
|
||||||
token.for_each_attribute([&](auto& attribute) {
|
token.for_each_attribute([&](auto& attribute) {
|
||||||
if (!current_node().has_attribute(attribute.local_name))
|
if (!top_element.has_attribute(attribute.local_name))
|
||||||
current_node().append_attribute(attribute.local_name, attribute.value);
|
top_element.append_attribute(attribute.local_name, attribute.value);
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue