Skip to content

fix(animations): detect object trigger values with Object.hasOwn - #70149

Open
arshsmith1 wants to merge 1 commit into
angular:mainfrom
arshsmith1:animations-trigger-hasown
Open

fix(animations): detect object trigger values with Object.hasOwn#70149
arshsmith1 wants to merge 1 commit into
angular:mainfrom
arshsmith1:animations-trigger-hasown

Conversation

@arshsmith1

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

StateValue (and AnimationTransitionNamespace.trigger) figure out whether a trigger binding is in the {value, params} object form by calling input.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 own hasOwnProperty key, for example [@state]="JSON.parse('{\"value\":\"open\",\"hasOwnProperty\":\"x\"}')", that own property shadows the method, so the call throws TypeError: input.hasOwnProperty is not a function and 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?

  • Yes
  • No

Other information

The added spec fails on main with the TypeError and passes with this change.

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.
@pullapprove
pullapprove Bot requested a review from crisbeto August 11, 2026 12:56
@angular-robot angular-robot Bot added the area: animations legacy animations package only. Otherwise use area: core. label Aug 11, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: animations legacy animations package only. Otherwise use area: core.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant