avm1: Iterating xmlnode attributes should list every attribute

This commit is contained in:
Nathan Adams 2020-09-04 01:07:01 +02:00 committed by Mike Welsh
parent bcb64b9a62
commit c5ac707fb5
5 changed files with 16 additions and 1 deletions

View File

@ -215,7 +215,9 @@ impl<'gc> TObject<'gc> for XMLAttributesObject<'gc> {
}
fn get_keys(&self, activation: &mut Activation<'_, 'gc, '_>) -> Vec<String> {
self.base().get_keys(activation)
let mut base = self.base().get_keys(activation);
base.extend(self.node().attribute_keys());
base
}
fn as_string(&self) -> Cow<str> {

View File

@ -1042,6 +1042,17 @@ impl<'gc> XMLNode<'gc> {
}
}
/// Retrieve all keys defined on this node.
pub fn attribute_keys(self) -> Vec<String> {
match &*self.0.read() {
XMLNodeData::Element { attributes, .. } => attributes
.keys()
.map(|v| v.node_name().to_string())
.collect::<Vec<String>>(),
_ => Vec::new(),
}
}
/// Retrieve the value of a single attribute on this node, case-insensitively.
///
/// TODO: Probably won't need this when we have a proper HTML parser.

View File

@ -1,3 +1,5 @@
attr y string
undefined
attrx
attry