avm2: Support any name in XML get_property_local

Fixes #9999
This commit is contained in:
Tom Schuster 2023-03-12 17:38:10 +01:00 committed by Aaron Hill
parent 2d9c1a3829
commit 3d29b81a8c
2 changed files with 32 additions and 29 deletions

View File

@ -294,7 +294,11 @@ impl<'gc> E4XNode<'gc> {
}
pub fn matches_name(&self, name: &Multiname<'gc>) -> bool {
// FIXME - we need to handle namespaces heere
// FIXME - we need to handle namespaces here
if name.is_any_name() {
return true;
}
if let Some(local_name) = self.local_name() {
Some(local_name) == name.local_name()
} else {

View File

@ -118,35 +118,34 @@ impl<'gc> TObject<'gc> for XmlObject<'gc> {
return Ok(Value::Undefined);
}
}
let matched_children = if let E4XNodeKind::Element {
children,
attributes,
} = &*read.node.kind()
{
let search_children = if name.is_attribute() {
attributes
} else {
children
};
search_children
.iter()
.filter_map(|child| {
if child.matches_name(name) {
Some(E4XOrXml::E4X(*child))
} else {
None
}
})
.collect::<Vec<_>>()
} else {
Vec::new()
};
return Ok(
XmlListObject::new(activation, matched_children, Some(self.into())).into(),
);
}
let matched_children = if let E4XNodeKind::Element {
children,
attributes,
} = &*read.node.kind()
{
let search_children = if name.is_attribute() {
attributes
} else {
children
};
search_children
.iter()
.filter_map(|child| {
if child.matches_name(name) {
Some(E4XOrXml::E4X(*child))
} else {
None
}
})
.collect::<Vec<_>>()
} else {
Vec::new()
};
return Ok(XmlListObject::new(activation, matched_children, Some(self.into())).into());
}
read.base.get_property_local(name, activation)