fix(animations): detect object trigger values with Object.hasOwn - #70149
Open
arshsmith1 wants to merge 1 commit into
Open
fix(animations): detect object trigger values with Object.hasOwn#70149arshsmith1 wants to merge 1 commit into
arshsmith1 wants to merge 1 commit into
Conversation
StateValue and AnimationTransitionNamespace.trigger detect the {value,
params} object form of a trigger binding by calling hasOwnProperty on the
bound value. When that value is an object from untrusted data (for example
a parsed JSON payload) carrying an own hasOwnProperty key, the shadowed
property is called as a method and throws, breaking the animation flush.
Use Object.hasOwn for the check so a shadowing key no longer matters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Type
What is the current behavior?
Issue Number: N/A
StateValue(andAnimationTransitionNamespace.trigger) figure out whether a trigger binding is in the{value, params}object form by callinginput.hasOwnProperty('value')on the bound value. When an app binds a trigger to an object that comes from untrusted data and happens to carry an ownhasOwnPropertykey, for example[@state]="JSON.parse('{\"value\":\"open\",\"hasOwnProperty\":\"x\"}')", that own property shadows the method, so the call throwsTypeError: input.hasOwnProperty is not a functionand the whole animation flush fails during change detection.What is the new behavior?
Both checks use
Object.hasOwn(value, 'value'), which does not go through the value's own members, so a shadowing key no longer matters. Primitive values and normal{value, params}objects are detected exactly as before.Does this PR introduce a breaking change?
Other information
The added spec fails on
mainwith theTypeErrorand passes with this change.