3 ms·
> Nothing will become inaccurate, because JS never introduces breaking changes. Can you help me debug why `document.createElement('button').attachEvent('onclic
by reificator 6y ago
> Nothing will become inaccurate, because JS never introduces breaking changes.
Can you help me debug why `document.createElement('button').attachEvent('onclick', e=>alert('attachEvent!'))` isn't working then?
You might object that DOM APIs aren't part of JS proper and that's true, but this guide covers `addEventListener` on this page: https://javascript.info/introduction-browser-events https://javascript.info/introduction-browser-events
Sticking only to JS language features, I assume you can help track down why my `with()` statement doesn't work. Or why `function testing() { console.log(this.location.href); } testing();` throws an error but only if I package my code as an ES Module instead of an AMD bundle.
I agree that breaking changes like this are increasingly unlikely to happen, and I think the changes that have been made are easily net positive. But the claim that they never happen is simply not true.
- brundolf 6y agoI do include the DOM API in my statement, but I do not include non-standardized browser APIs, which attachEvent seems to be. I'll refine my statement to "The JS standard never introduces breaking changes". attachEvent never was part of any standard, and is therefore subject to breakage. Non-standard APIs should never be part of a comprehensive guide to the language in the first place.
- reificator 6y agoI was worried that leading with `attachEvent` would get a response about only `attachEvent`. The `with` statement is described on page 75 of the ES3 standard[0]. It does not work in an ES Module or in a strict mode context. This is a breaking change. [0]: https://www-archive.mozilla.org/js/language/E262-3.pdf https://www-archive.mozilla.org/js/language/E262-3.pdf
- brundolf 6y agoStrict mode was invented as a way of introducing a handful of "breaking" changes without them actually being breaking, since it's opt-in. JavaScript had some egregious design issues from the beginning and strict mode is a remedy to some of them. But when most people say "breaking changes" they mean things that suddenly cause legacy code to stop working, and non-strict mode will almost certainly be supported ad infinitum, so I don't really count that. It's also almost certainly never going to happen again.