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

XMLSerializer: Keep redundant but harmless default namespace declarations #15779

Merged
merged 1 commit into from
Mar 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions domparsing/XMLSerializer-serializeToString.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ <h1>domparsing_XMLSerializer_serializeToString</h1>
assert_equals(serialize(root), '<root xmlns="urn:bar"><outer xmlns=""><inner>value1</inner></outer></root>');
}, 'Check if there is no redundant empty namespace declaration.');

test(function() {
assert_equals(serialize(parse('<root><child xmlns=""/></root>')),
'<root><child/></root>');
assert_equals(serialize(parse('<root xmlns=""><child xmlns=""/></root>')),
'<root><child/></root>');
assert_equals(serialize(parse('<root xmlns="u1"><child xmlns="u1"/></root>')),
'<root xmlns="u1"><child/></root>');
}, 'Check if redundant xmlns="..." is dropped.');

test(function() {
const root = parse('<root xmlns="uri1"/>');
const child = root.ownerDocument.createElement('child');
Expand Down Expand Up @@ -145,8 +154,6 @@ <h1>domparsing_XMLSerializer_serializeToString</h1>

test(function() {
assert_equals(serialize(parse('<root><child/></root>')), '<root><child/></root>');
assert_equals(serialize(parse('<root><child xmlns=""/></root>')), '<root><child/></root>');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we lost this particular input @tkent-google. A root without xmlns declaration and a child with one. Could you restore that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

assert_equals(serialize(parse('<root xmlns="u1"><child xmlns="u1"/></root>')), '<root xmlns="u1"><child/></root>');
assert_equals(serialize(parse('<root xmlns="u1"><p:child xmlns:p="u1"/></root>')), '<root xmlns="u1"><child xmlns:p="u1"/></root>');
}, 'Check if start tag serialization drops element prefix if the namespace is same as inherited default namespace.');

Expand Down