-
Notifications
You must be signed in to change notification settings - Fork 715
[cssom-view] Change scrollIntoView(undefined) to be like true #1505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
21c997e
to
763f7e7
Compare
763f7e7
to
0c667c7
Compare
Ping @travisleithead - is this change OK for Edge? |
0c667c7
to
763f7e7
Compare
cssom-view/Overview.bs
Outdated
@@ -1082,8 +1082,7 @@ dictionary ScrollIntoViewOptions : ScrollOptions { | |||
partial interface Element { | |||
sequence<DOMRect> getClientRects(); | |||
[NewObject] DOMRect getBoundingClientRect(); | |||
void scrollIntoView(); | |||
void scrollIntoView((boolean or object) arg); | |||
void scrollIntoView(optional (boolean or ScrollIntoViewOptions) arg = true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to define a default here. I had a similar situation with addEventListener
. Basically if no argument is given you'll end up getting a dictionary passed to your algorithm and that dictionary should have the appropriate defaults already. Does that make sense?
cssom-view/Overview.bs
Outdated
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, set <var>options</var> to <var>arg</var>. Otherwise: | ||
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]] | ||
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>". | ||
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>". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should basically no longer be needed. All you need is some logic for what to do when arg is a boolean. Or is there another caller of sorts?
cssom-view/Overview.bs
Outdated
<code>false</code> is equivalent to | ||
<code>{ block: "end", inline: "nearest" }</code>. Since centering is a | ||
common case, passing in an empty dictionary <code>{}</code> is equivalent to | ||
<code>{ block: "center", inline: "center" }</code>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we wouldn't do this?
Okay, isn't that a little confusing? |
Maybe it is, yeah. I can address both issues at once. I'll push new commits here and update the tests. |
This aligns with the behavior of Gecko/WebKit/Chromium; EdgeHTML treats explicit undefined like false. Fixes #1367. Tests: web-platform-tests/wpt#6253
763f7e7
to
73f06e5
Compare
@annevk PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let/set nit must be fixed, the rest would be nice.
cssom-view/Overview.bs
Outdated
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>". | ||
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, set <var>options</var> to <var>arg</var>. Otherwise: | ||
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]] | ||
1. If <var>arg</var> is false, let the {{ScrollIntoViewOptions/block}} dictionary member of <var>options</var> to "<code>end</code>". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then set
cssom-view/Overview.bs
Outdated
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]] | ||
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>". | ||
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>". | ||
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, set <var>options</var> to <var>arg</var>. Otherwise: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems clearer if Otherwise is a new step
cssom-view/Overview.bs
Outdated
dictionary <code>{}</code> to {{Element/scrollIntoView()}} is equivalent to | ||
<code>{ block: "start", inline: "nearest" }</code>. Passing in | ||
<code>false</code> is equivalent to | ||
<code>{ block: "end", inline: "nearest" }</code>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is needed as we don't explain all the other nuances of IDL either.
cssom-view/Overview.bs
Outdated
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>". | ||
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>". | ||
1. If <var>arg</var> is a {{ScrollIntoViewOptions}} dictionary, set <var>options</var> to <var>arg</var>. Otherwise: | ||
1. <a lt="converted to an IDL value">Convert</a> <var>options</var> to a {{ScrollIntoViewOptions}} dictionary. [[!WEBIDL]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish this could be avoided somehow, but I guess it's okay. It's a little ugly to invoke JS->IDL conversions when you're supposedly already in IDL-prose land.
@@ -1301,7 +1298,9 @@ The <dfn attribute for=Element>clientHeight</dfn> attribute must run these steps | |||
<h3 id=element-scrolling-members>{{Element}} Scrolling Members</h3> | |||
|
|||
To <dfn>scroll an element into view</dfn> <var>element</var>, | |||
with a {{ScrollIntoViewOptions}} dictionary <var>options</var>, | |||
with a scroll behavior <var>behavior</var>, | |||
a block flow direction position <var>block</var>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and an optional block flow ... and an inline base ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow. Would you like me to tweak the wording? Or make these optional? Both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you treat the second and third argument as optional because there's one invocation that just invokes this with "auto", afaict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that. Within cssom-view it's only invoked here
1. <a lt='scroll an element into view'>Scroll the element into view</a>
with <var>behavior</var>, <var>block</var>, and <var>inline</var>.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah you're right. I got confused with "scroll an element".
This aligns with the behavior of Gecko/WebKit/Chromium; EdgeHTML
treats explicit undefined like false.
Fixes #1367.
Tests: web-platform-tests/wpt#6253