Index: sky/framework/sky-element.sky |
diff --git a/sky/framework/sky-element.sky b/sky/framework/sky-element.sky |
index 8b04f79a5048e9db4bf0f0b5abfcd32df0616953..2e80eb2be1c90b2ab59936ecc1076e185e193008 100644 |
--- a/sky/framework/sky-element.sky |
+++ b/sky/framework/sky-element.sky |
@@ -47,8 +47,7 @@ abstract class SkyElement extends Element { |
var registration = _registery[tagName]; |
if (registration.template != null) { |
ShadowRoot shadow = ensureShadowRoot(); |
- var tree = registration.template.content.cloneNode(deep:true); |
- shadow.appendChild(tree); |
+ shadow.appendChild(_cloneDeep(registration.template.content)); |
abarth-chromium
2015/02/21 09:15:49
Custom elements don't quite work properly with the
abarth-chromium
2015/02/21 09:15:49
Custom elements don't quite work properly with the
esprehn
2015/02/21 09:57:13
We should use importNode, which clones you into th
|
shadowRootReady(); |
} |
} |
@@ -62,6 +61,25 @@ abstract class SkyElement extends Element { |
attributeChangedCallback(name, oldValue, newValue) { |
attributeChanged(name, oldValue, newValue); |
} |
+ |
+ Node _clone(Node node) { |
+ if (node is Element) { |
+ Element result = document.createElement(node.tagName); |
+ result.setAttributes(node.getAttributes()); |
+ return result; |
+ } |
+ return node.cloneNode(deep: false); |
+ } |
+ |
+ Node _cloneDeep(Node node) { |
+ Node result = _clone(node); |
+ if (node is ParentNode) { |
+ ParentNode parent = node as ParentNode; |
+ for (Node child = parent.firstChild; child != null; child = child.nextSibling) |
+ result.appendChild(_cloneDeep(child)); |
+ } |
+ return result; |
+ } |
esprehn
2015/02/21 09:57:13
This is duplicating what importNode already does.
|
} |
void register(Element script, Type type) { |