Ensure that Element.focus() centers the element.#41029
Conversation
|
There are no reviewers for this pull request. Please reach out on the chat room to get help with this. Thank you! |
6298991 to
6c1ecf1
Compare
| let scrollPos = test0.scrollTop; | ||
|
|
||
| // Ensure that both scroll positions are within +/- 1 | ||
| assert_true(focusPos <= scrollPos + 1 && focusPos >= scrollPos - 1, |
There was a problem hiding this comment.
Can you use assert_approx_equals? See https://web-platform-tests.org/writing-tests/testharness-api.html#assert-functions .
| "focus() is within +/- 1 of a centered scrollIntoView()"); | ||
| }, "Element.focus() center in the inline direction"); | ||
|
|
||
| promise_test(async (t) => { |
There was a problem hiding this comment.
Doesn't this test subsume the previous two?
There was a problem hiding this comment.
Yeah, I'll remove it. Originally added it just for completeness
| "focus() is within +/- 1 of a centered scrollIntoView()"); | ||
| }, "Element.focus() center in the block direction"); | ||
|
|
||
| promise_test(async (t) => { |
There was a problem hiding this comment.
I'm still confused why there are two tests here. They are identical up until the assert, right? Why not just include both asserts in one test?
There was a problem hiding this comment.
This was an artifact of test development. Updated to use just the test that asserts both directions are centered.
Element focus should behave similar to
`scrollIntoView({block: "center", inline: "center"})` when the element
is not in view.
|
Thanks for the review! |
Element focus should behave similar to
scrollIntoView({block: "center", inline: "center"})when the element is not in view.