Introduce a createText function.

This commit is contained in:
Ms2ger 2013-09-09 12:16:38 +02:00 committed by Josh Matthews
parent 849fba27ab
commit b5457f7910

View file

@ -331,10 +331,7 @@ impl Document {
for title_child in child.children() {
child.remove_child(title_child);
}
let new_text = unsafe {
Node::as_abstract_node(cx, @Text::new(title.to_str()))
};
child.add_child(new_text);
child.add_child(self.createText(title.to_str()));
break;
}
if !has_title {
@ -344,10 +341,7 @@ impl Document {
let new_title = unsafe {
Node::as_abstract_node(cx, new_title)
};
let new_text = unsafe {
Node::as_abstract_node(cx, @Text::new(title.to_str()))
};
new_title.add_child(new_text);
new_title.add_child(self.createText(title.to_str()));
node.add_child(new_title);
}
break;
@ -443,6 +437,13 @@ impl Document {
self.createHTMLCollection(|elem|
elem.get_attr("name").is_some() && eq_slice(elem.get_attr("name").unwrap(), name.to_str()))
}
pub fn createText(&self, data: ~str) -> AbstractNode<ScriptView> {
let (_scope, cx) = self.get_scope_and_cx();
unsafe {
Node::as_abstract_node(cx, @Text::new(data))
}
}
pub fn createHTMLCollection(&self, callback: &fn(elem: &Element) -> bool) -> @mut HTMLCollection {
let mut elements = ~[];