mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Simplify script::dom::node NodeValue implementations
This commit is contained in:
parent
aa105d89b4
commit
261ce49423
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