Skip to content

Only generate an attribute prefix if required - #30

Open
bwrrp wants to merge 1 commit into
w3c:gh-pagesfrom
bwrrp:preserve-attribute-prefixes
Open

Only generate an attribute prefix if required#30
bwrrp wants to merge 1 commit into
w3c:gh-pagesfrom
bwrrp:preserve-attribute-prefixes

Conversation

@bwrrp

@bwrrp bwrrp commented Jul 13, 2017

Copy link
Copy Markdown

If implemented as specified, the prefix set for an attribute in the DOM would never be preserved during serialization. This change only generates the new prefix if the prefix is either missing (which is not allowed for namespaced attributes), or if it conflicts with another local namespace definition of the prefix for a different namespace.

Fixes #29

If implemented as specified, the prefix set for an attribute in the DOM
would never be preserved during serialization. This change only
generates the new prefix if the prefix is either missing (which is not
allowed for namespaced attributes), or if it conflicts with another
local namespace definition of the prefix for a different namespace.

Fixes w3c#29
@bwrrp
bwrrp force-pushed the preserve-attribute-prefixes branch from eae9f35 to 97e7bb3 Compare October 31, 2018 11:13
@cscott

cscott commented Jul 2, 2021

Copy link
Copy Markdown

I verified that this spec change matches what Firefox currently does (see comment on issue #29). A corresponding patch would need to be made to web-platform-tests (also described at issue #29).

@Ms2ger

Ms2ger commented Aug 5, 2026

Copy link
Copy Markdown

This seems to still be buggy, as only new prefix is set, and candidate prefix remains null, so the step below will not serialize any prefix:

  let root = parse('<r></r>');
  root.setAttributeNS('uri', 'p:name', 'value');
  serialize(root) // '<r xmlns:ns1="uri" name="value"/>'

(I'm integrating a fix elsewhere, no need to update this PR.)

Ms2ger added a commit to Ms2ger/DOM-Parsing that referenced this pull request Aug 16, 2026
Fixes w3c#29.
Fixes w3c#30.

Co-authored-by: Stef Busking <stef.busking@gmail.com>
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.

Serialization algorithm never preserves attribute prefixes

3 participants