I am a bit new to javascript and was trying to understand how the W3C DOM standard and javascript as defined by ECMAscript interoperate.
Specifically, as I understand it:
the ECMAscript standard defines the existence of a Global Object, which provides functions such as parseInt(string)
and explicitly allows the presence of other built-in objects accessible through it, but the definition of these is left to the implementation.
The W3C DOM standard defines a set of objects and interfaces which correspond to the structure of an HTML document. One of these is the Document
object (uppercase D) containing methods such as getElementById
. However this specification, as far as I understand it, does not define how an instance of such an object representing the current document in a browser may be obtained.
Basically, what I am after is - where is it explicitly stated that when executing javascript in a web page, I can call document.getElementById("someId")
(note lowercase d), and that the document
property represents the DOM of the document in which the javascript is executing?
Is this particular detail implementation-specific. Shouldn't it be standardised somewhere? The nearest I can get is the Gecko DOM documentation which appears to imply that document
and Document
are equivalent. I thought javascript was case sensitive? Or am I just being really anal about interpreting these things?
Edit:
Trawling through the HTML 5 standard working draft after Jason's comment, I think the bit that captures what I'm looking for is
6.5.3.3 Creating scripts
...the user agent must run the following steps:
4
. Set up the script's global object, the script's browsing context, the script's URL character encoding and the script's base URL
6.5.3.1 states of the global object that
"This is typically a Window object. In JavaScript, this corresponds to the global object."
Further, 6.1 Browsing Contexts states
"The main view through which a user primarily interacts with a user agent is the default view. The AbstractView object that represents this view must also implement the Window interface, and is referred to as the Document's Window object. WindowProxy objects forward everything to the active document's default view's Window object."
Since the AbstractView interface implements the document property as per DOM 2 Views spec, this presumably is what defines the existence of the Javascript global document property.