- From: TAMURA, Kent <notifications@github.com>
- Date: Thu, 09 Apr 2020 23:18:07 -0700
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/857@github.com>
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