Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avm2: Implement XML.contains #16206

Merged
merged 7 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions core/src/avm2/globals/XML.as
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ package {
AS3 native function child(name:*):XMLList;
AS3 native function childIndex():int;
AS3 native function children():XMLList;
AS3 native function contains(value:*):Boolean;
AS3 native function copy():XML;
AS3 native function parent():*;
AS3 native function elements(name:* = "*"):XMLList;
Expand Down Expand Up @@ -171,6 +172,11 @@ package {
return self.AS3::children();
};

prototype.contains = function(value:*):Boolean {
var self:XML = this;
return self.AS3::contains(value);
};

prototype.copy = function():XML {
var self:XML = this;
return self.AS3::copy();
Expand Down
15 changes: 15 additions & 0 deletions core/src/avm2/globals/xml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,21 @@ pub fn children<'gc>(
.into())
}

pub fn contains<'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);

if let Some(other) = value.as_object().and_then(|obj| obj.as_xml_object()) {
let result = xml.node().equals(&other.node());
return Ok(result.into());
}
Ok(false.into())
}

pub fn copy<'gc>(
activation: &mut Activation<'_, 'gc>,
this: Object<'gc>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
num_ticks = 1
known_failure = true