From 261ce49423e04daa77785b462f2facb529db842a Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 11 Nov 2015 08:31:52 -0500 Subject: [PATCH] Simplify script::dom::node NodeValue implementations --- components/script/dom/node.rs | 17 +++-------------- 1 file 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 { - match self.type_id() { - NodeTypeId::CharacterData(..) => { - let chardata = self.downcast::().unwrap(); - Some(chardata.Data()) - } - _ => { - None - } - } + self.downcast::().map(CharacterData::Data) } // https://dom.spec.whatwg.org/#dom-node-nodevalue fn SetNodeValue(&self, val: Option) { - match self.type_id() { - NodeTypeId::CharacterData(..) => { - self.SetTextContent(val) - } - _ => {} + if let Some(character_data) = self.downcast::() { + character_data.SetData(val.unwrap_or(DOMString::new())); } }