-
-
Notifications
You must be signed in to change notification settings - Fork 828
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: Improve XML set_property_local implementation #13041
Conversation
a2b6e80
to
6d5d191
Compare
@@ -244,6 +244,57 @@ impl<'gc> E4XNode<'gc> { | |||
node | |||
} | |||
|
|||
/// Returns the amount of children in this node if this node is of Element kind, otherwise returns [None]. | |||
pub fn length(&self) -> Option<usize> { | |||
let E4XNodeKind::Element { children, .. } = &*self.kind() else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd say do it the other way around?
it let E4XNodeKind::Element { children, .. } = &*self.kind() {
Some(children.len())
} else {
None
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can cleanup in follow up PR.
let E4XNodeKind::Element { children, .. } = &mut *kind else { | ||
// 7. Let isValidName be the result of calling the function isXMLName (section 13.1.2.1) with argument n | ||
let is_valid_name = name.local_name().map_or(Ok(false), |x| { | ||
crate::avm2::e4x::is_xml_name(activation, x.into()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(in retrospect, maybe passing an AvmString to is_xml_name
would have been a nicer design, so it wouldn't need a Result
here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I also realized this myself, I should have left the null
and undefined
handling in AS3 isXMLName
function. Can cleanup in follow up PR.
Changes existing AS3 copy method to use this instead
901863a
to
8ddec21
Compare
This is a draft as it currently makes testxml_namespaced_property
fail.Also requires #12993(merged)Fixes #12162
Fixes #12910