Index: third_party/WebKit/Source/core/dom/Node.cpp |
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp |
index 2d3a061973739b598e3b345d45378d6c94a8729b..2287b661c68ff829a3f1a43da7f9fd734b5c7fbd 100644 |
--- a/third_party/WebKit/Source/core/dom/Node.cpp |
+++ b/third_party/WebKit/Source/core/dom/Node.cpp |
@@ -1165,45 +1165,19 @@ bool Node::isEqualNode(Node* other) const { |
bool Node::isDefaultNamespace( |
const AtomicString& namespaceURIMaybeEmpty) const { |
+ // https://dom.spec.whatwg.org/#dom-node-isdefaultnamespace |
+ |
+ // 1. If namespace is the empty string, then set it to null. |
const AtomicString& namespaceURI = |
namespaceURIMaybeEmpty.isEmpty() ? nullAtom : namespaceURIMaybeEmpty; |
- switch (getNodeType()) { |
- case kElementNode: { |
- const Element& element = toElement(*this); |
- |
- if (element.prefix().isNull()) |
- return element.namespaceURI() == namespaceURI; |
- |
- AttributeCollection attributes = element.attributes(); |
- for (const Attribute& attr : attributes) { |
- if (attr.localName() == xmlnsAtom) |
- return attr.value() == namespaceURI; |
- } |
- |
- if (Element* parent = parentElement()) |
- return parent->isDefaultNamespace(namespaceURI); |
+ // 2. Let defaultNamespace be the result of running locate a namespace for |
+ // context object using null. |
+ const AtomicString& defaultNamespace = lookupNamespaceURI(String()); |
- return false; |
- } |
- case kDocumentNode: |
- if (Element* de = toDocument(this)->documentElement()) |
- return de->isDefaultNamespace(namespaceURI); |
- return false; |
- case kDocumentTypeNode: |
- case kDocumentFragmentNode: |
- return false; |
- case kAttributeNode: { |
- const Attr* attr = toAttr(this); |
- if (attr->ownerElement()) |
- return attr->ownerElement()->isDefaultNamespace(namespaceURI); |
- return false; |
- } |
- default: |
- if (Element* parent = parentElement()) |
- return parent->isDefaultNamespace(namespaceURI); |
- return false; |
- } |
+ // 3. Return true if defaultNamespace is the same as namespace, and false |
+ // otherwise. |
+ return namespaceURI == defaultNamespace; |
} |
const AtomicString& Node::lookupPrefix(const AtomicString& namespaceURI) const { |