Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #33155

Legacy properties on Window objects (was: A generic question)

Path csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Legacy properties on Window objects (was: A generic question)
Date Mon, 01 May 2017 06:10:53 +0200
Organization PointedEars Software (PES)
Lines 70
Message-ID <11778646.uLZWGnKmhe@PointedEars.de> (permalink)
References <2372a119-d289-48a8-964c-f6ee4ad8bc5a@googlegroups.com> <1tz9urrqejwu3.1ubsg9y0ontbp$.dlg@40tude.net> <3990209.LvFx2qVVIh@PointedEars.de> <oe5irn$ufi$1@solani.org>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1493611853 14994 eJwFwYEBwCAIA7CXQGiRc8TZ/09YgqDzVhJMCIon3QUPK3EZa3p2P8tws3Nm5vNGbSJRvvQDEwQQbA== (1 May 2017 04:10:53 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Mon, 1 May 2017 04:10:53 +0000 (UTC)
User-Agent KNode/4.14.2
X-NNTP-Posting-Host eJwNyckBwDAIA7CVuEzKOFDi/Udo9RU8Nd8TiQwQvOYTtVO9/9yWXLFwJQFyBNqnTCwJr8fmAx+cEMg=
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Cancel-Lock sha1:tYOQREOuwOhRH25dMizZCbnpxvM=
X-User-ID eJwFwYEBwCAIA7CXZJQq50CV/09YEk6jNhhETIxdjndv9tYq79ulLwFZgupzghJYRa+l44svbz46MMbWD2rjFe0=
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
Xref csiph.com comp.lang.javascript:33155

Show key headers only | View raw


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.

> Even Firefox started polluting the global object in standards mode some
> years ago.
> 
> https://www.w3.org/Bugs/Public/show_bug.cgi?id=11960#c27

Thank you.  That is both interesting and disturbing.
 
>> Do not use it.
> 
> I agree. So does the HTML spec, but nevertheless the spec seems to
> require it:
> 
> https://html.spec.whatwg.org/#named-access-on-the-window-object

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()”.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

A generic question justaguy <lichunshen84@gmail.com> - 2017-04-29 09:56 -0700
  Re: A generic question JJ <jj4public@vfemail.net> - 2017-04-30 07:59 +0700
    Re: A generic question justaguy <lichunshen84@gmail.com> - 2017-04-29 19:21 -0700
    Re: A generic question Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-04-30 20:16 +0200
      Re: A generic question Frank Kozuschnik <franko@nurfuerspam.de> - 2017-04-30 22:53 +0200
        Legacy properties on Window objects (was: A generic question) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-05-01 06:10 +0200
        Re: A generic question JJ <jj4public@vfemail.net> - 2017-05-01 18:14 +0700
          Re: A generic question Frank Kozuschnik <franko@nurfuerspam.de> - 2017-05-01 18:07 +0200
  A generic question Ram Tobolski <ramtob@gmail.com> - 2017-04-30 08:01 -0700
    Re: A generic question justaguy <lichunshen84@gmail.com> - 2017-04-30 18:52 -0700

csiph-web