This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25512 - Is the ability to access elements by their name or ID likely to be removed?
Summary: Is the ability to access elements by their name or ID likely to be removed?
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: HTML (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: Unsorted
Assignee: Ian 'Hixie' Hickson
QA Contact: contributor
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-30 03:18 UTC by contributor
Modified: 2014-05-15 18:09 UTC (History)
3 users (show)

See Also:


Attachments

Description contributor 2014-04-30 03:18:47 UTC
Specification: http://www.whatwg.org/specs/web-apps/current-work/
Multipage: http://www.whatwg.org/C#named-access-on-the-window-object
Complete: http://www.whatwg.org/c#named-access-on-the-window-object
Referrer: 

Comment:
Is the ability to access elements by their name or ID likely to be removed?

Should their be a note that discourages its use?

Everything I read on the Internet, discourages this practice, as they are all
HOPING this features/bug gets removed.

I have found it quite useful as a teaching tool. I teach coding via
CodeAvengers.com and it is quite nice not to have to ram
document.getElementById() down learners through from the get go.

Posted from: 125.239.230.240
User agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1962.0 Safari/537.36
Comment 1 Ian 'Hixie' Hickson 2014-04-30 18:05:44 UTC
I doubt this will change. It's bad practice for many reasons, but we're more or less stuck with it, I think.

bz might have an opinion about this.
Comment 2 Boris Zbarsky 2014-04-30 18:29:38 UTC
I tried to convince non-Gecko UAs to remove this, and failed.  So I doubt it's going to go anywhere.

That said, it's a really bad habit to get into, because it's very unreliable.  Whether the element is accessible by window.id depends on the value of the id, and an element that's accessible today might not be tomorrow if a new function with the same name gets added to the window...
Comment 3 Ian 'Hixie' Hickson 2014-05-01 18:14:25 UTC
Yeah.
Comment 4 Ian 'Hixie' Hickson 2014-05-05 22:59:36 UTC
So the request here would be to turn the very very vague author advice here:

   http://whatwg.org/html#named-access-on-the-window-object

...into something much more opinionated, I guess.
Comment 5 contributor 2014-05-13 23:53:46 UTC
Checked in as WHATWG revision r8631.
Check-in comment: Discourage window.foo usage
http://html5.org/tools/web-apps-tracker?from=8630&to=8631
Comment 6 Ian 'Hixie' Hickson 2014-05-13 23:53:56 UTC
Ok, is that enough?
Comment 7 Ian 'Hixie' Hickson 2014-05-15 18:09:44 UTC
Marking FIXED based on the diff in comment 5 and the lack of complaints thereon. If you want more, just reopen the bug. Thanks!