bem-bl
bem-bl copied to clipboard
i-bem__dom: Need a proper way to check if block was destroyed
BEM.DOM.destruct()
of i-bem__dom
destructs found blocks in context from first to last. This could lead to some strange effects, when block that has been removed already still is trying to handle events from nested blocks that are in a destructing phase.
Live example: http://jsbin.com/nuquv/1/edit?html,js,console
Block zooo
is still handling input
's blur
event, regardless the fact that it's instance has been destroyed already (there is no this._ppp
prop in instance). At the same time, zooo
is still linked to it's DOM element with this.domElem
.
So there is no "official" way to handle this situation in general because we can't say is block is still a "live".
In bem-core's i-bem__dom
version we could use this.hasMod('js', 'inited')
for this cases. May be we could add something similar to bem-bl's one?
\cc @dfilatov
Actually the problem from jsbin's example is that i-bem
initializes a new empty instance of input
after blur event happens. As this new instance is linked to the same DOM node that already has input_js_inited
class, it doesn't call onSetMod → js → inited
handler, where _ppp
property should be set. So we have "strange" log message in console, where this.domElem
exists, but this._ppp
isn't.
@dfilatov should I open another issue about that?
BEM-2126