Frank Kozuschnik wrote:
> Thomas 'PointedEars' Lahn:
>> JJ:
>>> If a HTML element has an ID, it can be referenced from the global
>>> object or the `window` object.
>> … in Quirks Mode only, as this is a legacy feature.
>
> Which browser would nowadays support this "feature" in quirks mode only?
I do not know, but there have to be some. It might also depend on the
declared document type. If you really want to know, you can build a test
case and find it out; for me, it would be a waste of time.
Thank you. That is both interesting and disturbing.
That is _not_ “the HTML spec”, but the WHATWG “HTML Living Standard”.
There are people who consider this document normative even though it
lacks all characteristics of an industry standard.
The latest HTML specification is the HTML 5.1 W3C Recommendation, based on
a snapshot of the above:
<
https://www.w3.org/TR/2016/REC-html51-20161101/>
This error-prone legacy feature is actually specified in
<
https://www.w3.org/TR/2016/REC-html51-20161101/browsers.html#named-access-on-the-window-object>
such that
| […] The supported property names at any moment consist of the following,
| in tree order, ignoring later duplicates:
|
| * the child browsing context name property set.
|
| * the value of the “name” content attribute for all “a”, “applet”, “area”,
| “embed”, “form”, “frameset”, “img”, and “object” elements in the active
| document that have a non-empty “name” content attribute, and
|
| * the value of the “id” content attribute of any HTML element in the
| active document with a non-empty “id” content attribute.
which I find even more disturbing. It would seem that the wannabes have
taken over core sections of the W3C at this point :-(
At least they have added this informal note at the top of the section:
| As a general rule, relying on this will lead to brittle code. Which IDs
| end up mapping to this API can vary over time, as new features are added
| to the Web platform, for example. Instead of this, use
| “document.getElementById()” or “document.querySelector()”.