Permalink
Browse files

Add element.focus({ preventScroll: true })

Addresses the most basic part of #834, allowing further customizations
to be done by JavaScript code.
  • Loading branch information...
jihyerish authored and domenic committed Oct 26, 2017
1 parent 5f21a64 commit 7a579c1cf3fddc68a634e74c12c457af258e6a80
Showing with 24 additions and 5 deletions.
  1. +24 −5 source
View
29 source 100644 → 100755
@@ -9983,7 +9983,7 @@ interface <dfn>HTMLElement</dfn> : <span>Element</span> {
[<span>CEReactions</span>] attribute boolean <span data-x="dom-hidden">hidden</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>;
@@ -9992,6 +9992,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>;
@@ -73566,6 +73567,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>
@@ -73614,13 +73619,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>
@@ -73718,8 +73729,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>
@@ -73729,6 +73740,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>
@@ -120494,6 +120512,7 @@ INSERT INTERFACES HERE
Jessica Jong,
jfkthame, <!-- GitHub -->
Jian Li,
Jihye Hong,
Jim Jewett,
Jim Ley,
Jim Meehan,

0 comments on commit 7a579c1

Please sign in to comment.