mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +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
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue