Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's possible that 'retrieve a preferred prefix string' returns a wrong prefix for the specified namespace #45

Open
tkent-google opened this issue Feb 15, 2019 · 0 comments

Comments

@tkent-google
Copy link

https://w3c.github.io/DOM-Parsing/#dfn-retrieving-a-preferred-prefix-string
WPT domparsing/XMLSerializer-serializeToString.html has a test case for this behavior."Check if an attribute with namespace and no prefix is serialized with the nearest-declared prefix even if the prefix is assigned to another namespace."

const root = (new DOMParser()).parseFromString('<el1 xmlns:p="u1" xmlns:q="u1"><el2 xmlns:q="u2"/></el1>', 'text/xml').documentElement;
root.firstChild.setAttributeNS('u1', 'name', 'v');
console.log((new XMLSerializer()).serializeToString(root));

If we follow the current specification, 'retrieve a preferred prefix string' for name attribute choses q prefix because q is in the list for u1 namespace. However, namespace for q is u2 on the element. The serialization result would be <el1 ...><el2 xmlns:q="u2" q:name="v"/></el1>

Before we add prefix and namespace to a map, we need to remove the prefix associated to another namespace from the map.

wmfgerrit pushed a commit to wikimedia/mediawiki-libs-Dodo that referenced this issue Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants