Matthias said:
Jorge said:
window *is* already -in any decent browser- an alias of the global
object(1):
I was wondering about that passage in ECMA-262, Section 10.1.5:
"[...] for example, in the HTML document object model the window property
of the global object is the global object itself."
That matches what you're saying and contradicts what several others are
saying. The question is, is this normative to the DOM or descriptive
(e.g. for the time it was written)?
As Richard said. I would like to add an explanation as to why it is
"descriptive (and only an example)", hopefully for future reference:
As a rule of thumb, examples in specifications are *never* normative.
If you look closely, you can recognize the level of requirement in the part
that you have omitted (`[...]'):
| 15.1 The Global Object
|
| [...] Initially the global object has the following properties:
|
| [...]
| * Additional host defined properties. This may include a property whose
^^^
| value is the global object itself; [see quotation above]
That little word "may" is very important; so important, that in many other
specifications it is written in ALL-CAPS -- "MAY" -- so that it is not
overlooked in the prose. It means that there is the possibility of what is
described, but no requirement is made by the specification that it needs to
be made happen, and no recommendation is made to make it happen or to make
it not happen. IOW, it is completely neutral wording, by contrast to
"must/shall" (absolute requirement to be), "should" (recommendation in
favor), "should not" (recommendation against), "shall not/must not"
(absolute requirement not to be). See also RFC 2119, which defines these
terms common to many (if not all) technical specifications, and which is
therefore referred to by many specifications (for example, W3C
specifications). (Unfortunately, it is not referred to explicitly by the
Editions of the ECMAScript Language Specification; however, given general
use, and the way these words are used in the Specification, there can be no
doubt as to their meaning.)
Then you need to consider the scope of the Specification; no *programming
language* standard can provide a normative basis for the implementation of
a *host-defined (proprietary) feature* based on some *markup language*.
There is _not_ /the/ "HTML document model", but several ones. Even at the
time this wording was first used (1999/2000) there were at least three DOM
APIs: the NN4 DOM, the MSHTML DOM, and W3C DOM HTML Level 1; the first two
were not called "DOM" at the time (the prevalent term was "DHTML", cf. the
MSDN Library which still employs that term), and the latter one (obsolete
since 2003) did not specify the `window' property (nor do its successors to
date). As a rule of thumb, double-check all statements made by ECMA people
about HTML or the DOM, and by W3C Specifications about ECMAScript
implementations (for example, there are similar errors in examples in HTML
4.01).
Finally, a property can _not_ *be* an object; it can only _refer_ to one.
(Unfortunately, the Specification employs sloppy wording in several
normative places, while being rather unnecessarily pedantic in others
[especially in Edition 5]; a property can _not_ have an object for its
value, but only a reference to the object.)
On a personal note, Jorge has been told these and other basic things a
hundred times before already, but he would not listen (or try to
understand). The record shows he is likely only trolling; ignore him.
HTH
PointedEars