Skip to content

Commit

Permalink
avm2: Implement XML.setChildren
Browse files Browse the repository at this point in the history
  • Loading branch information
evilpie authored and torokati44 committed Nov 2, 2023
1 parent 3572367 commit 8138b68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions core/src/avm2/globals/XML.as
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ package {
AS3 native function insertChildBefore(child1:Object, child2:Object):*;
// NOTE: Docs lie, value can be anything not just XML.
AS3 native function replace(propertyName:Object, value:*):XML;
AS3 native function setChildren(value:Object):XML;

AS3 function valueOf():XML {
return this;
Expand Down Expand Up @@ -252,6 +253,11 @@ package {
return self.AS3::replace(propertyName, value);
}

prototype.setChildren = function(value:Object):XML {
var self:XML = this;
return self.AS3::setChildren(value);
}

public static const length:int = 1;
}
}
16 changes: 16 additions & 0 deletions core/src/avm2/globals/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,22 @@ pub fn replace<'gc>(
Ok(xml.into())
}

// ECMA-357 13.4.4.33 XML.prototype.setChildren (value)
pub fn set_children<'gc>(
activation: &mut Activation<'_, 'gc>,
this: Object<'gc>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
let xml = this.as_xml_object().unwrap();
let value = args.get_value(0);

// 1. Call the [[Put]] method of x with arguments "*" and value
xml.set_property_local(&Multiname::any(activation.gc()), value, activation)?;

// 2. Return x
Ok(xml.into())
}

pub fn set_notification<'gc>(
activation: &mut Activation<'_, 'gc>,
this: Object<'gc>,
Expand Down
1 change: 0 additions & 1 deletion tests/tests/swfs/from_avmplus/e4x/XML/e13_4_4_33/test.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true

0 comments on commit 8138b68

Please sign in to comment.