mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Implement Document.importNode
This commit is contained in:
parent
3252d984ae
commit
27dfd0170e
Notes:
sideshowbarker
2024-07-18 03:26:03 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/27dfd0170ed Pull-request: https://github.com/SerenityOS/serenity/pull/10218 Reviewed-by: https://github.com/linusg
3 changed files with 13 additions and 0 deletions
|
@ -814,6 +814,17 @@ NonnullRefPtrVector<HTML::HTMLScriptElement> Document::take_scripts_to_execute_a
|
|||
return move(m_scripts_to_execute_as_soon_as_possible);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-importnode
|
||||
ExceptionOr<NonnullRefPtr<Node>> Document::import_node(NonnullRefPtr<Node> node, bool deep)
|
||||
{
|
||||
// 1. If node is a document or shadow root, then throw a "NotSupportedError" DOMException.
|
||||
if (is<Document>(*node) || is<ShadowRoot>(*node))
|
||||
return DOM::NotSupportedError::create("Cannot import a document or shadow root.");
|
||||
|
||||
// 2. Return a clone of node, with this and the clone children flag set if deep is true.
|
||||
return node->clone_node(this, deep);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-node-adopt
|
||||
void Document::adopt_node(Node& node)
|
||||
{
|
||||
|
|
|
@ -202,6 +202,7 @@ public:
|
|||
bool in_quirks_mode() const { return m_quirks_mode == QuirksMode::Yes; }
|
||||
void set_quirks_mode(QuirksMode mode) { m_quirks_mode = mode; }
|
||||
|
||||
ExceptionOr<NonnullRefPtr<Node>> import_node(NonnullRefPtr<Node> node, bool deep);
|
||||
void adopt_node(Node&);
|
||||
ExceptionOr<NonnullRefPtr<Node>> adopt_node_binding(NonnullRefPtr<Node>);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ interface Document : Node {
|
|||
Range createRange();
|
||||
Event createEvent(DOMString interface);
|
||||
|
||||
[CEReactions, NewObject] Node importNode(Node node, optional boolean deep = false);
|
||||
[CEReactions, ImplementedAs=adopt_node_binding] Node adoptNode(Node node);
|
||||
|
||||
[ImplementedAs=style_sheets_for_bindings] readonly attribute StyleSheetList styleSheets;
|
||||
|
|
Loading…
Reference in a new issue