diff options
author | Harry Maclean <harryjmaclean@googlemail.com> | 2014-08-03 23:37:46 +0100 |
---|---|---|
committer | Harry Maclean <harryjmaclean@googlemail.com> | 2014-08-05 12:59:15 +0100 |
commit | f00bbdb30a3268d6fadb7f0d196f19f6b6bbf3e4 (patch) | |
tree | 19f739a5a0ad35beb82dce76171bccf301e9421b /src/components/script/dom/document.rs | |
parent | 05f62f7cf0d5ed78d99a69f0a5a741012058e18a (diff) | |
download | servo-f00bbdb30a3268d6fadb7f0d196f19f6b6bbf3e4.tar.gz servo-f00bbdb30a3268d6fadb7f0d196f19f6b6bbf3e4.zip |
Check for the empty string before creating a new text node when setting document.title
Diffstat (limited to 'src/components/script/dom/document.rs')
-rw-r--r-- | src/components/script/dom/document.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index 58fef0e527f..d452560ca46 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -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()); }, } |