by alextgordon · 11y ago · 0 comments
- No pointers
- No cache
- No branch predictor
- No interrupts
- No endianness
- No alignment
What exactly are we teaching students to program? It's certainly not a computer.
<img name="forEach">
<script>
document.images.forEach.src = "something";
</script>
This works, today, in all browsers. Adding "forEach" to the proto chain of HTMLCollection would make this code no longer work, so no browser is willing to add it for fear of breaking sites.The answer is to stop using HTMLCollection.
What's worse is that NodeList doesn't have this named-lookup issue, but putting Array.prototype on its proto chain (the obvious simplest way to get all the array goodies) again breaks websites, because some people uses "instanceof Array" to assume things about how an object will interact with Array.prototype.concat.
Long story short, making improvements to the DOM is very hard because of the two decades of weird website hacks that are supposed to not get broken in the process...