From 8bafbdddc6bb4fcadeb03d089ebd9fb43e7bdd74 Mon Sep 17 00:00:00 2001 From: Luke Date: Sun, 2 May 2021 21:03:50 +0100 Subject: [PATCH] LibWeb: Expose Node.ownerDocument Required by jQuery. --- Userland/Libraries/LibWeb/DOM/Node.cpp | 8 ++++++++ Userland/Libraries/LibWeb/DOM/Node.h | 2 ++ Userland/Libraries/LibWeb/DOM/Node.idl | 1 + 3 files changed, 11 insertions(+) diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index 058dda44cc..93d85754b8 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -539,4 +539,12 @@ bool Node::is_host_including_inclusive_ancestor_of(const Node& other) const return is_inclusive_ancestor_of(other) || (is(other.root()) && downcast(other.root())->host() && is_inclusive_ancestor_of(*downcast(other.root())->host().ptr())); } +// https://dom.spec.whatwg.org/#dom-node-ownerdocument +RefPtr Node::owner_document() const +{ + if (is_document()) + return nullptr; + return m_document; +} + } diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 701772e0e9..bd0a59c28f 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -99,6 +99,8 @@ public: Document& document() { return *m_document; } const Document& document() const { return *m_document; } + RefPtr owner_document() const; + const HTML::HTMLAnchorElement* enclosing_link_element() const; const HTML::HTMLElement* enclosing_html_element() const; const HTML::HTMLElement* enclosing_html_element_with_attribute(const FlyString&) const; diff --git a/Userland/Libraries/LibWeb/DOM/Node.idl b/Userland/Libraries/LibWeb/DOM/Node.idl index 7c17fc8bad..0c0b38cb01 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.idl +++ b/Userland/Libraries/LibWeb/DOM/Node.idl @@ -13,6 +13,7 @@ interface Node : EventTarget { readonly attribute Node? parentNode; readonly attribute Element? parentElement; readonly attribute boolean isConnected; + readonly attribute Document? ownerDocument; attribute DOMString textContent; Node appendChild(Node node);