mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Throw NotSupported when trying to deep clone a shadow root
This commit is contained in:
parent
d6ddb08e23
commit
6a85409ffe
3 changed files with 18 additions and 13 deletions
|
@ -280,7 +280,9 @@ impl Node {
|
||||||
|
|
||||||
new_child.parent_node.set(Some(self));
|
new_child.parent_node.set(Some(self));
|
||||||
if let Some(shadow_root) = self.downcast::<ShadowRoot>() {
|
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 {
|
} else {
|
||||||
new_child.composed_parent_node.set(Some(self));
|
new_child.composed_parent_node.set(Some(self));
|
||||||
}
|
}
|
||||||
|
@ -2528,8 +2530,11 @@ impl NodeMethods for Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-clonenode
|
// https://dom.spec.whatwg.org/#dom-node-clonenode
|
||||||
fn CloneNode(&self, deep: bool) -> DomRoot<Node> {
|
fn CloneNode(&self, deep: bool) -> Fallible<DomRoot<Node>> {
|
||||||
Node::clone(
|
if deep && self.is::<ShadowRoot>() {
|
||||||
|
return Err(Error::NotSupported);
|
||||||
|
}
|
||||||
|
Ok(Node::clone(
|
||||||
self,
|
self,
|
||||||
None,
|
None,
|
||||||
if deep {
|
if deep {
|
||||||
|
@ -2537,7 +2542,7 @@ impl NodeMethods for Node {
|
||||||
} else {
|
} else {
|
||||||
CloneChildrenFlag::DoNotCloneChildren
|
CloneChildrenFlag::DoNotCloneChildren
|
||||||
},
|
},
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-isequalnode
|
// https://dom.spec.whatwg.org/#dom-node-isequalnode
|
||||||
|
|
|
@ -500,7 +500,7 @@ impl RangeMethods for Range {
|
||||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||||
} else {
|
} else {
|
||||||
// Step 14.1.
|
// Step 14.1.
|
||||||
let clone = child.CloneNode(false);
|
let clone = child.CloneNode(/* deep */ false)?;
|
||||||
// Step 14.2.
|
// Step 14.2.
|
||||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||||
// Step 14.3.
|
// Step 14.3.
|
||||||
|
@ -521,7 +521,7 @@ impl RangeMethods for Range {
|
||||||
// Step 15.
|
// Step 15.
|
||||||
for child in contained_children {
|
for child in contained_children {
|
||||||
// Step 15.1.
|
// Step 15.1.
|
||||||
let clone = child.CloneNode(true);
|
let clone = child.CloneNode(/* deep */ true)?;
|
||||||
// Step 15.2.
|
// Step 15.2.
|
||||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ impl RangeMethods for Range {
|
||||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||||
} else {
|
} else {
|
||||||
// Step 17.1.
|
// Step 17.1.
|
||||||
let clone = child.CloneNode(false);
|
let clone = child.CloneNode(/* deep */ false)?;
|
||||||
// Step 17.2.
|
// Step 17.2.
|
||||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||||
// Step 17.3.
|
// Step 17.3.
|
||||||
|
@ -573,7 +573,7 @@ impl RangeMethods for Range {
|
||||||
if end_node == start_node {
|
if end_node == start_node {
|
||||||
if let Some(end_data) = end_node.downcast::<CharacterData>() {
|
if let Some(end_data) = end_node.downcast::<CharacterData>() {
|
||||||
// Step 4.1.
|
// Step 4.1.
|
||||||
let clone = end_node.CloneNode(true);
|
let clone = end_node.CloneNode(/* deep */ true)?;
|
||||||
// Step 4.2.
|
// Step 4.2.
|
||||||
let text = end_data.SubstringData(start_offset, end_offset - start_offset);
|
let text = end_data.SubstringData(start_offset, end_offset - start_offset);
|
||||||
clone
|
clone
|
||||||
|
@ -614,7 +614,7 @@ impl RangeMethods for Range {
|
||||||
if let Some(start_data) = child.downcast::<CharacterData>() {
|
if let Some(start_data) = child.downcast::<CharacterData>() {
|
||||||
assert!(child == start_node);
|
assert!(child == start_node);
|
||||||
// Step 15.1.
|
// Step 15.1.
|
||||||
let clone = start_node.CloneNode(true);
|
let clone = start_node.CloneNode(/* deep */ true)?;
|
||||||
// Step 15.2.
|
// Step 15.2.
|
||||||
let text = start_data.SubstringData(start_offset, start_node.len() - start_offset);
|
let text = start_data.SubstringData(start_offset, start_node.len() - start_offset);
|
||||||
clone
|
clone
|
||||||
|
@ -631,7 +631,7 @@ impl RangeMethods for Range {
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
// Step 16.1.
|
// Step 16.1.
|
||||||
let clone = child.CloneNode(false);
|
let clone = child.CloneNode(/* deep */ false)?;
|
||||||
// Step 16.2.
|
// Step 16.2.
|
||||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||||
// Step 16.3.
|
// Step 16.3.
|
||||||
|
@ -658,7 +658,7 @@ impl RangeMethods for Range {
|
||||||
if let Some(end_data) = child.downcast::<CharacterData>() {
|
if let Some(end_data) = child.downcast::<CharacterData>() {
|
||||||
assert!(child == end_node);
|
assert!(child == end_node);
|
||||||
// Step 18.1.
|
// Step 18.1.
|
||||||
let clone = end_node.CloneNode(true);
|
let clone = end_node.CloneNode(/* deep */ true)?;
|
||||||
// Step 18.2.
|
// Step 18.2.
|
||||||
let text = end_data.SubstringData(0, end_offset);
|
let text = end_data.SubstringData(0, end_offset);
|
||||||
clone
|
clone
|
||||||
|
@ -671,7 +671,7 @@ impl RangeMethods for Range {
|
||||||
end_data.ReplaceData(0, end_offset, DOMString::new())?;
|
end_data.ReplaceData(0, end_offset, DOMString::new())?;
|
||||||
} else {
|
} else {
|
||||||
// Step 19.1.
|
// Step 19.1.
|
||||||
let clone = child.CloneNode(false);
|
let clone = child.CloneNode(/* deep */ false)?;
|
||||||
// Step 19.2.
|
// Step 19.2.
|
||||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||||
// Step 19.3.
|
// Step 19.3.
|
||||||
|
|
|
@ -58,7 +58,7 @@ interface Node : EventTarget {
|
||||||
[CEReactions]
|
[CEReactions]
|
||||||
void normalize();
|
void normalize();
|
||||||
|
|
||||||
[CEReactions]
|
[CEReactions, Throws]
|
||||||
Node cloneNode(optional boolean deep = false);
|
Node cloneNode(optional boolean deep = false);
|
||||||
[Pure]
|
[Pure]
|
||||||
boolean isEqualNode(Node? node);
|
boolean isEqualNode(Node? node);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue