mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
commit
529c21bb65
4 changed files with 41 additions and 7 deletions
|
@ -274,7 +274,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
has_title = true;
|
has_title = true;
|
||||||
for title_child in child.children() {
|
for title_child in child.children() {
|
||||||
child.remove_child(title_child);
|
child.RemoveChild(title_child);
|
||||||
}
|
}
|
||||||
child.AppendChild(self.CreateTextNode(abstract_self, title.clone()));
|
child.AppendChild(self.CreateTextNode(abstract_self, title.clone()));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -212,6 +212,8 @@ impl<'self> Element {
|
||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.node.wait_until_safe_to_modify_dom();
|
||||||
|
|
||||||
// FIXME: reduce the time of `value.clone()`.
|
// FIXME: reduce the time of `value.clone()`.
|
||||||
let win = self.node.owner_doc().document().window;
|
let win = self.node.owner_doc().document().window;
|
||||||
let new_attr = Attr::new_ns(win, local_name.clone(), value.clone(),
|
let new_attr = Attr::new_ns(win, local_name.clone(), value.clone(),
|
||||||
|
|
|
@ -220,18 +220,28 @@ impl<View> TreeNodeRef<Node<View>> for AbstractNode<View> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_parent_node(node: &mut Node<View>, new_parent_node: Option<AbstractNode<View>>) {
|
fn set_parent_node(node: &mut Node<View>, new_parent_node: Option<AbstractNode<View>>) {
|
||||||
|
let doc = node.owner_doc();
|
||||||
|
doc.document().wait_until_safe_to_modify_dom();
|
||||||
node.parent_node = new_parent_node
|
node.parent_node = new_parent_node
|
||||||
}
|
}
|
||||||
fn set_first_child(node: &mut Node<View>, new_first_child: Option<AbstractNode<View>>) {
|
fn set_first_child(node: &mut Node<View>, new_first_child: Option<AbstractNode<View>>) {
|
||||||
|
let doc = node.owner_doc();
|
||||||
|
doc.document().wait_until_safe_to_modify_dom();
|
||||||
node.first_child = new_first_child
|
node.first_child = new_first_child
|
||||||
}
|
}
|
||||||
fn set_last_child(node: &mut Node<View>, new_last_child: Option<AbstractNode<View>>) {
|
fn set_last_child(node: &mut Node<View>, new_last_child: Option<AbstractNode<View>>) {
|
||||||
|
let doc = node.owner_doc();
|
||||||
|
doc.document().wait_until_safe_to_modify_dom();
|
||||||
node.last_child = new_last_child
|
node.last_child = new_last_child
|
||||||
}
|
}
|
||||||
fn set_prev_sibling(node: &mut Node<View>, new_prev_sibling: Option<AbstractNode<View>>) {
|
fn set_prev_sibling(node: &mut Node<View>, new_prev_sibling: Option<AbstractNode<View>>) {
|
||||||
|
let doc = node.owner_doc();
|
||||||
|
doc.document().wait_until_safe_to_modify_dom();
|
||||||
node.prev_sibling = new_prev_sibling
|
node.prev_sibling = new_prev_sibling
|
||||||
}
|
}
|
||||||
fn set_next_sibling(node: &mut Node<View>, new_next_sibling: Option<AbstractNode<View>>) {
|
fn set_next_sibling(node: &mut Node<View>, new_next_sibling: Option<AbstractNode<View>>) {
|
||||||
|
let doc = node.owner_doc();
|
||||||
|
doc.document().wait_until_safe_to_modify_dom();
|
||||||
node.next_sibling = new_next_sibling
|
node.next_sibling = new_next_sibling
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,6 +557,10 @@ impl AbstractNode<ScriptView> {
|
||||||
self.node().AppendChild(self, node)
|
self.node().AppendChild(self, node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn RemoveChild(self, node: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> {
|
||||||
|
self.node().RemoveChild(self, node)
|
||||||
|
}
|
||||||
|
|
||||||
// http://dom.spec.whatwg.org/#node-is-inserted
|
// http://dom.spec.whatwg.org/#node-is-inserted
|
||||||
fn node_inserted(self) {
|
fn node_inserted(self) {
|
||||||
assert!(self.parent_node().is_some());
|
assert!(self.parent_node().is_some());
|
||||||
|
@ -1076,8 +1090,6 @@ impl Node<ScriptView> {
|
||||||
pub fn SetTextContent(&mut self,
|
pub fn SetTextContent(&mut self,
|
||||||
abstract_self: AbstractNode<ScriptView>,
|
abstract_self: AbstractNode<ScriptView>,
|
||||||
value: Option<DOMString>) -> ErrorResult {
|
value: Option<DOMString>) -> ErrorResult {
|
||||||
self.wait_until_safe_to_modify_dom();
|
|
||||||
|
|
||||||
let value = null_str_as_empty(&value);
|
let value = null_str_as_empty(&value);
|
||||||
match self.type_id {
|
match self.type_id {
|
||||||
DocumentFragmentNodeTypeId | ElementNodeTypeId(*) => {
|
DocumentFragmentNodeTypeId | ElementNodeTypeId(*) => {
|
||||||
|
@ -1092,6 +1104,8 @@ impl Node<ScriptView> {
|
||||||
Node::replace_all(node, abstract_self);
|
Node::replace_all(node, abstract_self);
|
||||||
}
|
}
|
||||||
CommentNodeTypeId | TextNodeTypeId => {
|
CommentNodeTypeId | TextNodeTypeId => {
|
||||||
|
self.wait_until_safe_to_modify_dom();
|
||||||
|
|
||||||
do abstract_self.with_mut_characterdata() |characterdata| {
|
do abstract_self.with_mut_characterdata() |characterdata| {
|
||||||
characterdata.data = value.clone();
|
characterdata.data = value.clone();
|
||||||
|
|
||||||
|
@ -1108,11 +1122,10 @@ impl Node<ScriptView> {
|
||||||
pub fn InsertBefore(&self,
|
pub fn InsertBefore(&self,
|
||||||
node: AbstractNode<ScriptView>,
|
node: AbstractNode<ScriptView>,
|
||||||
child: Option<AbstractNode<ScriptView>>) -> Fallible<AbstractNode<ScriptView>> {
|
child: Option<AbstractNode<ScriptView>>) -> Fallible<AbstractNode<ScriptView>> {
|
||||||
self.wait_until_safe_to_modify_dom();
|
|
||||||
Node::pre_insert(node, node, child)
|
Node::pre_insert(node, node, child)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_until_safe_to_modify_dom(&self) {
|
pub fn wait_until_safe_to_modify_dom(&self) {
|
||||||
let document = self.owner_doc();
|
let document = self.owner_doc();
|
||||||
document.document().wait_until_safe_to_modify_dom();
|
document.document().wait_until_safe_to_modify_dom();
|
||||||
}
|
}
|
||||||
|
@ -1120,7 +1133,6 @@ impl Node<ScriptView> {
|
||||||
pub fn AppendChild(&self,
|
pub fn AppendChild(&self,
|
||||||
abstract_self: AbstractNode<ScriptView>,
|
abstract_self: AbstractNode<ScriptView>,
|
||||||
node: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> {
|
node: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> {
|
||||||
self.wait_until_safe_to_modify_dom();
|
|
||||||
Node::pre_insert(node, abstract_self, None)
|
Node::pre_insert(node, abstract_self, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1131,7 +1143,6 @@ impl Node<ScriptView> {
|
||||||
pub fn RemoveChild(&self,
|
pub fn RemoveChild(&self,
|
||||||
abstract_self: AbstractNode<ScriptView>,
|
abstract_self: AbstractNode<ScriptView>,
|
||||||
node: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> {
|
node: AbstractNode<ScriptView>) -> Fallible<AbstractNode<ScriptView>> {
|
||||||
self.wait_until_safe_to_modify_dom();
|
|
||||||
Node::pre_remove(node, abstract_self)
|
Node::pre_remove(node, abstract_self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
src/test/html/content/test_element_attributes.html
Normal file
21
src/test/html/content/test_element_attributes.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<html>
|
||||||
|
<head id="foo">
|
||||||
|
<script src="harness.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div></div>
|
||||||
|
<script>
|
||||||
|
var attrs = [];
|
||||||
|
for (var i = 'a'.charCodeAt(0); i != 'z'.charCodeAt(0); i++) {
|
||||||
|
document.getElementsByTagName('div')[0].setAttribute(String.fromCharCode(i),
|
||||||
|
i.toString());
|
||||||
|
}
|
||||||
|
var attributes = document.getElementsByTagName('div')[0].attributes;
|
||||||
|
for (var i = 0; i < attributes.length; i++) {
|
||||||
|
is(attributes[i].name, String.fromCharCode(i + 'a'.charCodeAt(0)));
|
||||||
|
is(attributes[i].value, (i + 'a'.charCodeAt(0)).toString());
|
||||||
|
}
|
||||||
|
finish();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue