Skip to content

Commit

Permalink
the body element and document.body
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.whatwg.org/webapps@164 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Oct 20, 2006
1 parent ccbfde6 commit 4bcd8ad
Show file tree
Hide file tree
Showing 2 changed files with 163 additions and 130 deletions.
177 changes: 95 additions & 82 deletions index
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
readonly attribute DOMString <a href="#referrer" title=dom-document-referrer>referrer</a>;
attribute DOMString <a href="#domain1" title=dom-document-domain>domain</a>;
readonly attribute DOMString <a href="#url" title=dom-document-URL>URL</a>;
attribute <a href="#htmlelement">HTMLElement</a> <span title=dom-document-body>body</span>;
attribute <a href="#htmlelement">HTMLElement</a> <a href="#body0" title=dom-document-body>body</a>;
readonly attribute <a href="#htmlcollection0">HTMLCollection</a> <span title=dom-document-images>images</span>;
<!-- readonly attribute <span>HTMLCollection</span> <span title="dom-document-applets">applets</span>;
--> readonly attribute <a href="#htmlcollection0">HTMLCollection</a> <span title=dom-document-links>links</span>;
Expand Down Expand Up @@ -2290,28 +2290,13 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
of <a href="#the-head0">the <code>head</code> element</a>, if there is
one, or null otherwise.

<p><dfn id=the-body0>The <code>body</code> element</dfn> of a document is
the first <code><a href="#body0">body</a></code> element that is a child
of <a href="#the-html0">the <code>html</code> element</a>, if there is
one, or null otherwise. If the <code><a href="#body0">body</a></code>
element is null, then the <code>Document</code> object is "the <code><a
href="#body0">body</a></code> element" for the purposes of event
targetting (i.e. if an event is to be fired "on <a href="#the-body0">the
<code>body</code> element</a>" when there isn't one, then the event will
instead be fired on the <code>Document</code> object).

<p class=big-issue>document.body needs to point to the first
<code>frameset</code> in framed pages (maybe?). also note that d.body is
mutable; it replaces the current one or adds one if there isn't one. only
works for body and frameset elements.</p>
<!--
http://lxr.mozilla.org/seamonkey/source/content/html/document/src/nsHTMLDocument.cpp
search for ::GetBody ::SetBody
http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLDocument.cpp
search for ::setBody
http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/dom/Document.cpp
search for ::body
-->
<p><dfn id=the-body0>the body element</dfn> of a document is the first
child of <a href="#the-html0">the <code>html</code> element</a> that is
either a <code><a href="#body1">body</a></code> element or a
<code>frameset</code> element. If there is no such element, it is null. If
the body element is null, then when the specification requires that events
be fired at "the body element", they must instead be fired at the
<code>Document</code> object.

<p>The <dfn id=document.title
title=dom-document-title><code>title</code></dfn> attribute must, on
Expand Down Expand Up @@ -2370,19 +2355,52 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
href="#domain1">domain</a></code> attribute is used to enable pages on
different hosts of a domain to access each others' DOMs.</p>
<!-- XXX xref -->
<!--
<!--XXX
http://lxr.mozilla.org/seamonkey/source/content/html/document/src/nsHTMLDocument.cpp
search for ::GetDomain ::SetDomain
http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/dom/Document.cpp
search for ::domain ::setDomain
-->

<p>The <dfn id=url title=dom-document-URL><code>URL</code></dfn> attribute
must return the <span>the document's address</span><!-- XXX xref -->.
must return the <span>the document's address</span><!--
XXX xref -->.

<p>The <dfn id=body0 title=dom-document-body><code>body</code></dfn>
attribute, on getting, must return <a href="#the-body0">the body
element</a> of the document (either a <code><a
href="#body1">body</a></code> element, a <code>frameset</code> element, or
null). On setting, the following algorithm must be followed:

<ol>
<li>If the new value is not a <code><a href="#body1">body</a></code> or
<code>frameset</code> element, then raise a
<code>HIERARCHY_REQUEST_ERR</code> exception and abort these steps.

<li>Otherwise, if the new value is the same as <a href="#the-body0">the
body element</a>, do nothing. Abort these steps.

<li>Otherwise, if <a href="#the-body0">the body element</a> is not null,
then replace that element with the new value in the DOM, as if the root
element's <code title="">replaceChild()</code> method had been called
with the new value and <a href="#the-body0" title="the body element">the
incumbent body element</a> as its two arguments respectively, then abort
these steps.

<li>Otherwise, the <a href="#the-body0">the body element</a> is null.
Append the new value to the root element.
</ol>
<!--XXX
http://lxr.mozilla.org/seamonkey/source/content/html/document/src/nsHTMLDocument.cpp
search for ::GetBody ::SetBody
http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/html/HTMLDocument.cpp
search for ::setBody
http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/dom/Document.cpp
search for ::body
-->

<p class=big-issue>Need to define the remaining members.</p>
<!--
attribute <span>HTMLElement</span> <span title="dom-document-body">body</span>;
readonly attribute <span>HTMLCollection</span> <span title="dom-document-images">images</span>;
readonly attribute <span>HTMLCollection</span> <span title="dom-document-links">links</span>;
readonly attribute <span>HTMLCollection</span> <span title="dom-document-forms">forms</span>;
Expand Down Expand Up @@ -3384,7 +3402,7 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
</ul>

<p>There are also elements that seem to be block-level but aren't, such as
<code><a href="#body0">body</a></code>, <code><a
<code><a href="#body1">body</a></code>, <code><a
href="#li0">li</a></code>, <code><a href="#dt0">dt</a></code>, <code><a
href="#dd0">dd</a></code>, and <code>td</code>. These elements are allowed
only in specific places, not simply anywhere that block-level elements are
Expand Down Expand Up @@ -3820,7 +3838,7 @@ should the click, focus, blur methods be recursible?
<dt>Content model:

<dd>A <code><a href="#head0">head</a></code> element followed by a
<code><a href="#body0">body</a></code> element.</dd>
<code><a href="#body1">body</a></code> element.</dd>
<!--XXX
Steven Pemberton was as always, a remarkable speaker, but his answer
to my question leaves me a very bad taste. Basically, I asked him why
Expand Down Expand Up @@ -4542,7 +4560,7 @@ class="main"> or <div class="content">. Why do we also need a body?
defined in the processing models section of this specification.

<h4 id=the-body><span class=secno>3.5.1. </span>The <dfn
id=body0><code>body</code></dfn> element</h4>
id=body1><code>body</code></dfn> element</h4>

<p><a href="#sectioning" title="sectioning elements">Sectioning
element</a>.
Expand All @@ -4567,24 +4585,24 @@ class="main"> or <div class="content">. Why do we also need a body?
href="#htmlelement">HTMLElement</a></code>.
</dl>

<p>The <code><a href="#body0">body</a></code> element represents the main
<p>The <code><a href="#body1">body</a></code> element represents the main
content of the document.

<p>The <code><a href="#body0">body</a></code> element potentially has a
<p>The <code><a href="#body1">body</a></code> element potentially has a
heading. See the section on <a href="#headings1">headings and sections</a>
for further details.

<p>In conforming documents, there is only one <code><a
href="#body0">body</a></code> element. The <code
title=dom-document-body>document.body</code> DOM attribute provides
scripts with easy access to a document's <code><a
href="#body0">body</a></code> element.
href="#body1">body</a></code> element. The <code
title=dom-document-body><a href="#body0">document.body</a></code> DOM
attribute provides scripts with easy access to a document's <code><a
href="#body1">body</a></code> element.

<p class=note>Some DOM operations (for example, parts of the <a
href="#drag-and0">drag and drop</a> model) are defined in terms of "<a
href="#the-body0">the <code>body</code> element</a>". This refers to a
particular element in the DOM, as per the definition of the term, and not
any arbitrary <code><a href="#body0">body</a></code> element.
href="#the-body0">the body element</a>". This refers to a particular
element in the DOM, as per the definition of the term, and not any
arbitrary <code><a href="#body1">body</a></code> element.

<h4 id=the-section><span class=secno>3.5.2. </span>The <dfn
id=section3><code>section</code></dfn> element</h4>
Expand Down Expand Up @@ -4702,7 +4720,7 @@ XXX attributes to give the date authored, date published
"independent" in that its contents could stand alone, for example in
syndication. However, the element is still associated with its ancestors;
for instance, contact information that <a href="#applyTo">applies</a> to a
parent <code><a href="#body0">body</a></code> element still covers the
parent <code><a href="#body1">body</a></code> element still covers the
<code><a href="#article0">article</a></code> as well.

<p>When <code><a href="#article0">article</a></code> elements are nested,
Expand Down Expand Up @@ -5104,17 +5122,17 @@ XXX attributes to give the date authored, date published
would be included with other information in a <code><a
href="#footer0">footer</a></code> element.

<p>To determine the contact information for a sectioning element (such as
<a href="#the-body0">the <code>body</code> element</a>, which would give
the contact information for the page), UAs must collect all the <code><a
href="#address0">address</a></code> elements that <a
<p>To determine the contact information for a sectioning element (such as a
document's <code><a href="#body1">body</a></code> element, which would
give the contact information for the page), UAs must collect all the
<code><a href="#address0">address</a></code> elements that <a
href="#applyToSection">apply</a> to that sectioning element and its
ancestor sectioning elements. The contact information is the collection of
all the information given by those elements.

<p class=note>Contact information for one sectioning element, e.g. a
<code><a href="#aside0">aside</a></code> element, does not apply to its
ancestor elements, e.g. the page's <code><a href="#body0">body</a></code>.
ancestor elements, e.g. the page's <code><a href="#body1">body</a></code>.

<h3 id=paragraphs><span class=secno>3.6. </span>Paragraphs</h3>

Expand Down Expand Up @@ -11259,7 +11277,7 @@ XXX selection ranges -->
<p>...the structure would be:</p>

<ol>
<li> Foo (heading of explicit <code><a href="#body0">body</a></code>
<li> Foo (heading of explicit <code><a href="#body1">body</a></code>
section)
<ol>
<li> Bar (heading starting implied section)
Expand Down Expand Up @@ -11409,7 +11427,7 @@ XXX selection ranges -->

<p class=example>Selecting the first section of the document therefore
always takes the user to the top of the document, regardless of where the
first header in the <code><a href="#body0">body</a></code> is to be found.</p>
first header in the <code><a href="#body1">body</a></code> is to be found.</p>
<!-- XXX assuming there is a body, anyway -->

<div class=note>
Expand Down Expand Up @@ -12753,7 +12771,7 @@ XXX selection ranges -->
in the cases described above), the user agent must fire a <dfn id=popstate
title=event-popstate><code>popstate</code></dfn> event in the
<code>http://www.w3.org/2001/xml-events</code> namespace on the <a
href="#the-body0">the <code>body</code> element</a> using the <code><a
href="#the-body0">the body element</a> using the <code><a
href="#popstateevent">PopStateEvent</a></code> interface, with the state
object in the <code title=dom-PopStateEvent-state><a
href="#state0">state</a></code> attribute. This event bubbles but is not
Expand Down Expand Up @@ -12975,8 +12993,8 @@ user reload must be equivalent to .reload()
<p>These events are in the <code>http://www.w3.org/2001/xml-events</code>
namespace, do bubble, are not cancelable, have no default action, and use
the normal <code>Event</code> interface. They must be fired on <a
href="#the-body0">the <code>body</code> element</a>. (As the events
bubble, they will reach the <code>Window</code> object.)</p>
href="#the-body0">the body element</a>. (As the events bubble, they will
reach the <code>Window</code> object.)</p>
<!-- XXX ononline onoffline need to be defined -->

<h4 id=custom-handlers><span class=secno>5.2.2. </span><a href="#scs"
Expand Down Expand Up @@ -13930,7 +13948,7 @@ http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSPr
<td><dfn id=dragenter title=event-dragenter><code>dragenter</code></dfn>

<td><a href="#immediate">Immediate user selection</a> or <a
href="#the-body0">the <code>body</code> element</a>
href="#the-body0">the body element</a>

<td>&#x2713; Bubbles

Expand Down Expand Up @@ -14300,17 +14318,16 @@ http://developer.apple.com/documentation/AppleApplications/Conceptual/SafariJSPr

<li>
<p>Otherwise, if the <a href="#current0">current target element</a>
is not <a href="#the-body0">the <code>body</code> element</a>, the
user agent must fire a <code title=event-dragenter><a
is not <a href="#the-body0">the body element</a>, the user agent
must fire a <code title=event-dragenter><a
href="#dragenter">dragenter</a></code> event at <a
href="#the-body0">the <code>body</code> element</a>, and the <a
href="#the-body0">the body element</a>, and the <a
href="#current0">current target element</a> must be set to <a
href="#the-body0">the <code>body</code> element</a>, regardless of
whether that event was canceled or not. (If <a href="#the-body0">the
<code>body</code> element</a> is null, then the <a
href="#current0">current target element</a> would be set to null too
in this case, it wouldn't be set to the <code>Document</code>
object.)</p>
href="#the-body0">the body element</a>, regardless of whether that
event was canceled or not. (If <a href="#the-body0">the body
element</a> is null, then the <a href="#current0">current target
element</a> would be set to null too in this case, it wouldn't be
set to the <code>Document</code> object.)</p>
</ol>

<li>
Expand Down Expand Up @@ -16062,8 +16079,7 @@ interface <dfn id=storageitem>StorageItem</dfn> {
in the <code>http://www.w3.org/2001/xml-events</code> namespace, which
bubbles, is not cancelable, has no default action, and which uses the
<code><a href="#storageevent">StorageEvent</a></code> interface described
below, must be fired on <a href="#the-body0">the <code>body</code>
element</a>.
below, must be fired on <a href="#the-body0">the body element</a>.

<p>However, it is possible (indeed, for session storage areas, likely) that
the target <code><a href="#htmldocument">HTMLDocument</a></code> object is
Expand Down Expand Up @@ -20611,7 +20627,7 @@ function receiver(e) {
<code><a href="#base0">base</a></code>, <code>basefont</code>,
<code>bgsound</code>, <code><a
href="#blockquote0">blockquote</a></code>, <code><a
href="#body0">body</a></code>, <code><a href="#br0">br</a></code>,
href="#body1">body</a></code>, <code><a href="#br0">br</a></code>,
<code>center</code>, <code>col</code>, <code>colgroup</code>, <code><a
href="#dd0">dd</a></code>, <code><a href="#dir">dir</a></code>,
<code>div</code>, <code><a href="#dl0">dl</a></code>, <code><a
Expand Down Expand Up @@ -20973,7 +20989,7 @@ function receiver(e) {
case</a>)

<li>If <var title="">node</var> is a <code><a
href="#body0">body</a></code> element, then switch the <a
href="#body1">body</a></code> element, then switch the <a
href="#insertion0">insertion mode</a> to "<a href="#in-body"
title="insertion mode: in body">in body</a>" and abort these steps.

Expand Down Expand Up @@ -21034,23 +21050,20 @@ simplified explanation instead:
mode</span> to "<span title="insertion mode: in caption">in
caption</span>".</p></li>

<!-- you can't reach this point with a colgroup element on the
stack -->
( you can't reach this point with a colgroup element on the
stack )

<ul>
<li>
<p>Otherwise, if the <a href="#stack">stack of open elements</a> <a
href="#have-an0" title="has an element in table scope">has a
<code>table</code> element in table scope</a>, then switch the <a
href="#insertion0">insertion mode</a> to "<a href="#in-table"
title="insertion mode: in table">in table</a>".
<li><p>Otherwise, if the <span>stack of open elements</span> <span
title="has an element in table scope">has a <code>table</code>
element in table scope</span>, then switch the <span>insertion
mode</span> to "<span title="insertion mode: in table">in
table</span>".</p></li>

<li>
<p>Otherwise, switch the <a href="#insertion0">insertion mode</a> to "<a
href="#in-body" title="insertion mode: in body">in body</a>".
</ul>
<li><p>Otherwise, switch the <span>insertion mode</span> to "<span
title="insertion mode: in body">in body</span>".</p></li>

<p>-->
</ol>
-->

<h6 id=how-to0><span class=secno>8.2.4.3.7. </span>How to handle tokens in
the main phase</h6>
Expand Down Expand Up @@ -21085,7 +21098,7 @@ simplified explanation instead:
title=dom-innerHTML-HTML><a href="#innerhtml">innerHTML</a></code>
attribute (<a href="#innerhtml0"><code>innerHTML</code> case</a>) and
the second node on the <a href="#stack">stack of open elements</a> is
not a <code><a href="#body0">body</a></code> node, this is a <a
not a <code><a href="#body1">body</a></code> node, this is a <a
href="#parse">parse error</a>.</p>

<p><a href="#stop-">Stop parsing.</a></p>
Expand Down Expand Up @@ -21568,29 +21581,29 @@ simplified explanation instead:
<p><a href="#parse">Parse error</a>.</p>

<p>If the second element on the <a href="#stack">stack of open
elements</a> is not a <code><a href="#body0">body</a></code>
elements</a> is not a <code><a href="#body1">body</a></code>
element, or, if the <a href="#stack">stack of open elements</a> has
only one node on it, then ignore the token. (<a
href="#innerhtml0"><code>innerHTML</code> case</a>)</p>

<p>Otherwise, for each attribute on the token, check to see if the
attribute is already present on the <code><a
href="#body0">body</a></code> element (the second element) on the <a
href="#body1">body</a></code> element (the second element) on the <a
href="#stack">stack of open elements</a>. If it is not, add the
attribute and its corresponding value to that element.</p>

<dt>An end tag with the tag name "body"

<dd>
<p>If the second element in the <a href="#stack">stack of open
elements</a> is not a <code><a href="#body0">body</a></code>
elements</a> is not a <code><a href="#body1">body</a></code>
element, this is a <a href="#parse">parse error</a>. Ignore the
token. (<a href="#innerhtml0"><code>innerHTML</code> case</a>)</p>

<p>Otherwise:</p>

<p>If the <a href="#current3">current node</a> is not the <code><a
href="#body0">body</a></code> element, then this is a <a
href="#body1">body</a></code> element, then this is a <a
href="#parse">parse error</a>.</p>

<p>Change the <a href="#insertion0">insertion mode</a> to "<a
Expand Down
Loading

0 comments on commit 4bcd8ad

Please sign in to comment.