mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
e4fbab9ec8
Internally we store lifecycle hooks in the format `[index, hook, index, hook]` and when iterating over them, we check one place ahead to figure out whether we've hit found a hook or an index. The problem is that the loop is set up to iterate up to `hooks.length` which means that we may go out of bounds on the last iteration, depending on where we started. This appears to happen under a specific set of circumstances where a directive calls `detectChanges` from an input setter while it has `ngOnChanges` and `ngAfterViewInit` hooks. These changes resolve the issue by only iterating up to `length - 1` which guarantees that we can always look one place ahead. This appears to have regressed some time in version 10. Fixes #38611. PR Close #40206