4 ms·
It's all fun and games, until you have to access parent elements. You'll likely start wrapping these methods, and before you know it, you have jQuery-micro.
by softwarefounder 8y ago
It's all fun and games, until you have to access parent elements.
You'll likely start wrapping these methods, and before you know it, you have jQuery-micro.
- scottharveyco 8y agoThat's what I have, a very small helper library that contains 5 or 6 functions that I use frequently like .closest(), .hideAll(), .showAll() etc. My application doesn't use much JS so this seems reasonable to me instead of including a framework for a few functions.
- bzbarsky 8y agoFor what it's worth, https://caniuse.com/#feat=element-closest https://caniuse.com/#feat=element-closest is supported by everyone except IE (and Opera Mini, I guess).
- Piskvorrr 8y agoThat's exactly the point! "Oh, you can code [a polyfill] yourself, and it will work. Mostly. Sort of. jQuery bad, reinventing the wheel good! Never mind that you originally went there to implement some business logic, let's get tangled in the myriad almost-almost-working combinations."
- minitech 8y ago> Oh, you can code [a polyfill] yourself, and it will work. Use a polyfill that already exists. Take it out when browser support is there.
- chrismorgan 8y agoFor finding parents matching a selector, there’s a fairly recent addition, Element.closest(). There’s not magnificent support for it yet (notably, no IE), so you will probably need a polyfill.