Skip to content

Commit

Permalink
avm2: Support enumeration for XML objects
Browse files Browse the repository at this point in the history
Previously, iterating the XML object would iterate the prototype. This broke filtering expressions on XML objects, which should work.
  • Loading branch information
sleepycatcoding authored and Dinnerbone committed Nov 10, 2023
1 parent 949b294 commit e8ccbf4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
35 changes: 35 additions & 0 deletions core/src/avm2/object/xml_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,41 @@ impl<'gc> TObject<'gc> for XmlObject<'gc> {
Ok(())
}

fn get_next_enumerant(
self,
last_index: u32,
_activation: &mut Activation<'_, 'gc>,
) -> Result<Option<u32>, Error<'gc>> {
Ok(Some(if last_index == 0 { 1 } else { 0 }))
}

fn get_enumerant_value(
self,
index: u32,
_activation: &mut Activation<'_, 'gc>,
) -> Result<Value<'gc>, Error<'gc>> {
if index == 1 {
Ok(self.into())
} else {
Ok(Value::Undefined)
}
}

fn get_enumerant_name(
self,
index: u32,
_activation: &mut Activation<'_, 'gc>,
) -> Result<Value<'gc>, Error<'gc>> {
if index == 1 {
Ok(index
.checked_sub(1)
.map(|index| index.into())
.unwrap_or(Value::Undefined))
} else {
Ok(Value::Undefined)
}
}

fn delete_property_local(
self,
activation: &mut Activation<'_, 'gc>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true # https://github.com/ruffle-rs/ruffle/issues/12351

0 comments on commit e8ccbf4

Please sign in to comment.