-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Duplicate xmlns attributes should be combined? #14
Comments
I had a read through the spec, and |
This is causing issues for me as well. w3c-xmlserializer has different output depending on whether it's being used with jsdom or a web browser.
The result is that if used with jsdom, localDefaultNamespace in serializeElement has a value, but if used within Chrome/Firefox context, localDefaultNamespace is null. Therefore, when paired with jsdom, only qualifiedName is appended to the markup string, whereas in Chrome/Firefox context, the full xmlns attribute is appended, which is then re-appended a second time in attributeUtils.serializeAttributes. Yes, technically w3c-xmlserializer implements the spec, but not in the same way that Chrome/Firefox implement it. It seems ignoreNamespaceDefAttr should be used towards end of serializeAttributes to ensure the xmlns attribute isn't set a second time. I'll submit a pull request for consideration. |
This also seems to cause issues with svgdom since I also dont set a namespaceURI for the xmlns attribute (because the attribute is created using setAttribute and not setAttributeNS). |
I'm not sure whether this is a bug in
w3c-xmlserializer
or whether the current behaviour matches the spec and browsers implement the spec differently.When an
xmlns
attribute is set manually on an element, even if it's set to the same value as the node's namespace URI,w3c-xmlserializer
repeats thexmlns
attribute.Browsers:
w3c-xmlserializer:
I note that setting
requireWellFormed
totrue
(i.e. callingproduceXMLSerialization(element, true)
) throws an "InvalidStateError: Failed to serialize XML: Invalid attribute localName value" error, because it explicitly forbids attributes namedxmlns
that aren't in thehttp://www.w3.org/2000/xmlns/
namespace, so this may be valid, but maybe it should match the behaviour of the browsers' native XMLSerializer?The text was updated successfully, but these errors were encountered: