fix(js): make setAttributeNS/getAttributeNS/removeAttributeNS namespace-aware - #514
Open
mnaza wants to merge 3 commits into
Open
fix(js): make setAttributeNS/getAttributeNS/removeAttributeNS namespace-aware#514mnaza wants to merge 3 commits into
mnaza wants to merge 3 commits into
Conversation
…ce-aware The three NS methods ignored the namespace: setAttributeNS stored the qualified name against the non-namespaced store and getAttributeNS/removeAttributeNS looked up by local name only, so a namespaced attribute was not addressable by (namespace, localName) — getAttributeNS(xlink, 'href') returned null. Record the namespace on the attribute and add namespace-aware DOM ops that match by (namespace, localName), where the local name is the attribute name after any prefix (so both setAttributeNS-created 'xlink:href' and parser-created 'href' resolve). The non-namespaced getAttribute/serialization paths are untouched, and getAttributeNS(null, name) still reads plain attributes. Fixes h4ckf0r0day#503
mnaza
force-pushed
the
fix/attribute-ns-503
branch
from
July 26, 2026 11:30
233cdcd to
6314ecb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #503.
Problem
setAttributeNS/getAttributeNS/removeAttributeNSignored the namespace:setAttributeNSstored the qualified name against the non-namespaced store and the getters/removers looked up by local name only, so a namespaced attribute was not addressable by(namespace, localName)—getAttributeNS(xlink, 'href')returnednull.Fix
Record the namespace on the attribute and add namespace-aware DOM ops that match by
(namespace, localName), where the local name is the attribute name after any prefix (so bothsetAttributeNS-createdxlink:hrefand parser-createdhrefresolve). The non-namespacedgetAttribute/serialization paths are untouched;getAttributeNS(null, name)still reads plain attributes.Tests
Three
runtime.rstests (RED→GREEN): NS round-trip by(ns, local),removeAttributeNS, and thegetAttributeNS(null, name)backward-compat guard. obscura-js + obscura-dom 165/165, obscura-cdp 94/94.Note: touches
tree.rs+bootstrap.js+ops.rs+runtime.rstests; overlaps #495/#498/#499/#500/#504.