blitz-dom: attributes in a namespace get the special handling of the same-named attribute in no namespace
Generated from repros/blitz-dom-namespaced-attribute-special-cased/README.md when the site was built at 7aa23e2.
What niso does
Section titled “What niso does”Nothing yet. setAttributeNS("https://example.com/attributes", "style", …) on an element that also has a
style attribute in no namespace re-parses the inline style from the namespaced one, so the element loses its
inline style (tests/wpt/expectations.json: dom/nodes/namespaced-attribute-mutations.html, the four
“change/replace a namespaced style attribute preserves … inline style” subtests).
Expected vs actual
Section titled “Expected vs actual”DocumentMutator::set_attribute (packages/blitz-dom/src/mutator.rs:323-456) decides what an attribute means
by its local name alone: id, class, style, value, disabled, checked, src, href and so on get
their behaviour whatever their namespace. ElementData::attr (packages/blitz-dom/src/node/element.rs:492),
which flush_style_attribute and the rest read the value through, also matches the local name only and returns
whichever comes first. Per DOM and HTML, those attributes have their meaning only in no namespace.
- Expected: the element’s inline style still comes from its
styleattribute in no namespace (color: green). - Actual: it comes from the namespaced
styleattribute, which was set first (after), so it is empty.
the null-namespace style attribute is Some("color: green")expected: 1 inline declaration (color: green), from the style attribute in no namespaceactual: 0 inline declarations, from Some("after")CARGO_TARGET_DIR=~/.capy/work/repro-target cargo runExit status 1 while the bug reproduces, 0 once fixed. On Ubuntu, blitz needs sudo apt-get install -y libfontconfig-dev pkg-config.
Upstream main
Section titled “Upstream main”Reproduces. Blitz main was at 9f9c8e321735890754b4a9970cb07765b8bf3c0c when tested (2026-11-08,
git ls-remote https://github.com/DioxusLabs/blitz HEAD), with the same output and exit status 1.
Existing issue or PR
Section titled “Existing issue or PR”None found. Searched DioxusLabs/blitz issues and PRs (all states) for namespace attribute, namespaced,
setAttributeNS, attribute namespace style. Closest: #1292 (“Follow-ups to :open: namespace check”), which
checks the namespace for open only, and #1168/#1231, about dioxus-native-dom creating attributes in the HTML
namespace.
Issue text
Section titled “Issue text”Title: Namespaced attributes get the behaviour of the same-named attribute in no namespace
Body:
DocumentMutator::set_attribute and ElementData::attr look attributes up by local name only. An element with a
style attribute in no namespace and a style attribute in another namespace (setAttributeNS) takes its
inline style from whichever comes first, and setting the namespaced one re-parses the inline style from it. The
same goes for id, class, value, disabled and the rest of the attributes set_attribute special-cases.
let style = |ns: &str| QualName::new(None, Namespace::from(ns), LocalName::from("style"));let mut m = doc.mutate();m.set_attribute(div, style("https://example.com/attributes"), "before");m.set_attribute(div, style(""), "color: green");m.set_attribute(div, style("https://example.com/attributes"), "after");// the div's style_attribute now has no declarations; expected color: greenTested at be60597f67b3cece0456d26e8d7ff5a88600bbc5 and 9f9c8e321735890754b4a9970cb07765b8bf3c0c. Suggested fix:
match ns!() as well as the local name in attr/attr_parsed and before the special cases in
set_attribute/clear_attribute.