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.

@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
@JeanMeche
JeanMeche removed the request for review from crisbeto August 16, 2026 17:43
@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker target: patch This PR is targeted for the next patch release labels Aug 16, 2026
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.
@JeanMeche
JeanMeche force-pushed the animations-trigger-hasown branch from 018bb28 to 2f89d58 Compare August 16, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: animations legacy animations package only. Otherwise use area: core. target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants