Auto merge of #8466 - frewsxcv:node-value, r=nox

Simplify script::dom::node NodeValue implementations

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8466)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-11 21:43:21 +05:30
commit 01ff78b438

View file

@ -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()));
}
}