Open scribetw opened 2 years ago
I don't know how other libraries handle this situation?
Resolving the property early might be possible, but it breaks the general mutability of the DOM (or require complicated invalidation logic).
Storing the property on copy might be possible, but changes the DOM in unexpected ways.
In xmldom
(a Node.js library) it is stored while parsing and creating a new element or attribute node.
https://github.com/xmldom/xmldom/blob/e31e25d9b0ce79e8545d23771181a79d96b80c73/lib/dom.js#L894
https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-NodeNSname
namespaceURI of type DOMString, readonly, introduced in DOM Level 2 The namespace URI of this node, or null if it is unspecified. This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.
I think it's safe to store it at creation time.
Interesting: https://www.w3.org/TR/DOM-Level-2-Core/core.html#Namespaces-Considerations. This basically breaks mutability and serialization of the DOM by design :-/
I'm using
xml
to process SAML responses.https://github.com/renggli/dart-xml/blob/3c587e18c3b507eb737a2aec864f0bc8413f8aed/lib/src/xml/utils/prefix_name.dart#L18 The resolving of a namespace URI is depending on the ancestors.
Consider storing the namespace URI property directly.