4 ms·
If you like brittle things, the id attribute is already made into an attribute on the window for legacy reasons Edit: My tone may have indicated that parent's
by nattaylor 2y ago
If you like brittle things, the id attribute is already made into an attribute on the window for legacy reasons
Edit: My tone may have indicated that parent's solution was brittle. It's not!
- akira2501 2y agoThe id attribute can take on values that are already present or reserved in window. "fetch", "opener", etc.. The reason to have a separate system that correctly calls getElementById() is to avoid this issue. So, it's actually a _less_ brittle mechanism that doesn't rely on legacy mechanisms and lacks the surprises that come with that.
- nattaylor 2y agoSorry, I didn't mean to suggest your solution was brittle -- I actually quite like it and want to adopt it! But I do think the legacy browser behavior with the ID attribute as window properties is very brittle for the reasons you suggest
- akira2501 2y agoMy fault, I tend to "rapid fire" sometimes. Yours was next to another reply on the identical subject and that caused me to mistake the meaning of the comma in your sentence. Reading it more slowly, I see it now, and, thank you!
- cies 2y agoNah, i rather skip brittle :) But what's not brittle in JS? Elm? (TS to some extend)