Commit 71b093d2 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Fix a bug that document.importNode() doesn't clone Attr nodes with namespace.

We should just call Attr::Clone().

Bug: 812089, 812105
Change-Id: I163769e134a52d82b88834ae29083a01a3480e95
Reviewed-on: https://chromium-review.googlesource.com/925865Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537730}
parent 69674f1d
......@@ -54,4 +54,14 @@ test(function() {
assert_equals(newDiv.ownerDocument, document);
assert_equals(newDiv.firstChild, null);
}, "False 'deep' argument.")
test(function() {
let doc = document.implementation.createHTMLDocument("Title");
doc.body.setAttributeNS("http://example.com/", "p:name", "value");
let originalAttr = doc.body.getAttributeNodeNS("http://example.com/", "name");
let imported = document.importNode(originalAttr, true);
assert_equals(imported.prefix, originalAttr.prefix);
assert_equals(imported.namespaceURI, originalAttr.namespaceURI);
assert_equals(imported.localName, originalAttr.localName);
}, "Import an Attr node with namespace/prefix correctly.");
</script>
......@@ -1261,15 +1261,6 @@ Node* Document::importNode(Node* imported_node,
// 2. Return a clone of node, with context object and the clone children flag
// set if deep is true.
if (imported_node->IsAttributeNode()) {
// The following code doesn't create an Attr with namespace. See
// crbug.com/812105.
return Attr::Create(
*this,
QualifiedName(g_null_atom, AtomicString(ToAttr(imported_node)->name()),
g_null_atom),
ToAttr(imported_node)->value());
}
return imported_node->Clone(
*this, deep ? CloneChildrenFlag::kClone : CloneChildrenFlag::kSkip);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment