mirror of
https://github.com/lexmount/moli.git
synced 2026-10-03 08:00:49 +00:00
fix(html): create wrappers for empty html innerHTML
This commit is contained in:
@@ -763,7 +763,14 @@ impl DocumentRuntime {
|
||||
.node(target)
|
||||
.map(|node| node.child_ids(self.dom_host().dom()).collect::<Vec<_>>())
|
||||
.unwrap_or_default();
|
||||
if html.is_empty() && existing_children.is_empty() {
|
||||
let empty_html_context_creates_document_wrappers = self
|
||||
.dom_host()
|
||||
.node(context)
|
||||
.is_some_and(|node| node.is_html_element_named("html"));
|
||||
if html.is_empty()
|
||||
&& existing_children.is_empty()
|
||||
&& !empty_html_context_creates_document_wrappers
|
||||
{
|
||||
return false;
|
||||
}
|
||||
let Some(fragment) = self.build_fragment_from_html(
|
||||
|
||||
@@ -7663,6 +7663,27 @@ fn document_element_inner_html_fragment_preserves_html_context_wrappers() {
|
||||
assert_eq!(result, "HEAD|BODY");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_detached_html_inner_html_creates_head_and_body() {
|
||||
let mut vm = new_storage_test_vm("https://example.com/");
|
||||
|
||||
let result = vm
|
||||
.eval(
|
||||
r#"
|
||||
(() => {
|
||||
const html = document.createElement("html");
|
||||
html.innerHTML = "";
|
||||
return Array.from(html.childNodes)
|
||||
.map(node => node.nodeName)
|
||||
.join("|");
|
||||
})()
|
||||
"#,
|
||||
)
|
||||
.expect("empty detached HTML innerHTML probe should evaluate");
|
||||
|
||||
assert_eq!(result, "HEAD|BODY");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn child_window_text_replacement_setters_dispatch_disconnected_callbacks() {
|
||||
let mut vm = new_storage_test_vm("https://example.com/");
|
||||
|
||||
Reference in New Issue
Block a user