Open onnlucky opened 6 years ago
So are you suggesting removing the layer:destroy event? We definitely need to keep this around so we know when a layer is destroyed.
I understand not firing the change:parent when set to null during initialization... If that's what you are saying.
Any code that calls @off
for event handlers, will implicitly create a dom even wrapper because it is created in a getter. We need an alternative to the default getter that will not create a wrapper, and places that use it can skip a lot of work if there never was a wrapper.
I am not proposing to remove "layer:destroy"
, only to make the code that emits it follow the same code path that avoids creating needless wrappers.
On init and on destroy of a layer, event handlers are removed from elements that sometimes don't even have handlers. The problem is this will call the getter
layer._domEventHandler
and will create a needlessDOMEventManagerElement
just so all handlers can be removed.For example,
@define "constraintValues"
calls@off "change:parent", @parentChanged
when set withnull
, which is done when applying defaults.Also in
Layer.destroy()
,@_context.emit("layer:destroy", @)
will trigger code that has the same effect.All that work is just wasteful. Especially for Layers that never actually have any dom event handlers.