mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +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));
|
||||
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
|
||||
|
|
|
@ -500,7 +500,7 @@ impl RangeMethods for Range {
|
|||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||
} else {
|
||||
// Step 14.1.
|
||||
let clone = child.CloneNode(false);
|
||||
let clone = child.CloneNode(/* deep */ false)?;
|
||||
// Step 14.2.
|
||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||
// Step 14.3.
|
||||
|
@ -521,7 +521,7 @@ impl RangeMethods for Range {
|
|||
// Step 15.
|
||||
for child in contained_children {
|
||||
// Step 15.1.
|
||||
let clone = child.CloneNode(true);
|
||||
let clone = child.CloneNode(/* deep */ true)?;
|
||||
// Step 15.2.
|
||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ impl RangeMethods for Range {
|
|||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||
} else {
|
||||
// Step 17.1.
|
||||
let clone = child.CloneNode(false);
|
||||
let clone = child.CloneNode(/* deep */ false)?;
|
||||
// Step 17.2.
|
||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||
// Step 17.3.
|
||||
|
@ -573,7 +573,7 @@ impl RangeMethods for Range {
|
|||
if end_node == start_node {
|
||||
if let Some(end_data) = end_node.downcast::<CharacterData>() {
|
||||
// Step 4.1.
|
||||
let clone = end_node.CloneNode(true);
|
||||
let clone = end_node.CloneNode(/* deep */ true)?;
|
||||
// Step 4.2.
|
||||
let text = end_data.SubstringData(start_offset, end_offset - start_offset);
|
||||
clone
|
||||
|
@ -614,7 +614,7 @@ impl RangeMethods for Range {
|
|||
if let Some(start_data) = child.downcast::<CharacterData>() {
|
||||
assert!(child == start_node);
|
||||
// Step 15.1.
|
||||
let clone = start_node.CloneNode(true);
|
||||
let clone = start_node.CloneNode(/* deep */ true)?;
|
||||
// Step 15.2.
|
||||
let text = start_data.SubstringData(start_offset, start_node.len() - start_offset);
|
||||
clone
|
||||
|
@ -631,7 +631,7 @@ impl RangeMethods for Range {
|
|||
)?;
|
||||
} else {
|
||||
// Step 16.1.
|
||||
let clone = child.CloneNode(false);
|
||||
let clone = child.CloneNode(/* deep */ false)?;
|
||||
// Step 16.2.
|
||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||
// Step 16.3.
|
||||
|
@ -658,7 +658,7 @@ impl RangeMethods for Range {
|
|||
if let Some(end_data) = child.downcast::<CharacterData>() {
|
||||
assert!(child == end_node);
|
||||
// Step 18.1.
|
||||
let clone = end_node.CloneNode(true);
|
||||
let clone = end_node.CloneNode(/* deep */ true)?;
|
||||
// Step 18.2.
|
||||
let text = end_data.SubstringData(0, end_offset);
|
||||
clone
|
||||
|
@ -671,7 +671,7 @@ impl RangeMethods for Range {
|
|||
end_data.ReplaceData(0, end_offset, DOMString::new())?;
|
||||
} else {
|
||||
// Step 19.1.
|
||||
let clone = child.CloneNode(false);
|
||||
let clone = child.CloneNode(/* deep */ false)?;
|
||||
// Step 19.2.
|
||||
fragment.upcast::<Node>().AppendChild(&clone)?;
|
||||
// Step 19.3.
|
||||
|
|
|
@ -58,7 +58,7 @@ interface Node : EventTarget {
|
|||
[CEReactions]
|
||||
void normalize();
|
||||
|
||||
[CEReactions]
|
||||
[CEReactions, Throws]
|
||||
Node cloneNode(optional boolean deep = false);
|
||||
[Pure]
|
||||
boolean isEqualNode(Node? node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue