w3c / w3c/DOM-Parsing

XMLSerializer: Should prefer the default namespace to a prefix declared in an ancestor

Open
#52 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

xml-serialization
Dominant language
HTML
Stars
28
Forks
14
Avg merge
3h 10m
Merged PRs (30d)
1

Description

Suppose that we have the following XML document, parse it, and serialize it.

<root xmlns:x="uri1">
 <table xmlns="uri1"/>
</root>

If we follow the current specification, the serialization result is:

<root xmlns:x="uri1">
 <x:table xmlns="uri1"/>
</root>

It's incompatible with Edge, Firefox, Safari, and Chrome 73-.
(Chrome 74 produces the above result, and we're fixing it.)

I think 12.1 in https://w3c.github.io/DOM-Parsing/#xml-serializing-an-element-node should be changed as following:

Original: Let candidate prefix be the result of retrieving a preferred prefix string prefix from map given namespace ns.

Proposed: Let candidate prefix be null if prefix is null and ns equals to local default namespace. Otherwise let candidate prefix be the result of retrieving a preferred prefix string prefix from map given namespace ns.

WPT domparsing/XMLSerializer-serializeToString.html contains a testcase for this behavior.
"Check if start tag serialization does NOT apply the default namespace if its namespace is declared in an ancestor."

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read section 12.1 of the DOM Parsing XML serialization specification and compare it with the proposed wording in this issue. Review the WPT case in domparsing/XMLSerializer-serializeToString.html, then update the specification behavior so the existing test passes and the cross-browser serialization result is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
xml
Domain
web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.