marionettejs / backbone.marionette

The Backbone Framework
https://marionettejs.com
Other
7.07k stars 1.26k forks source link

multiple triggers of `destroy` and `before:destroy` events in some cases #3634

Closed taburetkin closed 6 years ago

taburetkin commented 6 years ago

Description

  1. if main view listen for childview destroy for self destroying, mainview destroy called multiple times, and all destroy events triggered multiple times
  2. there should be a guard for preventing destroy called more than once

Expected behavior

destroy logic should be executed only once and all triggers should occur only once too.

Actual behavior

here is an example: https://jsfiddle.net/c4dbp50m/11/ main view is a CollectionView but with View and childView in regions behavior is the same

Environment

  1. Marionette version: v4
  2. Backbone version: v1.3