Skip to content

fix(js): make setAttributeNS/getAttributeNS/removeAttributeNS namespace-aware - #514

Open
mnaza wants to merge 3 commits into
h4ckf0r0day:mainfrom
mnaza:fix/attribute-ns-503
Open

fix(js): make setAttributeNS/getAttributeNS/removeAttributeNS namespace-aware#514
mnaza wants to merge 3 commits into
h4ckf0r0day:mainfrom
mnaza:fix/attribute-ns-503

Conversation

@mnaza

@mnaza mnaza commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #503.

Problem

setAttributeNS/getAttributeNS/removeAttributeNS ignored the namespace: setAttributeNS stored 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') returned null.

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 both setAttributeNS-created xlink:href and parser-created href resolve). The non-namespaced getAttribute/serialization paths are untouched; getAttributeNS(null, name) still reads plain attributes.

Tests

Three runtime.rs tests (RED→GREEN): NS round-trip by (ns, local), removeAttributeNS, and the getAttributeNS(null, name) backward-compat guard. obscura-js + obscura-dom 165/165, obscura-cdp 94/94.


Note: touches tree.rs + bootstrap.js + ops.rs + runtime.rs tests; overlaps #495/#498/#499/#500/#504.

…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
mnaza force-pushed the fix/attribute-ns-503 branch from 233cdcd to 6314ecb Compare July 26, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setAttributeNS/getAttributeNS/removeAttributeNS ignore the namespace

2 participants