Node::GetParentElement should use and_then instead of filtered/map.

This commit is contained in:
Tetsuharu OHZEKI 2014-05-02 13:13:06 +09:00
parent b36b779d24
commit 31cf10c006

View file

@ -902,9 +902,7 @@ impl Node {
// http://dom.spec.whatwg.org/#dom-node-parentelement // http://dom.spec.whatwg.org/#dom-node-parentelement
pub fn GetParentElement(&self) -> Option<JS<Element>> { pub fn GetParentElement(&self) -> Option<JS<Element>> {
self.parent_node.clone() self.parent_node.clone().and_then(|parent| ElementCast::to(&parent))
.filtered(|parent| parent.is_element())
.map(|node| ElementCast::to(&node).unwrap())
} }
// http://dom.spec.whatwg.org/#dom-node-haschildnodes // http://dom.spec.whatwg.org/#dom-node-haschildnodes