[w3c/DOM-Parsing] XMLSerializer: Should prefer the default namespace to a prefix declared in an ancestor (#52)

Suppose that we have the following XML document, parse it, and serialize it.
```xml
<root xmlns:x="uri1">
 <table xmlns="uri1"/>
</root>
```

If we follow the current specification, the serialization result is:
```xml
<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."

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/DOM-Parsing/issues/52

Received on Thursday, 9 May 2019 04:47:16 UTC