-
Notifications
You must be signed in to change notification settings - Fork 2
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
Make ES5 compatible by using an object instead of Map and adding a polyfill for WeakMap #2
base: master
Are you sure you want to change the base?
Conversation
@kristerkari thanks for the PR! Needs some work before I can merge it. The key/value object doesn't work well when export const getEd = (element = document.body) => {
if (ed[element] !== undefined) { If you call it with e.g. Your To solve the first issue, you'd have to implement part of For not leaking memory, you'd have to keep counts of the number of mounted components referencing each element, and clean up the pseudo-map entry when there are no references, after rolling back the style/className changes. Hope you continue working on this, it'd be nice to not rely on |
Yeah I was thinking about implementing a local version of Doing the cleanup of references does not sound like a big thing to do. But now that I think about it, it would probably be easier to just include the polyfills in this project as it would to be adding ~1kb minified code to the library: https://github.com/Polymer/WeakMap/blob/master/weakmap.js What do you think @brigand? |
@brigand I brought WeakMap back and added a small polyfill. It's really a small amount of code, but this way the user of the library doesn't have to worry about polyfills. I guess that we can also get rid of |
Thanks for getting back to this. Have you tested it in an app? If so, I'll merge it. |
I did not test it in an app yet, but I'll test in our app to see if it works normally in IE11 after I remove the polyfills 👍 |
I did some testing with the changes. It seems that the polyfill does not for some reason get applied properly, so an error gets thrown. I was unable access dev tools on the browsers that I tested with, so I don't know yet what it throws. I need to try to find a browser that does not support WeakMap and has working dev tools. |
fixes #1
ping @brigand