Hacker News new | ask | show | jobs
by dspillett 4621 days ago
I don't think any Javascript is in use at all here, but if it were I would not expect errors but instead simply unexpected behaviour as browsers tend to just try do something if what you are asking isn't clear (for instance if a jquery selector returns nothing, any changes you chain after the call just apply to that nothing instead of complaining that they expect to have some nodes to act on).

Multiple elements with the same ID is wrong of course, so you can't guarantee what will happen if you use and ID based selector: three equally (in)correct interpretations would be "act on the first element you find with that ID", "act on all elements with that ID", and "error because we don't expect to find more than one". By breaking the standard you are exposing yourself to undefined behaviour - the browser can do what it likes and each environment might do something different.