Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define DocumentOrShadowRoot.activeElement #4837

Merged
merged 5 commits into from Aug 23, 2019
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 40 additions & 11 deletions source
Expand Up @@ -3146,12 +3146,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-comment"><code>Comment</code></dfn> interface</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-domimplementation"><code>DOMImplementation</code></dfn> interface</li>
<li><dfn data-x="DOM Document" data-x-href="https://dom.spec.whatwg.org/#interface-document"><code>Document</code></dfn> interface</li>
<li><dfn data-x="DOM DocumentOrShadowRoot" data-x-href="https://dom.spec.whatwg.org/#documentorshadowroot"><code>DocumentOrShadowRoot</code></dfn> interface</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-documentfragment"><code>DocumentFragment</code></dfn> interface</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-documenttype"><code>DocumentType</code></dfn> interface</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-childnode"><code>ChildNode</code></dfn> interface</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-element"><code>Element</code></dfn> interface</li>
<li><dfn data-x="dom-Element-attachShadow" data-x-href="https://dom.spec.whatwg.org/#dom-element-attachshadow"><code>attachShadow()</code></dfn> method.</li>
<li>An element's <dfn data-x="concept-element-shadow-root" data-x-href="https://dom.spec.whatwg.org/#concept-element-shadow-root">shadow root</dfn></li>
<li>The <dfn data-x="dom-retarget" data-x-href="https://dom.spec.whatwg.org/#retarget">retargeting algorithm</dfn></li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-node"><code>Node</code></dfn> interface</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-nodelist"><code>NodeList</code></dfn> interface</li>
<li><dfn data-x-href="https://dom.spec.whatwg.org/#interface-processinginstruction"><code>ProcessingInstruction</code></dfn> interface</li>
Expand Down Expand Up @@ -3189,8 +3191,9 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-child" data-x="concept-tree-child">child</dfn> concept</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-root">root</dfn> and <dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-including-root">shadow-including root</dfn> concepts</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor">inclusive ancestor</dfn>,
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant">shadow-including descendant</dfn>, and
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant">shadow-including inclusive descendant</dfn> concepts</li>
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-including-descendant">shadow-including descendant</dfn>,
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-descendant">shadow-including inclusive descendant</dfn>, and
<dfn data-x-href="https://dom.spec.whatwg.org/#concept-shadow-including-inclusive-ancestor">shadow-including inclusive ancestor</dfn> concepts</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-first-child">first child</dfn> and <dfn data-x-href="https://dom.spec.whatwg.org/#concept-tree-next-sibling">next sibling</dfn> concepts</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#document-element">document element</dfn> concept</li>
<li>The <dfn data-x-href="https://dom.spec.whatwg.org/#in-a-document-tree">in a document tree</dfn>, <dfn data-x-href="https://dom.spec.whatwg.org/#in-a-document">in a document</dfn> (legacy), and <dfn data-x-href="https://dom.spec.whatwg.org/#connected">connected</dfn> concepts</li>
Expand Down Expand Up @@ -9238,7 +9241,6 @@ partial interface <dfn id="document" data-lt="">Document</dfn> {

// <span>user interaction</span>
readonly attribute <span>WindowProxy</span>? <span data-x="dom-document-defaultView">defaultView</span>;
readonly attribute <span>Element</span>? <span data-x="dom-document-activeElement">activeElement</span>;
boolean <span data-x="dom-document-hasFocus">hasFocus</span>();
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-document-designMode">designMode</span>;
[<span>CEReactions</span>] boolean <span data-x="dom-document-execCommand">execCommand</span>(DOMString commandId, optional boolean showUI = false, optional DOMString value = "");
Expand Down Expand Up @@ -9279,6 +9281,15 @@ partial interface <dfn id="document" data-lt="">Document</dfn> {
data-x="concept-document-module-map">module map</dfn>, which is a <span>module map</span>,
initially empty.</p>

<h4>The <code>DocumentOrShadowRoot</code> interface</h4>

<p><cite>DOM</cite> defines the <code data-x="DOM
DocumentOrShadowRoot">DocumentOrShadowRoot</code> mixin, which this specification
extends.</p>

<pre><code class="idl">partial interface mixin <dfn>DocumentOrShadowRoot</dfn> {
readonly attribute <span>Element</span>? <span data-x="dom-documentorshadowroot-activeElement">activeElement</span>;
};</code></pre>

<h4><dfn>Resource metadata management</dfn></h4>

Expand Down Expand Up @@ -73903,8 +73914,9 @@ END:VCARD</pre>
document">focused area</span> is a <code>button</code> element, removing, disabling, or hiding
that button would cause the page's new <span data-x="focused area of the document">focused
area</span> to be the <span>viewport</span> of the <code>Document</code>. This would, in turn,
be reflected through the <code data-x="dom-document-activeElement">activeElement</code> API as
<span>the body element</span>.</p>
be reflected through the <code
data-x="dom-documentorshadowroot-activeElement">activeElement</code> API as <span>the body
element</span>.</p>

<hr>

Expand Down Expand Up @@ -74296,7 +74308,8 @@ END:VCARD</pre>

<dl class="domintro">

<dt><var>document</var> . <code subdfn data-x="dom-document-activeElement">activeElement</code></dt>
<dt><var>documentOrShadowRoot</var> . <code subdfn
data-x="dom-documentorshadowroot-activeElement">activeElement</code></dt>
domenic marked this conversation as resolved.
Show resolved Hide resolved

<dd>

Expand All @@ -74307,8 +74320,19 @@ END:VCARD</pre>
<span>browsing context container</span> is <a href="#bc-focus-ergo-bcc-focus">focused</a> in the
<span>parent browsing context</span>. For example, if the user moves the focus to a text control
in an <code>iframe</code>, the <code>iframe</code> is the element returned by the <code
data-x="dom-document-activeElement">activeElement</code> API in the <code>iframe</code>'s
<span>node document</span>.</p>
data-x="dom-documentorshadowroot-activeElement">activeElement</code> API in the
<code>iframe</code>'s <span>node document</span>.</p>

<p>Similarly, when the focused element is in a <span>shadow tree</span>, the value returned
will be the result of <span data-x="dom-retarget">retargeting</span> the focused element against
<var>documentShadowRoot</var>. This means if the focused element's <span>root</span>
<var>root</var> is not a <span>shadow-including inclusive ancestor</span> of
<var>documentOrShadowRoot</var>, the value returned will be the <var>root</var>'s
<span data-x="concept-DocumentFragment-host">host</span> (but if the host itself is in another
shadow tree whose <span>root</span> is still not a, <span>shadow-including inclusive
ancestor</span> of <var>documentOrShadowRoot</var>, it will check the host's <span>root</span>
and so on until we got to the<span>document</span>, or find a <span>shadow root</span>
fulfilling the criteria).</p>

</dd>

Expand Down Expand Up @@ -74392,12 +74416,17 @@ END:VCARD</pre>

<div w-nodev>

<p>The <dfn><code data-x="dom-document-activeElement">activeElement</code></dfn> attribute's
getter must run these steps:</p>
<p id="dom-document-activeelement">The <dfn><code
data-x="dom-documentorshadowroot-activeElement">activeElement</code></dfn> attribute's getter must
run these steps:</p>

<ol>
<li><p>Let <var>candidate</var> be the <span>DOM anchor</span> of the <span data-x="focused area
domenic marked this conversation as resolved.
Show resolved Hide resolved
of the document">focused area</span> of this <code>Document</code> object.</p></li>
of the document">focused area</span> of this <code>DocumentOrShadowRoot</code>'s <span>node
document</span>.</p></li>

domenic marked this conversation as resolved.
Show resolved Hide resolved
<li><p>Set <var>candidate</var> to the result of <span data-x="dom-retarget">retargeting</span>
domenic marked this conversation as resolved.
Show resolved Hide resolved
<var>candidate</var> against this <code>DocumentOrShadowRoot</code>.</p></li>
domenic marked this conversation as resolved.
Show resolved Hide resolved

domenic marked this conversation as resolved.
Show resolved Hide resolved
<li><p>If <var>candidate</var> is not a <code>Document</code> object, then return
<var>candidate</var>.</p></li>
Expand Down