Hacker News new | ask | show | jobs
by LorenzA 2689 days ago
document.querySelectorAll('.tpm_sensors').forEach((sensor) => {if (sensor.pressure < threshold) { fixBeforeIDie(); }});
2 comments

Then this breaks in older browsers because forEach isn't a method on a NodeList. So you have to polyfill in features to do [...document.querySelectorAll('.tpm_sensors')].forEach(...);
and you usually define $ and $$ as querySelector and querySelectorAll at the beginning of the file if you don't like writing them all out, so they're exactly the same length
I remember the mess that came before jQuery. This is quite literally what we did back then, just with a custom made snippet of JS for finding by id and by class. It sucked. I mean to me Bootstrap is just a black box library, I don’t care how it works as long as it does. But this is going to suck for those working on its code.