Skip to content
Permalink
Browse files

[giow] (2) Make HTMLDocument === Document.

Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=14037

git-svn-id: http://svn.whatwg.org/webapps@6718 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
Hixie committed Oct 20, 2011
1 parent ec18727 commit 83f13eef1b41120b4b0f27ee58d716865141168c
Showing with 97 additions and 149 deletions.
  1. +32 −49 complete.html
  2. +32 −49 index
  3. +33 −51 source
<pre>&lt;<a href=#the-form-element>form</a> <a href=#attr-form-name title=attr-form-name>name</a>="main"&gt;
Result: &lt;<a href=#the-output-element>output</a> <a href=#attr-fe-name title=attr-fe-name>name</a>="result"&gt;&lt;/output&gt;
&lt;<a href=#the-script-element>script</a>&gt;
<a href=#htmldocument title=HTMLDocument>document</a>.<a href=#dom-document-forms title=dom-document-forms>forms</a>.main.<a href=#dom-form-elements title=dom-form-elements>elements</a>.result.<a href=#dom-output-value title=dom-output-value>value</a> = 'Hello World';
<a href=#document title=Document>document</a>.<a href=#dom-document-forms title=dom-document-forms>forms</a>.main.<a href=#dom-form-elements title=dom-form-elements>elements</a>.result.<a href=#dom-output-value title=dom-output-value>value</a> = 'Hello World';
&lt;/script&gt;
&lt;/form&gt;</pre>

can have its "<code title=attr-hyperlink-href><a href=#attr-hyperlink-href>href</a></code>"
attribute changed in several ways:</p>

<pre>var a = <a href=#htmldocument title=HTMLDocument>document</a>.<a href=#dom-document-links title=dom-document-links>links</a>[0]; // obtain the first link in the document
<pre>var a = <a href=#document title=Document>document</a>.<a href=#dom-document-links title=dom-document-links>links</a>[0]; // obtain the first link in the document
a.<a href=#dom-a-href title=dom-a-href>href</a> = 'sample.html'; // change the destination URL of the link
a.<a href=#dom-uda-protocol title=dom-uda-protocol>protocol</a> = 'https'; // change just the scheme part of the URL
a.setAttribute('href', 'http://example.com/'); // change the content attribute directly</pre>

</ol><h4 id=documents-in-the-dom><span class=secno>3.1.1 </span>Documents in the DOM</h4>

<p>All <code><a href=#document>Document</a></code> objects (in user agents implementing
this specification) <span class=impl>must</span> also implement
the <code><a href=#htmldocument>HTMLDocument</a></code> interface, available using
binding-specific methods. (This is the case whether or not the
document in question is an <a href=#html-documents title="HTML documents">HTML
document</a> or indeed whether it contains any <a href=#html-elements>HTML
elements</a> at all.) <code><a href=#document>Document</a></code> objects <span class=impl>must</span> also implement the document-level interface
of any other namespaces that the UA supports.</p>

<p class=example>For example, if an HTML implementation also
supports SVG, then the <code><a href=#document>Document</a></code> object implements both
<code><a href=#htmldocument>HTMLDocument</a></code> and <code>SVGDocument</code>.</p>

<p class=note>Because the <code><a href=#htmldocument>HTMLDocument</a></code> interface is
now obtained using binding-specific casting methods instead of
simply being the primary interface of the document object, it is no
longer defined as inheriting from <code><a href=#document>Document</a></code>.</p>

<pre class=idl>[OverrideBuiltins]
interface <dfn id=htmldocument>HTMLDocument</dfn> {
partial interface <a href=#document>Document</a> {
readonly attribute <code><a href=#document>Document</a></code> <a href=#htmldocument title=HTMLDocument>HTMLDocument</a>;

// <a href=#resource-metadata-management>resource metadata management</a>
[PutForwards=<a href=#dom-location-href title=dom-location-href>href</a>] readonly attribute <a href=#location>Location</a>? <a href=#dom-document-location title=dom-document-location>location</a>;
readonly attribute DOMString <a href=#dom-document-url title=dom-document-URL>URL</a>;
<!--CSSREF--> readonly attribute <a href=#domelementmap>DOMElementMap</a> <a href=#dom-document-csselementmap title=dom-document-cssElementMap>cssElementMap</a>;<!--CSSREF-->

// <a href=#dynamic-markup-insertion>dynamic markup insertion</a>
<a href=#htmldocument>HTMLDocument</a> <a href=#dom-document-open title=dom-document-open>open</a>(optional DOMString type, optional DOMString replace);
<a href=#document>Document</a> <a href=#dom-document-open title=dom-document-open>open</a>(optional DOMString type, optional DOMString replace);
<a href=#windowproxy>WindowProxy</a> <a href=#dom-document-open title=dom-document-open>open</a>(DOMString url, DOMString name, DOMString features, optional boolean replace);
void <a href=#dom-document-close title=dom-document-close>close</a>();
void <a href=#dom-document-write title=dom-document-write>write</a>(DOMString... text);

// special <a href=#event-handler-idl-attributes>event handler IDL attributes</a> that only apply to Document objects
[TreatNonCallableAsNull] attribute <a href=#function>Function</a>? <a href=#handler-onreadystatechange title=handler-onreadystatechange>onreadystatechange</a>;
};
<a href=#document>Document</a> implements <a href=#htmldocument>HTMLDocument</a>;</pre>
};</pre>

<p>Since the <code><a href=#htmldocument>HTMLDocument</a></code> interface holds methods and
attributes related to a number of disparate features, the members of
this interface are described in various different sections.</p>
<p>The <dfn id=htmldocument><code>HTMLDocument</code></dfn> IDL attribute must
return the <code><a href=#document>Document</a></code> object on which it is called.</p>


<h4 id=security-document><span class=secno>3.1.2 </span>Security</h4>
<ol><li><p>If the <a href=#root-element>root element</a> is an <code><a href=#svg>svg</a></code>
element in the "<code title="">http://www.w3.org/2000/svg</code>"
namespace, and the user agent supports SVG, then the setter must
defer to the setter for the IDL attribute of the same name on the
<code>SVGDocument</code> interface. Stop the algorithm here. <a href=#refsSVG>[SVG]</a></li>
act as if it was the setter for the IDL attribute of the same name
on the <code><a href=#document>Document</a></code> interface defined by the SVG
specification. Stop the algorithm here. <a href=#refsSVG>[SVG]</a></li>

<li>If <a href=#the-title-element-0>the <code>title</code> element</a> is null and
<a href=#the-head-element-0>the <code>head</code> element</a> is null, then the
<li>A single <code><a href=#text>Text</a></code> node whose data is the new value
being assigned must be appended to <var title="">element</var>.</li>

</ol><p>The <code title=dom-document-title><a href=#document.title>title</a></code> attribute on
the <code><a href=#htmldocument>HTMLDocument</a></code> interface should shadow the attribute
of the same name on the <code>SVGDocument</code> interface when the
user agent supports both HTML and SVG. <a href=#refsSVG>[SVG]</a></p>
</ol><p>The <code title=dom-document-title><a href=#document.title>title</a></code> IDL attribute
defined above must replace the attribute of the same name on the
<code><a href=#document>Document</a></code> interface defined by the SVG specification
when the user agent supports both HTML and SVG. <a href=#refsSVG>[SVG]</a></p>

</div>


<div class=impl>

<hr><p>The <code><a href=#htmldocument>HTMLDocument</a></code> interface <span title="support
<hr><p>The <code><a href=#document>Document</a></code> interface <span title="support
named properties">supports named properties</span>. The
<a href=#supported-property-names>supported property names</a> at any moment consist of the
values of the <code title=attr-name>name</code> content attributes
elements in the <code><a href=#document>Document</a></code> that have both <code title=attr-name>name</code> content attributes and <code title=attr-id><a href=#the-id-attribute>id</a></code> content attributes.</p>

<p>To <a href=#determine-the-value-of-a-named-property>determine the value of a named property</a> <var title="">name</var> when <dfn id=dom-document-nameditem title=dom-document-namedItem>the
<code>HTMLDocument</code> object is indexed for property
<code>Document</code> object is indexed for property
retrieval</dfn>, the user agent must return the value obtained using
the following steps:</p>

</div>

<hr><p class=note>The <code title=dom-document-dir><a href=#dom-document-dir>dir</a></code>
attribute on the <code><a href=#htmldocument>HTMLDocument</a></code> interface is defined
attribute on the <code><a href=#document>Document</a></code> interface is defined
along with the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> content
attribute.</p>

<a href=#limited-to-only-known-values>limited to only known values</a>.</p>

<p>The <dfn id=dom-document-dir title=dom-document-dir><code>dir</code></dfn> IDL
attribute on <code><a href=#htmldocument>HTMLDocument</a></code> objects must
attribute on <code><a href=#document>Document</a></code> objects must
<a href=#reflect>reflect</a> the <code title=attr-dir><a href=#the-dir-attribute>dir</a></code> content
attribute of <a href=#the-html-element-0>the <code>html</code> element</a>, if any,
<a href=#limited-to-only-known-values>limited to only known values</a>. If there is no such
tasks</a> or <a href=#completely-loaded>completely loaded</a>.</p>

<p>When called with three or more arguments, the <code title=dom-document-open><a href=#dom-document-open>open()</a></code> method on the
<code><a href=#htmldocument>HTMLDocument</a></code> object must call the <code title=dom-open><a href=#dom-open>open()</a></code> method on the <code><a href=#window>Window</a></code>
object of the <code><a href=#htmldocument>HTMLDocument</a></code> object, with the same
<code><a href=#document>Document</a></code> object must call the <code title=dom-open><a href=#dom-open>open()</a></code> method on the <code><a href=#window>Window</a></code>
object of the <code><a href=#document>Document</a></code> object, with the same
arguments as the original call to the <code title=dom-document-open><a href=#dom-document-open>open()</a></code> method, and return whatever
that method returned. If the <code><a href=#htmldocument>HTMLDocument</a></code> object has no
that method returned. If the <code><a href=#document>Document</a></code> object has no
<code><a href=#window>Window</a></code> object, then the method must throw an
<code><a href=#invalidaccesserror>InvalidAccessError</a></code> exception.</p>

</dl><div class=impl>

<p>The <dfn id=dom-document-commands title=dom-document-commands><code>commands</code></dfn> attribute
of the document's <code><a href=#htmldocument>HTMLDocument</a></code> interface must return an
of the document's <code><a href=#document>Document</a></code> interface must return an
<code><a href=#htmlcollection>HTMLCollection</a></code> rooted at the <code><a href=#document>Document</a></code>
node, whose filter matches only elements that <a href=#concept-command title=concept-command>define commands</a> and have <a href=#command-facet-id title=command-facet-ID>IDs</a>.</p>

context</a>'s <a href=#active-document>active document</a>.</p>

<p>The <dfn id=dom-document-defaultview title=dom-document-defaultView><code>defaultView</code></dfn> IDL
attribute of the <code><a href=#htmldocument>HTMLDocument</a></code> interface must return the
attribute of the <code><a href=#document>Document</a></code> interface must return the
<code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a>'s
<code><a href=#windowproxy>WindowProxy</a></code> object, if there is one, or null
otherwise.</p>
</dl><div class=impl>

<p>The <dfn id=dom-document-location title=dom-document-location><code>location</code></dfn> attribute
of the <code><a href=#htmldocument>HTMLDocument</a></code> interface must return the
of the <code><a href=#document>Document</a></code> interface must return the
<code><a href=#location>Location</a></code> object for that <code><a href=#document>Document</a></code> object,
if it is in a <a href=#browsing-context>browsing context</a>, and null otherwise.</p>

</table><p class=note>The <code title=handler-window-onerror><a href=#handler-window-onerror>onerror</a></code>
handler is also used for <a href=#runtime-script-errors>reporting script errors</a>.</p>

<hr><!-- this guy is only on HTMLDocument and not on HTMLElement because
<hr><!-- this guy is only on Document and not on HTMLElement because
otherwise HTMLScriptElement would have it and that causes
compatibility issues since IE fires readystatechange events on
<script>, not load events, and we can't fire both, and some sites
</dl><div class=impl>

<p>The <dfn id=dom-document-activeelement title=dom-document-activeElement><code>activeElement</code></dfn>
attribute on <code><a href=#htmldocument>HTMLDocument</a></code> objects must return the
attribute on <code><a href=#document>Document</a></code> objects must return the
element in the document that is focused. If no element in the
<code><a href=#document>Document</a></code> is focused, this must return <a href=#the-body-element-0>the body
element</a>.</p>

<p>The <dfn id=dom-document-hasfocus title=dom-document-hasFocus><code>hasFocus()</code></dfn> method
on <code><a href=#htmldocument>HTMLDocument</a></code> objects must return true if the
on <code><a href=#document>Document</a></code> objects must return true if the
<code><a href=#document>Document</a></code>'s <a href=#browsing-context>browsing context</a> is focused,
and all its <a href=#ancestor-browsing-context title="ancestor browsing context">ancestor
browsing contexts</a> are also focused, and the <a href=#top-level-browsing-context>top-level
spec, albeit as obsolete, and then we say that only elements not
defined in this spec use HTMLUnknownElement. -->

<hr><pre class=idl>partial interface <a href=#htmldocument>HTMLDocument</a> {
<hr><pre class=idl>partial interface <a href=#document>Document</a> {
[TreatNullAs=EmptyString] attribute DOMString <a href=#dom-document-fgcolor title=dom-document-fgColor>fgColor</a>;
[TreatNullAs=EmptyString] attribute DOMString <a href=#dom-document-linkcolor title=dom-document-linkColor>linkColor</a>;
[TreatNullAs=EmptyString] attribute DOMString <a href=#dom-document-vlinkcolor title=dom-document-vlinkColor>vlinkColor</a>;
library.onload = function() {
var sound1 = library.getAudio("sound1.wav"); // returns an Audio object
var image1 = library.getImage("image1.png"); // returns an HTMLImageElement
var doc1 = library.getXMLDocument("doc1.xml"); // returns a Document
var doc2 = library.getHTMLDocument("doc1.html"); // returns an HTMLDocument
var doc1 = library.getXMLDocument("doc1.xml"); // returns a Document (XML Document mode)
var doc2 = library.getHTMLDocument("doc1.html"); // returns a Document (HTML Document mode)
}
or:
var library = new ResourceLoader("data.zip");

0 comments on commit 83f13ee

Please sign in to comment.
You can’t perform that action at this time.