mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
feat: implement ShadowRoot::setHTMLUnsafe (#36240)
Implements #36166 --------- Signed-off-by: TG <ebiritg@gmail.com>
This commit is contained in:
parent
5cdb0865ba
commit
1a3f10bba4
11 changed files with 46 additions and 4940 deletions
|
@ -3025,28 +3025,8 @@ impl ElementMethods<crate::DomTypeHolder> for Element {
|
|||
DomRoot::from_ref(self.upcast())
|
||||
};
|
||||
|
||||
// Step 3. Unsafely set HTML given target, this, and compliantHTML.
|
||||
// Let newChildren be the result of the HTML fragment parsing algorithm.
|
||||
let new_children = ServoParser::parse_html_fragment(self, html, true, can_gc);
|
||||
|
||||
let context_document = {
|
||||
if let Some(template) = self.downcast::<HTMLTemplateElement>() {
|
||||
template.Content(can_gc).upcast::<Node>().owner_doc()
|
||||
} else {
|
||||
self.owner_document()
|
||||
}
|
||||
};
|
||||
|
||||
// Let fragment be a new DocumentFragment whose node document is contextElement's node document.
|
||||
let frag = DocumentFragment::new(&context_document, can_gc);
|
||||
|
||||
// For each node in newChildren, append node to fragment.
|
||||
for child in new_children {
|
||||
frag.upcast::<Node>().AppendChild(&child, can_gc).unwrap();
|
||||
}
|
||||
|
||||
// Replace all with fragment within target.
|
||||
Node::replace_all(Some(frag.upcast()), &target, can_gc);
|
||||
// Step 3. Unsafely set HTML given target, this, and compliantHTML
|
||||
Node::unsafely_set_html(&target, self, html, can_gc);
|
||||
}
|
||||
|
||||
/// <https://html.spec.whatwg.org/multipage/#dom-element-gethtml>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue