3 ms·
Exactly like how `getElementById` replaced the direct use of the id as a JavaScript identifier.
by littlestymaar 1y ago
Exactly like how `getElementById` replaced the direct use of the id as a JavaScript identifier.
- xg15 1y agoI remember there being posts that explicitly discouraged using IDs directly, but I'm not sure of tge reasons anymore. Maybe browser incompatibilities or unclear scoping and confusion with other variables?
- withinboredom 1y agoIt was either Mozilla (Netscape, I think) or IE that it didn’t work on for the longest time.
- mook 1y agoI think that was a native IE API that Mozilla had to add support for, as well as document.all (Netscape used document.layers).
- chrismorgan 1y agoIt works everywhere (it’s now specified in https://html.spec.whatwg.org/multipage/nav-history-apis.html#named-access-on-the-window-object https://html.spec.whatwg.org/multipage/nav-history-apis.html...), but it’s brittle. It can break by adding colliding properties to window deliberately or by accidental global leak (… including things like setting in dev tools), by browser defining new globals, by some 'name' attribute conflict.