Re: [whatwg/dom] getElementById should not return the first but no element if id exists multiple times (Issue #1361)

WebReflection left a comment (whatwg/dom#1361)

not sure I am adding anything, but *IDs* have a meaning in *SVG* namespaces too where these can be embedded into the document and conflict with outer *IDs* without having an outer-scope understanding of what's going on.

Accordingly, I agree there should be some warning around *IDs* used on the web because Shadow DOM, SVG, and who knows what else could have similar names so that it should never guarantee, if the *ID* is not unique, that it returns the mentioned element, encouraging developers to use better `querySelector` *CSS* constraints when such expectation is desired.

True that `getElementById` is the widest used *API* that worked for 20+ years and that cannot, and should not (imho) be changed by any mean.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1361#issuecomment-2668886097
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1361/2668886097@github.com>

Received on Wednesday, 19 February 2025 14:53:12 UTC