mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
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:
commit
01ff78b438
1 changed files with 3 additions and 14 deletions
|
@ -1887,24 +1887,13 @@ impl NodeMethods for Node {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||||
fn GetNodeValue(&self) -> Option<DOMString> {
|
fn GetNodeValue(&self) -> Option<DOMString> {
|
||||||
match self.type_id() {
|
self.downcast::<CharacterData>().map(CharacterData::Data)
|
||||||
NodeTypeId::CharacterData(..) => {
|
|
||||||
let chardata = self.downcast::<CharacterData>().unwrap();
|
|
||||||
Some(chardata.Data())
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
// https://dom.spec.whatwg.org/#dom-node-nodevalue
|
||||||
fn SetNodeValue(&self, val: Option<DOMString>) {
|
fn SetNodeValue(&self, val: Option<DOMString>) {
|
||||||
match self.type_id() {
|
if let Some(character_data) = self.downcast::<CharacterData>() {
|
||||||
NodeTypeId::CharacterData(..) => {
|
character_data.SetData(val.unwrap_or(DOMString::new()));
|
||||||
self.SetTextContent(val)
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue