Skip to content

Commit 7a579c1

Browse files
Jihye Hongdomenic
authored andcommitted
Add element.focus({ preventScroll: true })
Addresses the most basic part of whatwg#834, allowing further customizations to be done by JavaScript code.
1 parent 5f21a64 commit 7a579c1

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

source

100644100755
Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9983,7 +9983,7 @@ interface <dfn>HTMLElement</dfn> : <span>Element</span> {
99839983
[<span>CEReactions</span>] attribute boolean <span data-x="dom-hidden">hidden</span>;
99849984
void <span data-x="dom-click">click</span>();
99859985
[<span>CEReactions</span>] attribute long <span data-x="dom-tabindex">tabIndex</span>;
9986-
void <span data-x="dom-focus">focus</span>();
9986+
void <span data-x="dom-focus">focus</span>(optional <span>FocusOptions</span> options);
99879987
void <span data-x="dom-blur">blur</span>();
99889988
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-accessKey">accessKey</span>;
99899989
readonly attribute DOMString <span data-x="dom-accessKeyLabel">accessKeyLabel</span>;
@@ -9992,6 +9992,7 @@ interface <dfn>HTMLElement</dfn> : <span>Element</span> {
99929992

99939993
[<span>CEReactions</span>] attribute [TreatNullAs=EmptyString] DOMString <span data-x="dom-innerText">innerText</span>;
99949994
};
9995+
99959996
<span>HTMLElement</span> implements <span>GlobalEventHandlers</span>;
99969997
<span>HTMLElement</span> implements <span>DocumentAndElementEventHandlers</span>;
99979998
<span>HTMLElement</span> implements <span>ElementContentEditable</span>;
@@ -73566,6 +73567,10 @@ END:VCARD</pre>
7356673567

7356773568
<h4>Focus management APIs</h4>
7356873569

73570+
<pre class="idl">dictionary <dfn>FocusOptions</dfn> {
73571+
boolean <span data-x="dom-focusoptions-preventscroll">preventScroll</span> = false;
73572+
};</pre>
73573+
7356973574
<dl class="domintro">
7357073575

7357173576
<dt><var>document</var> . <code subdfn data-x="dom-document-activeElement">activeElement</code></dt>
@@ -73614,13 +73619,19 @@ END:VCARD</pre>
7361473619
</dd>
7361573620
-->
7361673621

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

7361973625
<dd>
7362073626

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

73623-
<p>If the element is a <span>browsing context container</span>, moves the focus to the <span>nested browsing context</span> instead.</p>
73629+
<p>If the element is a <span>browsing context container</span>, moves the focus to the
73630+
<span>nested browsing context</span> instead.</p>
73631+
73632+
<p>By default, this method also scrolls the element into view. Providing the <code
73633+
data-x="dom-focusoptions-preventscroll">preventScroll</code> option and setting it to true
73634+
prevents this behavior.</p>
7362473635

7362573636
</dd>
7362673637

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

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

7372473735
<ol>
7372573736

@@ -73729,6 +73740,13 @@ END:VCARD</pre>
7372973740

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

73743+
<li><p>If the value of the <dfn><code
73744+
data-x="dom-focusoptions-preventscroll">preventScroll</code></dfn> dictionary member of
73745+
<var>options</var> is false, then <span data-x="scroll an element into view">scroll the element
73746+
into view</span> with scroll behavior "<code data-x="">auto</code>", block flow direction
73747+
position set to a UA-defined value, and inline base direction position set to a UA-defined
73748+
value.</p></li>
73749+
7373273750
<li><p>Unmark the element as <i data-x="locked for focus">locked for focus</i>.</p></li>
7373373751

7373473752
</ol>
@@ -120494,6 +120512,7 @@ INSERT INTERFACES HERE
120494120512
Jessica Jong,
120495120513
jfkthame, <!-- GitHub -->
120496120514
Jian Li,
120515+
Jihye Hong,
120497120516
Jim Jewett,
120498120517
Jim Ley,
120499120518
Jim Meehan,

0 commit comments

Comments
 (0)