Permalink
Browse files

Merge pull request #559 from koenbok/feature/fix-domeventmanager-leak

remove layers from the DOMEventManager
  • Loading branch information...
onnlucky committed Jan 16, 2018
2 parents ca62c90 + 1ba8793 commit e3a10c8f14b9677fde5199af52e5fef5b0864a59
Showing with 11 additions and 1 deletion.
  1. +6 −1 framer/DOMEventManager.coffee
  2. +1 −0 framer/Layer.coffee
  3. +4 −0 test/tests/LayerTest.coffee
@@ -3,7 +3,7 @@
Utils = require "./Utils"
EventManagerIdCounter = 0
EventManagerIdCounter = 1
class DOMEventManagerElement extends EventEmitter
@@ -42,6 +42,11 @@ class exports.DOMEventManager
@_elements[element._eventManagerId]
remove: (element) =>
return unless element._eventManagerId
delete @_elements[element._eventManagerId]
element._eventManagerId = 0
reset: ->
for element, elementEventManager of @_elements
elementEventManager.removeAllListeners()
View
@@ -958,6 +958,7 @@ class exports.Layer extends BaseClass
@_context.removeLayer(@)
@_context.emit("layer:destroy", @)
@_context.domEventManager.remove(@_element)
##############################################################
@@ -1558,12 +1558,16 @@ describe "Layer", ->
it "should destroy", ->
before = Object.keys(Framer.CurrentContext.domEventManager._elements).length
layer = new Layer
layer.destroy()
(layer in Framer.CurrentContext.layers).should.be.false
assert.equal layer._element.parentNode, null
assert.equal before, Object.keys(Framer.CurrentContext.domEventManager._elements).length
it "should set text", ->
layer = new Layer

0 comments on commit e3a10c8

Please sign in to comment.