Expose `parentNode` to ActionScript
This commit is contained in:
parent
807725d7aa
commit
223320c98c
|
@ -278,6 +278,27 @@ pub fn create_xmlnode_proto<'gc>(
|
||||||
None,
|
None,
|
||||||
ReadOnly.into(),
|
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
|
xmlnode_proto
|
||||||
.as_script_object()
|
.as_script_object()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -110,6 +110,7 @@ swf_tests! {
|
||||||
(xml_clone_expandos, "avm1/xml_clone_expandos", 1),
|
(xml_clone_expandos, "avm1/xml_clone_expandos", 1),
|
||||||
(xml_has_child_nodes, "avm1/xml_has_child_nodes", 1),
|
(xml_has_child_nodes, "avm1/xml_has_child_nodes", 1),
|
||||||
(xml_first_last_child, "avm1/xml_first_last_child", 1),
|
(xml_first_last_child, "avm1/xml_first_last_child", 1),
|
||||||
|
(xml_parent_and_child, "avm1/xml_parent_and_child", 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
true
|
||||||
|
true
|
||||||
|
true
|
||||||
|
true
|
||||||
|
null
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue