diff options
author | Corey Farwell <coreyf@rwell.org> | 2015-11-11 08:31:52 -0500 |
---|---|---|
committer | Corey Farwell <coreyf@rwell.org> | 2015-11-11 08:53:53 -0500 |
commit | 261ce49423e04daa77785b462f2facb529db842a (patch) | |
tree | 696db642dea0833c424048bc03e852c8501b3861 /components/script/dom/node.rs | |
parent | aa105d89b4031d98376ac804e31e287f3bf21bb8 (diff) | |
download | servo-261ce49423e04daa77785b462f2facb529db842a.tar.gz servo-261ce49423e04daa77785b462f2facb529db842a.zip |
Simplify script::dom::node NodeValue implementations
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 3a8baa399d2..3db07a9cc7d 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1887,24 +1887,13 @@ impl NodeMethods for Node { // https://dom.spec.whatwg.org/#dom-node-nodevalue fn GetNodeValue(&self) -> Option<DOMString> { - match self.type_id() { - NodeTypeId::CharacterData(..) => { - let chardata = self.downcast::<CharacterData>().unwrap(); - Some(chardata.Data()) - } - _ => { - None - } - } + self.downcast::<CharacterData>().map(CharacterData::Data) } // https://dom.spec.whatwg.org/#dom-node-nodevalue fn SetNodeValue(&self, val: Option<DOMString>) { - match self.type_id() { - NodeTypeId::CharacterData(..) => { - self.SetTextContent(val) - } - _ => {} + if let Some(character_data) = self.downcast::<CharacterData>() { + character_data.SetData(val.unwrap_or(DOMString::new())); } } |