mirror of
https://github.com/servo/servo.git
synced 2025-06-20 23:28:59 +01:00
Implement Default trait for DOMString
This commit is contained in:
parent
49d48a8680
commit
00fa3b2f85
3 changed files with 11 additions and 5 deletions
|
@ -31,8 +31,8 @@ impl DocumentType {
|
||||||
DocumentType {
|
DocumentType {
|
||||||
node: Node::new_inherited(document),
|
node: Node::new_inherited(document),
|
||||||
name: name,
|
name: name,
|
||||||
public_id: public_id.unwrap_or(DOMString::new()),
|
public_id: public_id.unwrap_or_default(),
|
||||||
system_id: system_id.unwrap_or(DOMString::new())
|
system_id: system_id.unwrap_or_default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
|
|
|
@ -825,7 +825,7 @@ impl Node {
|
||||||
.map(|elem| elem.upcast::<Node>() == self)
|
.map(|elem| elem.upcast::<Node>() == self)
|
||||||
.unwrap_or(false),
|
.unwrap_or(false),
|
||||||
|
|
||||||
shortValue: self.GetNodeValue().unwrap_or(DOMString::new()), //FIXME: truncate
|
shortValue: self.GetNodeValue().unwrap_or_default(), //FIXME: truncate
|
||||||
incompleteValue: false, //FIXME: reflect truncation
|
incompleteValue: false, //FIXME: reflect truncation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1893,7 +1893,7 @@ impl NodeMethods for Node {
|
||||||
// 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>) {
|
||||||
if let Some(character_data) = self.downcast::<CharacterData>() {
|
if let Some(character_data) = self.downcast::<CharacterData>() {
|
||||||
character_data.SetData(val.unwrap_or(DOMString::new()));
|
character_data.SetData(val.unwrap_or_default());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1918,7 +1918,7 @@ impl NodeMethods for Node {
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
// https://dom.spec.whatwg.org/#dom-node-textcontent
|
||||||
fn SetTextContent(&self, value: Option<DOMString>) {
|
fn SetTextContent(&self, value: Option<DOMString>) {
|
||||||
let value = value.unwrap_or(DOMString::new());
|
let value = value.unwrap_or_default();
|
||||||
match self.type_id() {
|
match self.type_id() {
|
||||||
NodeTypeId::DocumentFragment |
|
NodeTypeId::DocumentFragment |
|
||||||
NodeTypeId::Element(..) => {
|
NodeTypeId::Element(..) => {
|
||||||
|
|
|
@ -24,6 +24,12 @@ impl DOMString {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for DOMString {
|
||||||
|
fn default() -> Self {
|
||||||
|
DOMString(String::new())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Deref for DOMString {
|
impl Deref for DOMString {
|
||||||
type Target = str;
|
type Target = str;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue