Skip to content

Commit

Permalink
Make Window and Document named/indexed properties exclude shadow trees
Browse files Browse the repository at this point in the history
Per discussion in WICG/webcomponents#145 and
WICG/webcomponents#536, elements in shadow
trees should not contribute to the named properties of Window and
Document objects, and should not contribute to the indexed properties of
Window objects. This makes that very clear, by using "in a document
tree" appropriately and defining "document-tree child browsing context"
for use in the Window case.

Fixes WICG/webcomponents#145. Fixes WICG/webcomponents#536.
  • Loading branch information
domenic authored and Alice Boxhall committed Jan 7, 2019
1 parent b9ea633 commit 084405b
Showing 1 changed file with 102 additions and 83 deletions.
185 changes: 102 additions & 83 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -9307,27 +9307,29 @@ partial /*sealed*/ interface <dfn>Document</dfn> {
<hr>

<p id="dom-document-namedItem-which">The <code>Document</code> interface <span data-x="support
named properties">supports named properties</span>. The <span>supported property names</span> at
any moment consist of the values of the <code data-x="">name</code> content attributes of
all the
<code>applet</code>,
<span>exposed</span> <code>embed</code>,
<code>form</code>,
<code>iframe</code>,
<code>img</code>, and
<span>exposed</span> <code>object</code>
elements in the <code>Document</code> that have non-empty <code data-x="">name</code> content
attributes, and the values of the <code data-x="attr-id">id</code> content attributes of all the
<code>applet</code> and
<span>exposed</span> <code>object</code>
elements in the <code>Document</code> that have non-empty <code data-x="attr-id">id</code> content
attributes, and the values of the <code data-x="attr-id">id</code> content attributes of all the
<code>img</code>
elements in the <code>Document</code> that have both non-empty <code data-x="">name</code> content
attributes and non-empty <code data-x="attr-id">id</code> content attributes. The <span>supported
property names</span> must be in <span>tree order</span>, ignoring later duplicates, with values
from <code data-x="attr-id">id</code> attributes coming before values from <code
data-x="">name</code> attributes when the same element contributes both.</p>
named properties">supports named properties</span>. The <span>supported property names</span> of a
<code>Document</code> object <var>document</var> at any moment consist of the following, in
<span>tree order</span> according to the element that contributed them, ignoring later duplicates,
and with values from <code data-x="attr-id">id</code> attributes coming before values from <code
data-x="">name</code> attributes when the same element contributes both:</p>

<ul>
<li><p>the value of the <code data-x="">name</code> content attribute for all <code>applet</code>,
<span>exposed</span> <code>embed</code>, <code>form</code>, <code>iframe</code>,
<code>img</code>, and <span>exposed</span> <code>object</code> elements that have a non-empty
<code data-x="">name</code> content attribute and are <span>in a document tree</span> with
<var>document</var> as their <span>root</span>;<p></li>

<li><p>the value of the <code data-x="attr-id">id</code> content attribute for all
<code>applet</code> and <span>exposed</span> <code>object</code> elements that have a non-empty
<code data-x="attr-id">id</code> content attribute and are <span>in a document tree</span> with
<var>document</var> as their <span>root</span>; and</p></li>

<li><p>the value of the <code data-x="attr-id">id</code> content attribute for all
<code>img</code> elements that have both a non-empty <code data-x="attr-id">id</code> content
attribute and a non-empty <code data-x="">name</code> content attribute, and are <span>in a
document tree</span> with <var>document</var> as their <span>root</span>.</p></li>
</ul>

<p id="dom-document-nameditem">To <span>determine the value of a named property</span>
<var>name</var> for a <code>Document</code>, the user agent must return the value obtained using
Expand All @@ -9337,8 +9339,9 @@ partial /*sealed*/ interface <dfn>Document</dfn> {

<li>

<p>Let <var>elements</var> be the list of <span
data-x="dom-document-namedItem-filter">named elements</span> with the name <var>name</var> in the <code>Document</code>.
<p>Let <var>elements</var> be the list of <span data-x="dom-document-namedItem-filter">named
elements</span> with the name <var>name</var> that are <span>in a document tree</span> with the
<code>Document</code> as their <span>root</span>.</p>

<p class="note">There will be at least one such element, by definition.<!-- (If there wasn't,
then this algorithm wouldn't have been invoked by Web IDL.) --></p>
Expand Down Expand Up @@ -77139,6 +77142,11 @@ dictionary <dfn>DragEventInit</dfn> : <span>MouseEventInit</span> {
data-x="concept-document-bc">browsing context</span> is <var>parent</var></p></li>
</ul>

<p>A <span>browsing context</span> <var>child</var> is then a <dfn>document-tree child browsing
context</dfn> of <var>parent</var> if it is a <span>child browsing context</span> and its
<span>browsing context container</span> is not just <span>connected</span>, but also <span>in a
document tree</span>.</p>

<p>A <span>browsing context</span> <var>child</var> may have a <dfn>parent browsing context</dfn>.
This is the unique <span>browsing context</span> that has <var>child</var> as a <span>child
browsing context</span>, if any such browsing context exists. Otherwise, the <span>browsing
Expand Down Expand Up @@ -78030,8 +78038,8 @@ console.assert(iframeWindow.frameElement === null);
{ [[Property]]: "<code data-x="">postMessage</code>" } ».</p></li>

<li>
<p>Repeat for each <var>e</var> that is an element of <var>O</var>'s <span>child browsing
context name property set</span>:</p>
<p>Repeat for each <var>e</var> that is an element of <var>O</var>'s <span>document-tree child
browsing context name property set</span>:</p>

<ol>
<li><p>Add { [[Property]]: <var>e</var> } as the last element of
Expand Down Expand Up @@ -78583,35 +78591,35 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<dd>

<p>Returns the number of <span data-x="child browsing context">child browsing
contexts</span>.</p>
<p>Returns the number of <span data-x="document-tree child browsing
context">document-tree child browsing contexts</span>.</p>

</dd>

<dt><var>window</var>[<var>index</var>]</dt>

<dd>

<p>Returns the indicated <span>child browsing context</span>.</p>
<p>Returns the indicated <span>document-tree child browsing context</span>.</p>

</dd>

</dl>

<div w-nodev>

<p>The <dfn>number of child browsing contexts</dfn> of a <code>Window</code> object <var>W</var>
is the number of <span data-x="child browsing context">child browsing contexts</span> that are
<span data-x="browsing context nested through">nested through</span> elements that are <span>in a
document</span> that is the <span>active document</span> of the <code>Window</code> object's <span
data-x="concept-document-window">associated <code>Document</code></span>'s <span
data-x="concept-document-bc">browsing context</span>.</p>
<p id="number-of-child-browsing-contexts">The <dfn>number of document-tree child browsing
contexts</dfn> of a <code>Window</code> object <var>W</var> is the number of <span
data-x="document-tree child browsing context">document-tree child browsing contexts</span> of
<var>W</var>'s <span data-x="concept-document-window">associated <code>Document</code></span>'s
<span data-x="concept-document-bc">browsing context</span>.</p>

<p>The <dfn><code data-x="dom-length">length</code></dfn> IDL attribute's getter must return the
<span>number of child browsing contexts</span> of this <code>Window</code> object.</p>
<span>number of document-tree child browsing contexts</span> of this <code>Window</code>
object.</p>

<p class="note">Indexed access to <span data-x="child browsing context">child browsing
contexts</span> is defined through the <a
<p class="note">Indexed access to <span data-x="document-tree child browsing
context">document-tree child browsing contexts</span> is defined through the <a
href="#windowproxy-getownproperty">[[GetOwnProperty]]</a> internal method of the
<code>WindowProxy</code> object.</p>

Expand Down Expand Up @@ -78640,23 +78648,26 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<div w-nodev>

<p>The <dfn>child browsing context name property set</dfn> of a <code>Window</code> object
<var>window</var> is the return value of running these steps:</p>
<p id="child-browsing-context-name-property-set">The <dfn>document-tree child browsing context
name property set</dfn> of a <code>Window</code> object <var>window</var> is the return value of
running these steps:</p>

<ol>
<li><p>Let <var>activeDocument</var> be <var>window</var>'s <span>browsing context</span>'s
<span>active document</span>.</p></li>

<li><p>Let <var>childBrowsingContexts</var> be all <span data-x="child browsing context">child
browsing contexts</span> of <var>activeDocument</var> whose <span>browsing context name</span> is
not the empty string, in order, and including only the first <span>child browsing context</span>
with a given <span data-x="browsing context name">name</span> if multiple <span data-x="child
browsing context">child browsing contexts</span> have the same one.</p></li>
<li><p>Let <var>childBrowsingContexts</var> be all <span data-x="document-tree child browsing
context">document-tree child browsing contexts</span> of <var>activeDocument</var>'s <span
data-x="concept-document-bc">browsing context</span> whose <span>browsing context name</span> is
not the empty string, in order, and including only the first <span>document-tree child browsing
context</span> with a given <span data-x="browsing context name">name</span> if multiple <span
data-x="document-tree child browsing context">document-tree child browsing contexts</span> have
the same one.</p></li>

<li><p>Remove each <span>child browsing context</span> from <var>childBrowsingContexts</var>
whose <span>active document</span>'s <span>origin</span> is not <span>same origin</span> with
<li><p>Remove each <span>browsing context</span> from <var>childBrowsingContexts</var> whose
<span>active document</span>'s <span>origin</span> is not <span>same origin</span> with
<var>activeDocument</var>'s <span>origin</span> and whose <span>browsing context name</span> does
not match the name of their <span>browsing context container</span>'s <code data-x="">name</code>
not match the name of its <span>browsing context container</span>'s <code data-x="">name</code>
content attribute value.</p></li>

<li><p>Return the <span data-x="browsing context name">browsing context names</span> of
Expand All @@ -78675,21 +78686,24 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<p>The <code>Window</code> object <span data-x="support named properties">supports named
properties</span>. The <span>supported property names</span> of a <code>Window</code> object
<var>window</var> at any moment consist of the following, in <span>tree order</span>, ignoring
later duplicates:</p>
<var>window</var> at any moment consist of the following, in <span>tree order</span> according to
the element that contributed them, ignoring later duplicates:</p>

<ul>
<li><var>window</var>'s <span>child browsing context name property set</span>,</li>
<li><p><var>window</var>'s <span>document-tree child browsing context name property
set</span>;</p></li>

<li>the value of the <code data-x="">name</code> content attribute for all <code>a</code>,
<li><p>the value of the <code data-x="">name</code> content attribute for all <code>a</code>,
<code>applet</code>, <code>area</code>, <code>embed</code>, <code>form</code>,
<code>frameset</code>, <code>img</code>, and <code>object</code> elements in <var>window</var>'s
<span>browsing context</span>'s <span>active document</span> that have a non-empty <code
data-x="">name</code> content attribute, and</li>

<li>the value of the <code data-x="attr-id">id</code> content attribute of any <span data-x="HTML
elements">HTML element</span> in <var>window</var>'s <span>browsing context</span>'s <span>active
document</span> with a non-empty <code data-x="attr-id">id</code> content attribute.</li>
<code>frameset</code>, <code>img</code>, and <code>object</code> elements that have a non-empty
<code data-x="">name</code> content attribute and are <span>in a document tree</span> with
<var>window</var>'s <span>browsing context</span>'s <span>active document</span> as their
<span>root</span>; and</p></li>

<li><p>the value of the <code data-x="attr-id">id</code> content attribute for all <span>HTML
elements</span> that have a non-empty <code data-x="attr-id">id</code> content attribute and are
<span>in a document tree</span> with <var>window</var>'s <span>browsing context</span>'s
<span>active document</span> as their <span>root</span>.</p></li>
</ul>

<p id="dom-window-nameditem">To <span>determine the value of a named property</span>
Expand All @@ -78702,9 +78716,8 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<li>

<p>Let <var>objects</var> be the list of <span
data-x="dom-window-namedItem-filter">named objects</span> with the name <var>name</var>
in the <span>active document</span>.
<p>Let <var>objects</var> be the list of <span data-x="dom-window-namedItem-filter">named
objects</span> with the name <var>name</var>.</p>

<p class="note">There will be at least one such object, by definition.<!-- (If there wasn't,
then this algorithm wouldn't have been invoked by Web IDL.) --></p>
Expand Down Expand Up @@ -78738,19 +78751,23 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

</ol>

<p><dfn data-x="dom-window-nameditem-filter">Named objects</dfn> with the name <var>name</var>, for the purposes of the above algorithm, are those that are either:</p>
<p><dfn data-x="dom-window-nameditem-filter">Named objects</dfn> with the name <var>name</var>,
for the purposes of the above algorithm, consist of the following:</p>

<ul>

<li><span data-x="child browsing context">child browsing contexts</span> of the <span>active
document</span> whose name is <var>name</var>,</li>
<li><p><span data-x="document-tree child browsing context">document-tree child browsing
contexts</span> of the <span>active document</span> whose name is <var>name</var>;</p></li>

<li><code>a</code>, <code>applet</code>, <code>area</code>, <code>embed</code>,
<li><p><code>a</code>, <code>applet</code>, <code>area</code>, <code>embed</code>,
<code>form</code>, <code>frameset</code>, <code>img</code>, or <code>object</code> elements that
have a <code data-x="">name</code> content attribute whose value is <var>name</var>, or</li>
have a <code data-x="">name</code> content attribute whose value is <var>name</var> and are
<span>in a document tree</span> with the <span>active document</span> as their
<span>root</span>; and</p></li>

<li><span>HTML elements</span> that have an <code data-x="attr-id">id</code> content attribute
whose value is <var>name</var>.</li>
<li><p><span>HTML elements</span> that have an <code data-x="attr-id">id</code> content attribute
whose value is <var>name</var> and are <span>in a document tree</span> with the <span>active
document</span> as their <span>root</span>.</p></li>

</ul>

Expand Down Expand Up @@ -79062,24 +79079,26 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
<ol>
<li><p>Let <var>index</var> be <span>ToUint32</span>(<var>P</var>).</p></li>

<li><p>Let <var>maxProperties</var> be the <span>number of child browsing contexts</span> of
<var>W</var>.
<li><p>Let <var>maxProperties</var> be the <span>number of document-tree child browsing
contexts</span> of <var>W</var>.</p></li>

<li><p>Let <var>value</var> be undefined.
<li><p>Let <var>value</var> be undefined.</p></li>

<li>
<p>If <var>maxProperties</var> is greater than 0 and <var>index</var> is less than
<var>maxProperties</var>, then:
<var>maxProperties</var>, then:</p>

<ol>
<li><p>Let <var>document</var> be <var>W</var>'s <span
data-x="concept-document-window">associated <code>Document</code></span>.</p></li>

<li><p>Set <var>value</var> to the <code>WindowProxy</code> object of the <var>index</var>th
<span>child browsing context</span> of the <code>Document</code> that is <span
data-x="browsing context nested through">nested through</span> an element that is <span
data-x="in a document">in <var>W</var>'s <code>Document</code></span>, sorted in the order
that the elements nesting those <span data-x="browsing context">browsing contexts</span> were
most recently inserted into the <code>Document</code>, the <code>WindowProxy</code> object of
the most recently inserted <span>browsing context container</span>'s <span>nested browsing
context</span> being last.</p></li>
<span>document-tree child browsing context</span> of <var>document</var>'s <span
data-x="concept-document-bc">browsing context</span>, sorted in the order
that their <span data-x="browsing context container">browsing context container</span>
elements were most recently inserted into <var>document</var>, the
<code>WindowProxy</code> object of the most recently inserted <span>browsing context
container</span>'s <span>nested browsing context</span> being last.</p></li>
<!-- sort order: http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2860 -->
</ol>

Expand All @@ -79105,8 +79124,8 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span
<li><p>If <var>property</var> is not undefined, return <var>property</var>.</p></li>

<li>
<p>If <var>property</var> is undefined and <var>P</var> is in <var>W</var>'s <span>child
browsing context name property set</span>, then:</p>
<p>If <var>property</var> is undefined and <var>P</var> is in <var>W</var>'s <span>document-tree
child browsing context name property set</span>, then:</p>

<ol>
<li><p>Let <var>value</var> be the <code>WindowProxy</code> object of the
Expand Down Expand Up @@ -79196,8 +79215,8 @@ callback <dfn>FrameRequestCallback</dfn> = void (<span>DOMHighResTimeStamp</span

<li><p>Let <var>keys</var> be a new empty <span>List</span>.</p></li>

<li><p>Let <var>maxProperties</var> be the <span>number of child browsing contexts</span> of
<var>W</var>.</p></li>
<li><p>Let <var>maxProperties</var> be the <span>number of document-tree child browsing
contexts</span> of <var>W</var>.</p></li>

<li><p>Let <var>index</var> be 0.</p></li>

Expand Down

0 comments on commit 084405b

Please sign in to comment.