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. this.elem cache #347

Closed
qfox opened this issue Mar 15, 2013 · 11 comments · Fixed by #634
Closed

i-bem. this.elem cache #347

qfox opened this issue Mar 15, 2013 · 11 comments · Fixed by #634
Assignees

Comments

@qfox
Copy link
Member

qfox commented Mar 15, 2013

this.elem cache should be dropped after findElem call
also is it possible to drop elem cache after jQuery dom manipulation functions calls? like empty or append, remove?

@corpix
Copy link
Contributor

corpix commented Mar 15, 2013

Are you talking about update, append, replace etc. i-bem__dom methods? Pure jQuery DOM manipulations is not recommended while you use BEM.
I don't know a good way to drop elem cache on DOM manipulations because we don't actually know what elements was appended/removed, someone please correct me if I go wrong

@qfox
Copy link
Member Author

qfox commented Mar 15, 2013

Sure not. I'm just talking about block/elem cache invalidation. Actually some jquery plugins just modifying DOM tree so we can't be everywhere and need some stable solution. I don't need to manipulate it by self despite the fact that some times it could be useful. e.g. for dynamic initialization of block: this.elem('title').length > 0 || renderBlock();

Just if something changed in DOM tree cache of elem and block must be dropped because it's already invalid and can store references to removed DOMElements at the moment. So garbage collector will be confused and it will result in memory leaks.

There is also W3C DOM 2 Events Recommendation: http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-mutationevents about mutationevents.

Easy way to do that is to use something like http://www.quirksmode.org/js/events/DOMtree.html — pretty cute demo about mutations which could be used to cache validation (tiny and useful way to collect garbage in cache).

I think it should be integrated. It's not too hard to do that and also it will be very good to have it regardless of DOM tree modifications by some third party scripts.

@deeonis
Copy link
Contributor

deeonis commented Feb 27, 2015

@zxqfox could you plz send pr?

@qfox
Copy link
Member Author

qfox commented Feb 27, 2015

@deeonis I can try to do it in medium-long period.

@qfox qfox self-assigned this Feb 27, 2015
@qfox
Copy link
Member Author

qfox commented Feb 27, 2015

Similar issue in bem-core: bem/bem-core#583

@deeonis
Copy link
Contributor

deeonis commented Feb 27, 2015

I can try to do it in medium-long period.

we'll be waiting 😼

@qfox
Copy link
Member Author

qfox commented Apr 17, 2015

@deeonis I'm not sure about the full idea of this issue but since code is pretty close to bem-core@v2.x codebase I think we can use it as is.

About full caching issues → not sure we can do it easily, it's a lot of work so I prefer to left it as is.

So it's ready, feel free to merge it ;-)

@qfox
Copy link
Member Author

qfox commented Jun 4, 2015

@deeonis Polite ping.

@Yeti-or
Copy link
Member

Yeti-or commented Jun 5, 2015

@zxqfox pong :)

qfox pushed a commit that referenced this issue Jun 8, 2015
@Yeti-or
Copy link
Member

Yeti-or commented Jun 8, 2015

@zxqfox Do u think that we need to do smth else with this issue?

@qfox
Copy link
Member Author

qfox commented Jun 8, 2015

I had some ideas long time ago, but for now there is better idea with virtualdom. I think we can left it as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants