Skip to content

Commit 0c667c7

Browse files
committed
[cssom-view] Change scrollIntoView(undefined) to be like true
This aligns with the behavior of Gecko/WebKit/Chromium; EdgeHTML treats explicit undefined like false. Fixes #1367. Tests: web-platform-tests/wpt#6253
1 parent 559de55 commit 0c667c7

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

cssom-view/Overview.bs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ When asked to <dfn>evaluate media queries and report changes</dfn> for a {{Docum
768768
<div class='example'>
769769
A simple piece of code that detects changes in the orientation of the viewport can be written as follows:
770770

771-
<pre class='lang-javascript'>
771+
<pre highlight=javascript>
772772
function handleOrientationChange(event) {
773773
if(event.matches) // landscape
774774
&hellip;
@@ -922,7 +922,7 @@ Note: Some non-conforming implementations are known to return 32 instead of 24.
922922
<code>colorDepth</code> can be used in the context of selecting SDR/HDR in
923923
addition with other information. For example, combined with color gamut.
924924

925-
<pre class='lang-javascript'>
925+
<pre highlight=javascript>
926926
if (screen.colorDepth >= 48 && window.matchMedia('(color-gamut: p3)').matches &&
927927
/* other checks */) {
928928
// Use HDR content.
@@ -1082,8 +1082,7 @@ dictionary ScrollIntoViewOptions : ScrollOptions {
10821082
partial interface Element {
10831083
sequence&lt;DOMRect> getClientRects();
10841084
[NewObject] DOMRect getBoundingClientRect();
1085-
void scrollIntoView();
1086-
void scrollIntoView((boolean or object) arg);
1085+
void scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = true);
10871086
void scroll(optional ScrollToOptions options);
10881087
void scroll(unrestricted double x, unrestricted double y);
10891088
void scrollTo(optional ScrollToOptions options);
@@ -1129,7 +1128,7 @@ Note: The {{DOMRect}} object returned by {{Element/getBoundingClientRect()}} is
11291128
<div class='example'>
11301129
The following snippet gets the dimensions of the first <code>div</code> element in a document:
11311130

1132-
<pre class='lang-javascript'>
1131+
<pre highlight=javascript>
11331132
var example = document.getElementsByTagName("div")[0].getBoundingClientRect();
11341133
var exampleWidth = example.width;
11351134
var exampleHeight = example.height;
@@ -1138,18 +1137,24 @@ Note: The {{DOMRect}} object returned by {{Element/getBoundingClientRect()}} is
11381137

11391138
The <dfn method for=Element caniuse=scrollintoview>scrollIntoView(<var>arg</var>)</dfn> method must run these steps:
11401139

1141-
<!-- scrollIntoView() means arg=true but scrollIntoView(undefined) means arg=false, to align with impls. -->
1142-
11431140
1. Let <var>options</var> be null.
1144-
1. If <var>arg</var> is an object, let <var>options</var> be <var>arg</var>.
1145-
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]]
1146-
1. If <var>arg</var> is not specified or is true, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>start</code>", and let the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> have the value "<code>nearest</code>".
1147-
1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> have the value "<code>end</code>", and let the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> have the value "<code>nearest</code>".
1141+
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, set <var>options</var> to <var>arg</var>. Otherwise:
1142+
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]]
1143+
1. If <var>arg</var> is true, set the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> to "<code>start</code>", and set the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> to "<code>nearest</code>".
1144+
1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> to "<code>end</code>", and set the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> to "<code>nearest</code>".
11481145
1. If the element does not have any associated <a>layout box</a> terminate these steps.
11491146
1. <a lt='scroll an element into view'>Scroll the element into view</a>
11501147
with the options <var>options</var>.
11511148
1. Optionally perform some other action that brings the element to the user's attention.
11521149

1150+
<p class=note highlight=javascript>For historical reasons, passing in <code>true</code> or
1151+
<code>undefined</code> to {{Element/scrollIntoView()}} is equivalent to
1152+
<code>{&nbsp;block:&nbsp;"start",&nbsp;inline:&nbsp;"nearest"&nbsp;}</code>, and passing in
1153+
<code>false</code> is equivalent to
1154+
<code>{&nbsp;block:&nbsp;"end",&nbsp;inline:&nbsp;"nearest"&nbsp;}</code>. Since centering is a
1155+
common case, passing in an empty dictionary <code>{}</code> is equivalent to
1156+
<code>{&nbsp;block:&nbsp;"center",&nbsp;inline:&nbsp;"center"&nbsp;}</code>.
1157+
11531158
The <dfn method for=Element lt="scroll(options)|scroll(x, y)">scroll()</dfn> method must run these steps:
11541159

11551160
1. If invoked with one argument, follow these substeps:

0 commit comments

Comments
 (0)