You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[cssom-view] scrollIntoView(undefined) to be like true; change defaults for ScrollIntoViewOptions
This aligns with the behavior of Gecko/WebKit/Chromium; EdgeHTML
treats explicit undefined like false. Fixesw3c#1367.
Also change defaults for ScrollIntoViewOptions. Fixesw3c#1720.
Tests: web-platform-tests/wpt#6253
@@ -1129,7 +1128,7 @@ Note: The {{DOMRect}} object returned by {{Element/getBoundingClientRect()}} is
1129
1128
<div class='example'>
1130
1129
The following snippet gets the dimensions of the first <code>div</code> element in a document:
1131
1130
1132
-
<pre class='lang-javascript'>
1131
+
<pre highlight=javascript>
1133
1132
var example = document.getElementsByTagName("div")[0].getBoundingClientRect();
1134
1133
var exampleWidth = example.width;
1135
1134
var exampleHeight = example.height;
@@ -1138,16 +1137,17 @@ Note: The {{DOMRect}} object returned by {{Element/getBoundingClientRect()}} is
1138
1137
1139
1138
The <dfn method for=Element caniuse=scrollintoview>scrollIntoView(<var>arg</var>)</dfn> method must run these steps:
1140
1139
1141
-
<!-- scrollIntoView() means arg=true but scrollIntoView(undefined) means arg=false, to align with impls. -->
1142
-
1143
-
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>".
1148
-
1. If the element does not have any associated <a>layout box</a> terminate these steps.
1140
+
1. Let <var>behavior</var> be "<code>auto</code>".
1141
+
1. Let <var>block</var> be "<code>start</code>".
1142
+
1. Let <var>inline</var> be "<code>nearest</code>".
1143
+
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, then:
1144
+
1. Set <var>behavior</var> to the {{ScrollOptions/behavior}} dictionary member of <var>options</var>.
1145
+
1. Set <var>block</var> to the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var>.
1146
+
1. Set <var>inline</var> to the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var>.
1147
+
1. Otherwise, if <var>arg</var> is false, then set <var>block</var> to "<code>end</code>".
1148
+
1. If the element does not have any associated <a>layout box</a>, then return.
1149
1149
1. <a lt='scroll an element into view'>Scroll the element into view</a>
1150
-
with the options <var>options</var>.
1150
+
with <var>behavior</var>, <var>block</var>, and <var>inline</var>.
1151
1151
1. Optionally perform some other action that brings the element to the user's attention.
1152
1152
1153
1153
The <dfn method for=Element lt="scroll(options)|scroll(x, y)">scroll()</dfn> method must run these steps:
@@ -1225,7 +1225,7 @@ When setting the {{Element/scrollTop}} attribute these steps must be run:
1225
1225
1. If the element is the root element invoke {{Window/scroll()}} on <var>window</var> with {{Window/scrollX}} on <var>window</var> as first argument and <var>y</var> as second argument, and terminate these steps.
1226
1226
1. If the element is <a>the HTML <code>body</code> element</a>, <var>document</var> is in <a>quirks mode</a>, and the element is not <a>potentially scrollable</a>, invoke {{Window/scroll()}} on <var>window</var> with {{Window/scrollX}} as first argument and <var>y</var> as second argument, and terminate these steps.
1227
1227
1. If the element does not have any associated <a>CSS layout box</a>, the element has no associated <a>scrolling box</a>, or the element has no overflow, terminate these steps.
1228
-
1. <a lt='scroll an element'>Scroll the element</a> to {{Element/scrollLeft}},<var>y</var>, with the scroll behavior being <code>"auto"</code>.
1228
+
1. <a lt='scroll an element'>Scroll the element</a> to {{Element/scrollLeft}},<var>y</var>, with the scroll behavior being "<code>auto</code>".
1229
1229
1230
1230
The <dfn attribute for=Element>scrollLeft</dfn> attribute, on getting, must return the result of running these steps:
1231
1231
@@ -1251,7 +1251,7 @@ When setting the {{Element/scrollLeft}} attribute these steps must be run:
1251
1251
1. If the element is the root element invoke {{Window/scroll()}} on <var>window</var> with <var>x</var> as first argument and {{Window/scrollY}} on <var>window</var> as second argument, and terminate these steps.
1252
1252
1. If the element is <a>the HTML <code>body</code> element</a>, <var>document</var> is in <a>quirks mode</a>, and the element is not <a>potentially scrollable</a>, invoke {{Window/scroll()}} on <var>window</var> with <var>x</var> as first argument and {{Window/scrollY}} on <var>window</var> as second argument, and terminate these steps.
1253
1253
1. If the element does not have any associated <a>CSS layout box</a>, the element has no associated <a>scrolling box</a>, or the element has no overflow, terminate these steps.
1254
-
1. <a lt='scroll an element'>Scroll the element</a> to <var>x</var>,{{Element/scrollTop}}, with the scroll behavior being <code>"auto"</code>.
1254
+
1. <a lt='scroll an element'>Scroll the element</a> to <var>x</var>,{{Element/scrollTop}}, with the scroll behavior being "<code>auto</code>".
1255
1255
1256
1256
The <dfn attribute for=Element>scrollWidth</dfn> attribute must return the result of running these steps:
1257
1257
@@ -1299,7 +1299,9 @@ The <dfn attribute for=Element>clientHeight</dfn> attribute must run these steps
To <dfn>scroll an element into view</dfn><var>element</var>,
1302
-
with a {{ScrollIntoViewOptions}} dictionary <var>options</var>,
1302
+
with a scroll behavior <var>behavior</var>,
1303
+
a block flow direction position <var>block</var>,
1304
+
and an inline base direction position <var>inline</var>,
1303
1305
means to run these steps for each ancestor element or <a>viewport</a> that establishes
1304
1306
a <a>scrolling box</a><var>scrolling box</var>, in order of innermost to outermost <a>scrolling box</a>:
1305
1307
@@ -1313,10 +1315,10 @@ a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outerm
1313
1315
1. Let <var>scrolling box width</var> be the distance between <var>scrolling box edge C</var> and <var>scrolling box edge D</var>.
1314
1316
1. Let <var>position</var> be the scroll position <var>scrolling box</var> would have by following these steps:
1315
1317
1316
-
1. If the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> is "start", align <var>element edge A</var> with <var>scrolling box edge A</var>.
1317
-
1. Otherwise, if the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> is "end"; align <var>element edge B</var> with <var>scrolling box edge B</var>.
1318
-
1. Otherwise, if the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> is "center"; align the center of <var>element bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>block flow direction</a>.
1319
-
1. Otherwise, it is "nearest"; follow these steps:
1318
+
1. If <var>block</var> is "<code>start</code>", then align <var>element edge A</var> with <var>scrolling box edge A</var>.
1319
+
1. Otherwise, if <var>block</var> is "<code>end</code>", then align <var>element edge B</var> with <var>scrolling box edge B</var>.
1320
+
1. Otherwise, if <var>block</var> is "<code>center</code>", then align the center of <var>element bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>block flow direction</a>.
1321
+
1. Otherwise, <var>block</var> is "<code>nearest</code>":
1320
1322
<dl class=switch>
1321
1323
<dt>If <var>element edge A</var> and <var>element edge B</var> are both outside <var>scrolling box edge A</var> and <var>scrolling box edge B</var>
1322
1324
<dd>Do nothing.
@@ -1329,10 +1331,10 @@ a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outerm
1329
1331
<dt>If <var>element edge B</var> is outside <var>scrolling box edge B</var> and <var>element width</var> is less than <var>scrolling box width</var>
1330
1332
<dd>Align <var>element edge B</var> with <var>scrolling box edge B</var>.
1331
1333
</dl>
1332
-
1. If the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> is "start", align <var>element edge C</var> with <var>scrolling box edge C</var>.
1333
-
1. Otherwise, if the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> is "end"; align <var>element edge D</var> with <var>scrolling box edge D</var>.
1334
-
1. Otherwise, if the {{ScrollIntoViewOptions/inline}} dictionary member of <var>options</var> is "center", align the center of <var>element bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>inline base direction</a>.
1335
-
1. Otherwise, it is "nearest"; follow these steps:
1334
+
1. If <var>inline</var> is "<code>start</code>", then align <var>element edge C</var> with <var>scrolling box edge C</var>.
1335
+
1. Otherwise, if <var>inline</var> is "<code>end</code>", then align <var>element edge D</var> with <var>scrolling box edge D</var>.
1336
+
1. Otherwise, if <var>inline</var> is "<code>center</code>", then align the center of <var>element bounding border box</var> with the center of <var>scrolling box</var> in <var>scrolling box</var>'s <a>inline base direction</a>.
1337
+
1. Otherwise, <var>inline</var> is "<code>nearest</code>":
1336
1338
<dl class=switch>
1337
1339
<dt>If <var>element edge C</var> and <var>element edge D</var> are both outside <var>scrolling box edge C</var> and <var>scrolling box edge D</var>
1338
1340
<dd>Do nothing.
@@ -1346,7 +1348,7 @@ a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outerm
1346
1348
<dd>Align <var>element edge D</var> with <var>scrolling box edge D</var>.
1347
1349
</dl>
1348
1350
1349
-
1. If <var>position</var> is the same as <var>scrolling box</var>'s current scroll position, and <var>scrolling box</var> does not have an ongoing <a>smooth scroll</a>, abort these steps.
1351
+
1. If <var>position</var> is the same as <var>scrolling box</var>'s current scroll position, and <var>scrolling box</var> does not have an ongoing <a>smooth scroll</a>, then return.
1350
1352
1. <dl class=switch>
1351
1353
<dt>If <var>scrolling box</var> is associated with an element
1352
1354
<dd>
@@ -1357,11 +1359,10 @@ a <a>scrolling box</a> <var>scrolling box</var>, in order of innermost to outerm
1357
1359
Let <var>document</var> be the <a>viewport’s</a> associated {{Document}}.
1358
1360
Let <var>associated element</var> be <var>document</var>'s root element, if there is one, or null otherwise.
1359
1361
</dl>
1360
-
1. Let <var>behavior</var> be the {{ScrollOptions/behavior}} dictionary member of <var>options</var>.
1361
1362
1. <a>Perform a scroll</a> of <var>scrolling box</var> to <var>position</var>, <var>associated element</var> as the associated element and <var>behavior</var> as the scroll behavior.
1362
1363
1363
1364
1364
-
To <dfn>scroll an element</dfn><var>element</var> to <var>x</var>,<var>y</var> optionally with a scroll behavior <var>behavior</var> (which is <code>"auto"</code> if omitted) means to:
1365
+
To <dfn>scroll an element</dfn><var>element</var> to <var>x</var>,<var>y</var> optionally with a scroll behavior <var>behavior</var> (which is "<code>auto</code>" if omitted) means to:
1365
1366
1366
1367
1. Let <var>box</var> be <var>element</var>'s associated <a>scrolling box</a>.
0 commit comments