Skip to content

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

Open

Description

@tkent-google

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."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions