Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i-bem__dom: Need a proper way to check if block was destroyed #507

Open
narqo opened this issue May 6, 2014 · 2 comments
Open

i-bem__dom: Need a proper way to check if block was destroyed #507

narqo opened this issue May 6, 2014 · 2 comments

Comments

@narqo
Copy link
Member

narqo commented May 6, 2014

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

@narqo narqo added the JS label May 6, 2014
@narqo narqo changed the title Need a proper way to check if block was destroyed i-bem__dom: Need a proper way to check if block was destroyed May 6, 2014
@narqo
Copy link
Member Author

narqo commented May 7, 2014

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?

@deeonis
Copy link
Contributor

deeonis commented Feb 25, 2015

BEM-2126

@deeonis deeonis added the TODO label Feb 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants