mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Check for the empty string before creating a new text node when setting document.title
This commit is contained in:
parent
05f62f7cf0
commit
f00bbdb30a
1 changed files with 8 additions and 6 deletions
|
@ -542,17 +542,19 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
for title_child in title_node.children() {
|
for title_child in title_node.children() {
|
||||||
assert!(title_node.RemoveChild(&title_child).is_ok());
|
assert!(title_node.RemoveChild(&title_child).is_ok());
|
||||||
}
|
}
|
||||||
let new_text = self.CreateTextNode(title.clone()).root();
|
if !title.is_empty() {
|
||||||
|
let new_text = self.CreateTextNode(title.clone()).root();
|
||||||
assert!(title_node.AppendChild(NodeCast::from_ref(&*new_text)).is_ok());
|
assert!(title_node.AppendChild(NodeCast::from_ref(&*new_text)).is_ok());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
let new_title = HTMLTitleElement::new("title".to_string(), self).root();
|
let new_title = HTMLTitleElement::new("title".to_string(), self).root();
|
||||||
let new_title: &JSRef<Node> = NodeCast::from_ref(&*new_title);
|
let new_title: &JSRef<Node> = NodeCast::from_ref(&*new_title);
|
||||||
|
|
||||||
let new_text = self.CreateTextNode(title.clone()).root();
|
if !title.is_empty() {
|
||||||
|
let new_text = self.CreateTextNode(title.clone()).root();
|
||||||
assert!(new_title.AppendChild(NodeCast::from_ref(&*new_text)).is_ok());
|
assert!(new_title.AppendChild(NodeCast::from_ref(&*new_text)).is_ok());
|
||||||
|
}
|
||||||
assert!(head.AppendChild(new_title).is_ok());
|
assert!(head.AppendChild(new_title).is_ok());
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue