diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-07-13 09:10:50 +0900 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-07-22 18:27:33 +0700 |
commit | b1b03a32dba47ee6ecc7d5faf500882e13c10559 (patch) | |
tree | cf4823858191341d332595547f21714c62bd7b0b /components/script/dom/node.rs | |
parent | 406be7accf50394f962382fc5a4c3aeb1c33aaa3 (diff) | |
download | servo-b1b03a32dba47ee6ecc7d5faf500882e13c10559.tar.gz servo-b1b03a32dba47ee6ecc7d5faf500882e13c10559.zip |
Upgrade rust-selectors, pass ':empty' tests
https://github.com/servo/rust-selectors/pull/36
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index d7432c570b0..3c0eb8e337e 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -2579,7 +2579,9 @@ impl<'a> VirtualMethods for &'a Node { } } -impl<'a> ::selectors::Node<&'a Element> for &'a Node { +impl<'a> ::selectors::Node for &'a Node { + type Element = &'a Element; + fn parent_node(&self) -> Option<&'a Node> { (*self).parent_node.get() .map(|node| node.root().get_unsound_ref_forever()) @@ -2609,9 +2611,17 @@ impl<'a> ::selectors::Node<&'a Element> for &'a Node { DocumentDerived::is_document(*self) } - fn as_element(&self) -> Option<&'a Element> { + fn as_element(&self) -> Option<Self::Element> { ElementCast::to_ref(*self) } + + fn is_element_or_non_empty_text(&self) -> bool { + if self.is_text() { + self.GetTextContent().map_or(false, |s| !s.is_empty()) + } else { + self.is_element() + } + } } pub trait DisabledStateHelpers { |