This commit is contained in:
Simon Sapin 2019-02-26 08:18:33 +01:00
parent 7bb7c9a1e3
commit 4464354e2e
10 changed files with 42 additions and 21 deletions

View file

@ -2533,13 +2533,14 @@ impl ElementMethods for Element {
let position = position.parse::<AdjacentPosition>()?;
let context = match position {
AdjacentPosition::BeforeBegin | AdjacentPosition::AfterEnd => match self
.upcast::<Node>()
.GetParentNode()
{
Some(ref node) if node.is::<Document>() => return Err(Error::NoModificationAllowed),
None => return Err(Error::NoModificationAllowed),
Some(node) => node,
AdjacentPosition::BeforeBegin | AdjacentPosition::AfterEnd => {
match self.upcast::<Node>().GetParentNode() {
Some(ref node) if node.is::<Document>() => {
return Err(Error::NoModificationAllowed)
},
None => return Err(Error::NoModificationAllowed),
Some(node) => node,
}
},
AdjacentPosition::AfterBegin | AdjacentPosition::BeforeEnd => {
DomRoot::from_ref(self.upcast::<Node>())