mirror of
https://github.com/servo/servo.git
synced 2025-06-20 15:18:58 +01:00
Introduce a createText function.
This commit is contained in:
parent
849fba27ab
commit
b5457f7910
1 changed files with 9 additions and 8 deletions
|
@ -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 = ~[];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue