Skip to content

Commit

Permalink
Check for the empty string before creating a new text node when setti…
Browse files Browse the repository at this point in the history
…ng document.title
  • Loading branch information
hmac committed Aug 5, 2014
1 parent 05f62f7 commit f00bbdb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/script/dom/document.rs
Expand Up @@ -542,17 +542,19 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
for title_child in title_node.children() {
assert!(title_node.RemoveChild(&title_child).is_ok());
}
let new_text = self.CreateTextNode(title.clone()).root();

assert!(title_node.AppendChild(NodeCast::from_ref(&*new_text)).is_ok());
if !title.is_empty() {
let new_text = self.CreateTextNode(title.clone()).root();
assert!(title_node.AppendChild(NodeCast::from_ref(&*new_text)).is_ok());
}
},
None => {
let new_title = HTMLTitleElement::new("title".to_string(), self).root();
let new_title: &JSRef<Node> = NodeCast::from_ref(&*new_title);

let new_text = self.CreateTextNode(title.clone()).root();

assert!(new_title.AppendChild(NodeCast::from_ref(&*new_text)).is_ok());
if !title.is_empty() {
let new_text = self.CreateTextNode(title.clone()).root();
assert!(new_title.AppendChild(NodeCast::from_ref(&*new_text)).is_ok());
}
assert!(head.AppendChild(new_title).is_ok());
},
}
Expand Down

0 comments on commit f00bbdb

Please sign in to comment.