diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2015-04-08 22:30:54 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2015-04-09 15:43:05 +0200 |
commit | 3d68a46fee3a33e76889f76350913128ae816ba9 (patch) | |
tree | fca5fdf298b34491a8457675006d41628fa3195b /components/script/dom/characterdata.rs | |
parent | f8d0237956480dd4c76527f834581c77888a1ef2 (diff) | |
download | servo-3d68a46fee3a33e76889f76350913128ae816ba9.tar.gz servo-3d68a46fee3a33e76889f76350913128ae816ba9.zip |
Implement NonDocumentTypeChildNode::*ElementSibling()
Diffstat (limited to 'components/script/dom/characterdata.rs')
-rw-r--r-- | components/script/dom/characterdata.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/components/script/dom/characterdata.rs b/components/script/dom/characterdata.rs index 1f2b18f1b99..2b730469582 100644 --- a/components/script/dom/characterdata.rs +++ b/components/script/dom/characterdata.rs @@ -6,11 +6,13 @@ use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods; -use dom::bindings::codegen::InheritTypes::{CharacterDataDerived, NodeCast}; +use dom::bindings::codegen::InheritTypes::{CharacterDataDerived, ElementCast}; +use dom::bindings::codegen::InheritTypes::NodeCast; use dom::bindings::error::{Fallible, ErrorResult}; use dom::bindings::error::Error::IndexSize; -use dom::bindings::js::JSRef; +use dom::bindings::js::{JSRef, Temporary}; use dom::document::Document; +use dom::element::Element; use dom::eventtarget::{EventTarget, EventTargetTypeId}; use dom::node::{Node, NodeHelpers, NodeTypeId}; @@ -127,5 +129,17 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> { let node: JSRef<Node> = NodeCast::from_ref(self); node.remove_self(); } + + // https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-previouselementsibling + fn GetPreviousElementSibling(self) -> Option<Temporary<Element>> { + NodeCast::from_ref(self).preceding_siblings() + .filter_map(ElementCast::to_temporary).next() + } + + // https://dom.spec.whatwg.org/#dom-nondocumenttypechildnode-nextelementsibling + fn GetNextElementSibling(self) -> Option<Temporary<Element>> { + NodeCast::from_ref(self).following_siblings() + .filter_map(ElementCast::to_temporary).next() + } } |