Partial ShadowRoot implementation of DocumentOrShadowRoot

This commit is contained in:
Fernando Jiménez Moreno 2019-01-21 20:58:52 +01:00
parent 18ae0fcbd6
commit 4304ee28dc
9 changed files with 161 additions and 54 deletions

View file

@ -1560,7 +1560,9 @@ impl Node {
) -> ErrorResult {
// Step 1.
match parent.type_id() {
NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => (),
NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => {
()
},
_ => return Err(Error::HierarchyRequest),
}
@ -2248,7 +2250,9 @@ impl NodeMethods for Node {
fn ReplaceChild(&self, node: &Node, child: &Node) -> Fallible<DomRoot<Node>> {
// Step 1.
match self.type_id() {
NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => (),
NodeTypeId::Document(_) | NodeTypeId::DocumentFragment(_) | NodeTypeId::Element(..) => {
()
},
_ => return Err(Error::HierarchyRequest),
}
@ -2351,8 +2355,10 @@ impl NodeMethods for Node {
// Step 12.
rooted_vec!(let mut nodes);
let nodes = if node.type_id() == NodeTypeId::DocumentFragment(DocumentFragmentTypeId::DocumentFragment) ||
node.type_id() == NodeTypeId::DocumentFragment(DocumentFragmentTypeId::ShadowRoot) {
let nodes = if node.type_id() ==
NodeTypeId::DocumentFragment(DocumentFragmentTypeId::DocumentFragment) ||
node.type_id() == NodeTypeId::DocumentFragment(DocumentFragmentTypeId::ShadowRoot)
{
nodes.extend(node.children().map(|node| Dom::from_ref(&*node)));
nodes.r()
} else {