mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Cleanup all subscriptions when a view is removed from the DOM
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
_ = require 'underscore'
|
||||
{View} = require 'space-pen'
|
||||
jQuery = require 'jquery'
|
||||
|
||||
originalRemove = View.prototype.remove
|
||||
|
||||
@@ -17,3 +18,8 @@ _.extend View.prototype,
|
||||
remove: (args...) ->
|
||||
@unsubscribe()
|
||||
originalRemove.apply(this, args)
|
||||
|
||||
originalCleanData = jQuery.cleanData
|
||||
jQuery.cleanData = (elements) ->
|
||||
jQuery(element).view()?.unsubscribe?() for element in elements
|
||||
originalCleanData(elements)
|
||||
|
||||
Reference in New Issue
Block a user