Open jnjaeschke opened 3 months ago
Yeah, I agree that makes more sense. The intent here was that the first common ancestor is used to set the :target
pseudo class since we can only set it on one element (I think?). But scrolling to it seems like a bug - we could separate the element used for :target
and scroll the start container as you suggest.
cc @megangardner
If a text directive should be scrolled to, it should be visible in the center of the view. However, scrolling the common ancestor of a range into the center of the view is not necessarily scrolling the range into view.
Example:
Text Directive:
:~:text=Test,Test2
An implementation that follows the spec would scroll in between the two
<p>
, so that neitherTest
norTest2
would be visible. This is confusing for users. Therefore, my proposal is to change the spec so that the start container of the range is visible at the center of the view instead of the common ancestor.Chrome already follows this proposal and scrolls
Test
into the center of the view. Safari and Gecko (as of now) follow the spec. I'm planning to change the implementation in Gecko to align with Chrome./cc @zcorpan