mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
35e45dc894
Previously, attempting to destroy a view with listeners more than once throws an error during event listener cleanup. This happens because `cleanup` field on the `TView` has already been cleared out by the time the second destruction runs. The `destroyed` flag on LView was previously being set in the `destroyLView` function, but this flag was never _checked_ anywhere in the codebase. This commit moves _setting_ this flag to the `cleanupView` function, just before destroy hooks are called. This is necessary because the destroy hooks can contain arbitrary user code, such as (surprise!) attempting to destroy the view (again). We also add a check to `destroyLView` to skip already-destroyed views. This prevents the cleanup code path from running twice. PR Close #28413