Implement `namespaceURI`

This commit is contained in:
David Wendt 2019-12-26 09:10:26 -07:00
parent 73da72db98
commit 00319f14a8
1 changed files with 18 additions and 0 deletions

View File

@ -359,6 +359,24 @@ pub fn create_xmlnode_proto<'gc>(
None,
ReadOnly.into(),
);
xmlnode_proto.add_property(
gc_context,
"namespaceURI",
Executable::Native(|_avm, _ac, this: Object<'gc>, _args| {
if let Some(node) = this.as_xml_node() {
if let Some(name) = node.tag_name() {
return Ok(node
.lookup_uri_for_namespace(name.prefix().unwrap_or(""))
.map(|s| s.into())
.unwrap_or_else(|| "".into()));
}
}
Ok(Value::Undefined.into())
}),
None,
ReadOnly.into(),
);
xmlnode_proto
.as_script_object()
.unwrap()