appendChild also refuses to orphan nodes already part of another XML tree.
This commit is contained in:
parent
bff851e6a4
commit
c76e5ce447
|
@ -53,8 +53,10 @@ pub fn xmlnode_append_child<'gc>(
|
||||||
this.as_xml_node(),
|
this.as_xml_node(),
|
||||||
args.get(0).map(|n| n.as_object().map(|n| n.as_xml_node())),
|
args.get(0).map(|n| n.as_object().map(|n| n.as_xml_node())),
|
||||||
) {
|
) {
|
||||||
let position = xmlnode.children_len();
|
if let Ok(None) = child_xmlnode.parent() {
|
||||||
xmlnode.insert_child(ac.gc_context, position, child_xmlnode)?;
|
let position = xmlnode.children_len();
|
||||||
|
xmlnode.insert_child(ac.gc_context, position, child_xmlnode)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Value::Undefined.into())
|
Ok(Value::Undefined.into())
|
||||||
|
|
|
@ -114,6 +114,7 @@ swf_tests! {
|
||||||
(xml_siblings, "avm1/xml_siblings", 1),
|
(xml_siblings, "avm1/xml_siblings", 1),
|
||||||
(xml_attributes_read, "avm1/xml_attributes_read", 1),
|
(xml_attributes_read, "avm1/xml_attributes_read", 1),
|
||||||
(xml_append_child, "avm1/xml_append_child", 1),
|
(xml_append_child, "avm1/xml_append_child", 1),
|
||||||
|
(xml_append_child_with_parent, "avm1/xml_append_child_with_parent", 1),
|
||||||
(xml_remove_node, "avm1/xml_remove_node", 1),
|
(xml_remove_node, "avm1/xml_remove_node", 1),
|
||||||
(xml_insert_before, "avm1/xml_insert_before", 1),
|
(xml_insert_before, "avm1/xml_insert_before", 1),
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
true
|
||||||
|
null
|
||||||
|
true
|
||||||
|
true
|
||||||
|
null
|
||||||
|
true
|
||||||
|
Swapping nodes...
|
||||||
|
true
|
||||||
|
null
|
||||||
|
true
|
||||||
|
true
|
||||||
|
null
|
||||||
|
true
|
||||||
|
Failing to swap nodes...
|
||||||
|
true
|
||||||
|
null
|
||||||
|
true
|
||||||
|
true
|
||||||
|
null
|
||||||
|
true
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue