Throw NotSupported when trying to deep clone a shadow root

This commit is contained in:
Fernando Jiménez Moreno 2019-01-29 15:06:34 +01:00
parent d6ddb08e23
commit 6a85409ffe
3 changed files with 18 additions and 13 deletions

View file

@ -280,7 +280,9 @@ impl Node {
new_child.parent_node.set(Some(self));
if let Some(shadow_root) = self.downcast::<ShadowRoot>() {
new_child.composed_parent_node.set(Some(shadow_root.Host().upcast::<Node>()));
new_child
.composed_parent_node
.set(Some(shadow_root.Host().upcast::<Node>()));
} else {
new_child.composed_parent_node.set(Some(self));
}
@ -2528,8 +2530,11 @@ impl NodeMethods for Node {
}
// https://dom.spec.whatwg.org/#dom-node-clonenode
fn CloneNode(&self, deep: bool) -> DomRoot<Node> {
Node::clone(
fn CloneNode(&self, deep: bool) -> Fallible<DomRoot<Node>> {
if deep && self.is::<ShadowRoot>() {
return Err(Error::NotSupported);
}
Ok(Node::clone(
self,
None,
if deep {
@ -2537,7 +2542,7 @@ impl NodeMethods for Node {
} else {
CloneChildrenFlag::DoNotCloneChildren
},
)
))
}
// https://dom.spec.whatwg.org/#dom-node-isequalnode