Dispose of subscriptions on SpacePen views in callRemoveHooks

Fixes atom/bracket-matcher#75
This commit is contained in:
Nathan Sobo
2014-10-11 07:25:28 -07:00
parent 95ee29ea39
commit b149d47b09
2 changed files with 10 additions and 5 deletions

View File

@@ -56,7 +56,7 @@
"season": "^1.0.2",
"semver": "1.1.4",
"serializable": "^1",
"space-pen": "3.7.0",
"space-pen": "3.8.0",
"temp": "0.7.0",
"text-buffer": "^3.2.8",
"theorist": "^1.0.2",

View File

@@ -1,15 +1,20 @@
_ = require 'underscore-plus'
spacePen = require 'space-pen'
SpacePen = require 'space-pen'
{Subscriber} = require 'emissary'
Subscriber.includeInto(spacePen.View)
Subscriber.includeInto(SpacePen.View)
jQuery = spacePen.jQuery
jQuery = SpacePen.jQuery
JQueryCleanData = jQuery.cleanData
jQuery.cleanData = (elements) ->
jQuery(element).view()?.unsubscribe() for element in elements
JQueryCleanData(elements)
SpacePenCallRemoveHooks = SpacePen.callRemoveHooks
SpacePen.callRemoveHooks = (element) ->
view.unsubscribe() for view in SpacePen.viewsForElement(element)
SpacePenCallRemoveHooks(element)
NativeEventNames = new Set
NativeEventNames.add(nativeEvent) for nativeEvent in ["blur", "focus", "focusin",
"focusout", "load", "resize", "scroll", "unload", "click", "dblclick", "mousedown",
@@ -133,4 +138,4 @@ jQuery.fn.setTooltip.humanizeKeystrokes = humanizeKeystrokes
Object.defineProperty jQuery.fn, 'element', get: -> @[0]
module.exports = spacePen
module.exports = SpacePen