-
Notifications
You must be signed in to change notification settings - Fork 14
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
Error thrown when resetting the default namespace to null on a prefixed element #48
Comments
@bwrrp additional WPT coverage would be terrific. Patching this standard too, but as you can tell from your previous PR there's no active maintenance at the moment so it might linger around for a while until it gets applied. (I'll look into that a bit.) |
This adds a DOM parsing test for the case where the default namespace is reset on a prefixed element. If implemented according to the spec, serialization with the `require-well-formed` flag set should throw. The error message seems to suggest that this check was intended only for prefix declarations, and indeed something like xmlns:pre="" would have been invalid. However, setting the default namespace back to null should be allowed, and from initial testing at least Firefox and Chrome seem to agree and do not throw.
I've added the example as a WPT test case in web-platform-tests/wpt#16025. |
…medness At this point, the declaration may either be a prefix declaration or a default namespace declaration. While prefix declarations for the null namespace are not valid, it is allowed to reset the default namespace this way. Fixes w3c#48
Now that you wrote that test, I'm reminded of #47, so perhaps the test isn't needed after all as we added a very similar one already. |
Ah yes, I saw that one. Looking at the tests in the linked PR it looks like they do not cover the case where the element having the |
Bug: w3c/DOM-Parsing#29 Bug: w3c/DOM-Parsing#38 Bug: w3c/DOM-Parsing#47 Bug: w3c/DOM-Parsing#48 Bug: w3c/DOM-Parsing#50 Bug: w3c/DOM-Parsing#52 Bug: w3c/DOM-Parsing#59 Bug: w3c/DOM-Parsing#71 Change-Id: I76735c4be1d9738c690417207301f737e3a3c9ff
Consider the following code, run on an empty XML document:
Which produces the following DOM (whitespace added for clarity):
If we now run the serialization algorithms as specified, with the
require-well-formed
flag set (as would be the case inroot.outerHTML
, for instance), an exception is thrown at step 3.5.2.3. of "serializing an element's attributes":The error message seems to suggest that this check is intended only for prefix declarations, and indeed something like
xmlns:pre=""
would have been invalid. However, setting the default namespace back to null should be allowed. In the example given, an explicit declaration on child would be preferable to having an automatically generatedxmlns=""
ongrandchild
, especially in cases where there would be manygrandchild
nodes.It seems that the condition for this error should have included a check whether
attr
'sprefix
attribute is not null. Note that both default namespace declaration attributes and prefix declaration attributes are specified to be in the XMLNS namespace, even though the former does not have a prefix (this is the only case of an unprefixed attribute having a non-null namespace).Note that this case is only hit for an
xmlns=""
declaration on an element that is itself prefixed, in a namespace other than the inherited default. If the element itself is unprefixed it would itself be in the null namespace. This would cause its own serialization generating the declaration and theignore namespace definition attribute
flag being set for the call to serialize its attributes, which in turn would cause the algorithm to skip the attribute earlier at step 3.5.2.1. (second bullet point).Testing the above example in Firefox and Chrome shows that
root.outerHTML
returns the expected serialization (minus the whitespace) and does not throw the error.Please let me know if it would be appreciated if I submit a PR (here and/or on the WPT repo?). It looks like the last one was flagged as I'm not a W3C member.
The text was updated successfully, but these errors were encountered: