Expose `parentNode` to ActionScript

This commit is contained in:
David Wendt 2019-12-25 20:42:54 -05:00
parent 807725d7aa
commit 223320c98c
5 changed files with 27 additions and 0 deletions

View File

@ -278,6 +278,27 @@ pub fn create_xmlnode_proto<'gc>(
None,
ReadOnly.into(),
);
xmlnode_proto.add_property(
gc_context,
"parentNode",
Executable::Native(|avm, ac, this: Object<'gc>, _args| {
if let Some(node) = this.as_xml_node() {
return Ok(node
.parent()
.unwrap_or(None)
.map(|mut parent| {
parent
.script_object(ac.gc_context, Some(avm.prototypes.xml_node))
.into()
})
.unwrap_or_else(|| Value::Null.into()));
}
Ok(Value::Undefined.into())
}),
None,
ReadOnly.into(),
);
xmlnode_proto
.as_script_object()
.unwrap()

View File

@ -110,6 +110,7 @@ swf_tests! {
(xml_clone_expandos, "avm1/xml_clone_expandos", 1),
(xml_has_child_nodes, "avm1/xml_has_child_nodes", 1),
(xml_first_last_child, "avm1/xml_first_last_child", 1),
(xml_parent_and_child, "avm1/xml_parent_and_child", 1),
}
#[test]

View File

@ -0,0 +1,5 @@
true
true
true
true
null

Binary file not shown.

Binary file not shown.