Bladeren bron

LibWeb: Bring Node closer to spec

Node::base_uri() correct implementation was left as a FIXME.
Igor Pissolati 3 jaren geleden
bovenliggende
commit
682a4a347a

+ 7 - 0
Userland/Libraries/LibWeb/DOM/Node.cpp

@@ -78,6 +78,13 @@ Node::~Node()
     deallocate_node_id(m_id);
 }
 
+// https://dom.spec.whatwg.org/#dom-node-baseuri
+String Node::base_uri() const
+{
+    // FIXME: Return this’s node document’s document base URL, serialized.
+    return document().url_string();
+}
+
 const HTML::HTMLAnchorElement* Node::enclosing_link_element() const
 {
     for (auto* node = this; node; node = node->parent()) {

+ 2 - 0
Userland/Libraries/LibWeb/DOM/Node.h

@@ -113,6 +113,8 @@ public:
 
     virtual FlyString node_name() const = 0;
 
+    String base_uri() const;
+
     String descendant_text_content() const;
     String text_content() const;
     void set_text_content(String const&);

+ 2 - 0
Userland/Libraries/LibWeb/DOM/Node.idl

@@ -7,6 +7,8 @@ interface Node : EventTarget {
     readonly attribute unsigned short nodeType;
     readonly attribute DOMString nodeName;
 
+    readonly attribute USVString baseURI;
+
     boolean hasChildNodes();
     [SameObject] readonly attribute NodeList childNodes;
     readonly attribute Node? firstChild;