Skip to content

Commit

Permalink
Add element.focus({ preventScroll: true })
Browse files Browse the repository at this point in the history
Addresses the most basic part of whatwg#834, allowing further customizations
to be done by JavaScript code.
  • Loading branch information
Jihye Hong authored and Alice Boxhall committed Jan 7, 2019
1 parent 82f7a07 commit 4429dea
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions source
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -9984,7 +9984,7 @@ interface <dfn>HTMLElement</dfn> : <span>Element</span> {
[<span>CEReactions</span>] attribute boolean <span data-x="dom-inert">inert</span>;
void <span data-x="dom-click">click</span>();
[<span>CEReactions</span>] attribute long <span data-x="dom-tabindex">tabIndex</span>;
void <span data-x="dom-focus">focus</span>();
void <span data-x="dom-focus">focus</span>(optional <span>FocusOptions</span> options);
void <span data-x="dom-blur">blur</span>();
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-accessKey">accessKey</span>;
readonly attribute DOMString <span data-x="dom-accessKeyLabel">accessKeyLabel</span>;
Expand All @@ -9993,6 +9993,7 @@ interface <dfn>HTMLElement</dfn> : <span>Element</span> {

[<span>CEReactions</span>] attribute [TreatNullAs=EmptyString] DOMString <span data-x="dom-innerText">innerText</span>;
};

<span>HTMLElement</span> implements <span>GlobalEventHandlers</span>;
<span>HTMLElement</span> implements <span>DocumentAndElementEventHandlers</span>;
<span>HTMLElement</span> implements <span>ElementContentEditable</span>;
Expand Down Expand Up @@ -73581,6 +73582,10 @@ END:VCARD</pre>

<h4>Focus management APIs</h4>

<pre class="idl">dictionary <dfn>FocusOptions</dfn> {
boolean <span data-x="dom-focusoptions-preventscroll">preventScroll</span> = false;
};</pre>

<dl class="domintro">

<dt><var>document</var> . <code subdfn data-x="dom-document-activeElement">activeElement</code></dt>
Expand Down Expand Up @@ -73629,13 +73634,19 @@ END:VCARD</pre>
</dd>
-->

<dt><var>element</var> . <code subdfn data-x="dom-focus">focus</code>()</dt>
<dt><var>element</var> . <code subdfn data-x="dom-focus">focus</code>([ { <code
data-x="dom-focusoptions-preventscroll">preventScroll</code>: true } ])</dt>

<dd>

<p>Moves the focus to the element.</p>

<p>If the element is a <span>browsing context container</span>, moves the focus to the <span>nested browsing context</span> instead.</p>
<p>If the element is a <span>browsing context container</span>, moves the focus to the
<span>nested browsing context</span> instead.</p>

<p>By default, this method also scrolls the element into view. Providing the <code
data-x="dom-focusoptions-preventscroll">preventScroll</code> option and setting it to true
prevents this behavior.</p>

</dd>

Expand Down Expand Up @@ -73733,8 +73744,8 @@ END:VCARD</pre>
system widget (e.g. tab or window) that contained the <span>browsing context</span>, but hostile
sites widely abuse this behavior to the user's detriment.</p>

<p>The <dfn data-dfn-for="HTMLElement"><code data-x="dom-focus">focus()</code></dfn> method on
elements, when invoked, must run the following algorithm:</p>
<p>The <dfn><code data-x="dom-focus">focus(<var>options</var>)</code></dfn> method on elements, when
invoked, must run the following steps:</p>

<ol>

Expand All @@ -73744,6 +73755,13 @@ END:VCARD</pre>

<li><p>Run the <span>focusing steps</span> for the element.</p></li>

<li><p>If the value of the <dfn><code
data-x="dom-focusoptions-preventscroll">preventScroll</code></dfn> dictionary member of
<var>options</var> is false, then <span data-x="scroll an element into view">scroll the element
into view</span> with scroll behavior "<code data-x="">auto</code>", block flow direction
position set to a UA-defined value, and inline base direction position set to a UA-defined
value.</p></li>

<li><p>Unmark the element as <i data-x="locked for focus">locked for focus</i>.</p></li>

</ol>
Expand Down Expand Up @@ -120514,6 +120532,7 @@ INSERT INTERFACES HERE
Jessica Jong,
jfkthame, <!-- GitHub -->
Jian Li,
Jihye Hong,
Jim Jewett,
Jim Ley,
Jim Meehan,
Expand Down

0 comments on commit 4429dea

Please sign in to comment.