[whatwg/dom] lookupNamespaceURI('xml') (#857)

Specification: https://dom.spec.whatwg.org/#locate-a-namespace https://dom.spec.whatwg.org/#dom-xpathnsresolver-lookupnamespaceuri https://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator-createNSResolver

Chrome, EdgeHTML, and Safari follows the current definition of `Node.lookupNamespaceURI()` and `XPathEvaluator.createNSResolver()`.  That is to say, `Node.lookupNamespacURI()` has no special handling for 'xml' prefix, and `createNSResolver()` adds it.

On the other hand, Firefox's `Node.lookupNamespaceURI('xml')` returns the XML namespace if the node is an `Element`, and `XPathEvaluator.createNSResolver()` just returns the specified node.

I prefer the Firefox behavior because of its simplicity.

Demo code:
```html
<!DOCTYPE html>
<html>
<pre></pre>
<script>
function t(header, node) {
  document.querySelector('pre').textContent += header + ':\traw=' +
      node.lookupNamespaceURI('xml') + '\twrapped=' +
      document.createNSResolver(node).lookupNamespaceURI('xml') + '\n';
}
document.querySelector('pre').textContent += 'Wrapped type: ' +
    document.createNSResolver(document).constructor.name + '\n';

t('Document', new Document());
t('DocumentType', document.doctype);
t('DocumentFragment', document.createDocumentFragment());
t('Attr', document.createAttribute('attr'));
t('Text', document.createTextNode('t'));
t('Element', document.createElement('div'));
</script>
</html>
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/857

Received on Friday, 10 April 2020 06:18:22 UTC