fix(dom): allow to correctly clone document fragments

This commit is contained in:
Tobias Bosch 2015-05-28 14:58:52 -07:00
parent 307011a96c
commit 2351896cc0
1 changed files with 13 additions and 6 deletions

View File

@ -302,12 +302,19 @@ export class Parse5DomAdapter extends DomAdapter {
throw _notImplemented('getDistributedNodes');
}
clone(node) {
// e.g. document fragment
if (node.type === 'root') {
var serialized = serializer.serialize(node);
var newParser = new parse5.Parser(parse5.TreeAdapters.htmlparser2);
return newParser.parseFragment(serialized);
} else {
var temp = treeAdapter.createElement("template", null, []);
treeAdapter.appendChild(temp, node);
var serialized = serializer.serialize(temp);
var newParser = new parse5.Parser(parse5.TreeAdapters.htmlparser2);
return newParser.parseFragment(serialized).childNodes[0];
}
}
hasProperty(element, name:string) {
return _HTMLElementPropertyList.indexOf(name) > -1;
}