mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
LibWeb: Assume XHTML <html> elements are in the HTML namespace
...unless specified otherwise explicitly. This is dervied from an interpretation of a note in the html5 spec at https://html.spec.whatwg.org/#xml
This commit is contained in:
parent
b86f0747dc
commit
5c23ef1596
Notes:
github-actions[bot]
2024-10-12 21:01:09 +00:00
Author: https://github.com/alimpfard
Commit: 5c23ef1596
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1751
1 changed files with 11 additions and 2 deletions
|
@ -57,7 +57,9 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name,
|
||||||
if (m_has_error)
|
if (m_has_error)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto found_explicit_namespace = false;
|
||||||
if (auto it = attributes.find("xmlns"); it != attributes.end()) {
|
if (auto it = attributes.find("xmlns"); it != attributes.end()) {
|
||||||
|
found_explicit_namespace = true;
|
||||||
m_namespace_stack.append({ m_namespace, 1 });
|
m_namespace_stack.append({ m_namespace, 1 });
|
||||||
m_namespace = MUST(FlyString::from_deprecated_fly_string(it->value));
|
m_namespace = MUST(FlyString::from_deprecated_fly_string(it->value));
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,8 +67,15 @@ void XMLDocumentBuilder::element_start(const XML::Name& name, HashMap<XML::Name,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == HTML::TagNames::html.to_deprecated_fly_string() && m_namespace != Namespace::HTML) {
|
if (name == HTML::TagNames::html.to_deprecated_fly_string() && m_namespace != Namespace::HTML) {
|
||||||
m_has_error = true;
|
// HTML / 2.1.3 XML compatibility: https://html.spec.whatwg.org/#xml
|
||||||
return;
|
// To ease migration from HTML to XML, user agents conforming to this specification will place elements in HTML
|
||||||
|
// in the http://www.w3.org/1999/xhtml namespace, at least for the purposes of the DOM and CSS.
|
||||||
|
// The term "HTML elements" refers to any element in that namespace, even in XML documents.
|
||||||
|
if (found_explicit_namespace || m_namespace_stack.size() != 1 || m_namespace_stack.last().depth != 2) {
|
||||||
|
m_has_error = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_namespace = Namespace::HTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto node = DOM::create_element(m_document, MUST(FlyString::from_deprecated_fly_string(name)), m_namespace).release_value_but_fixme_should_propagate_errors();
|
auto node = DOM::create_element(m_document, MUST(FlyString::from_deprecated_fly_string(name)), m_namespace).release_value_but_fixme_should_propagate_errors();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue