WICG / scroll-to-text-fragment

Proposal to allow specifying a text snippet in a URL fragment
Other
589 stars 42 forks source link

Clarify how scroll to fragment is performed #66

Closed fred-wang closed 4 years ago

fred-wang commented 4 years ago

https://wicg.github.io/ScrollToTextFragment/#navigating-to-text-fragment defers to HTML5 in order to perform the scroll to the fragment.

https://html.spec.whatwg.org/multipage/browsing-the-web.html#scroll-to-the-fragment-identifier assumes that the indicated part of the document is an Element and then defers to CSSOMView. However, https://wicg.github.io/ScrollToTextFragment/#find-a-target-text returns a Range.

Maybe what is wanted instead is to rely on window.find() but this is not standardized. See https://github.com/whatwg/html/issues/3539

bokand commented 4 years ago

@fred-wang WDYT of the updated indicated part of the document handling in https://github.com/WICG/ScrollToTextFragment/pull/67?

I think it'd make sense to standardize/clean-up window.find() and if we did that it'd make sense to share some of that functionality with this proposal but I expect that's a much larger undertaking and I don't think we should block ScrollToTextFragment on that work. WDYT?

fred-wang commented 4 years ago

@fred-wang WDYT of the updated indicated part of the document handling in #67?

OK, I took a look at the new text and the behavior now seems well-defined to me. At least I didn't find any obvious gap that prevents implementing it. Thanks for doing that change!

Maybe one possible addition could be to extend ScrollIntoViewOptions or ScrollOptions with a boolean "highlight" parameter, so that the CSSOM would take care of https://wicg.github.io/ScrollToTextFragment/#indicating-the-text-match

I think it'd make sense to standardize/clean-up window.find() and if we did that it'd make sense to share some of that functionality with this proposal but I expect that's a much larger undertaking and I don't think we should block ScrollToTextFragment on that work. WDYT?

Right, I mentioned window.find because there was already an issue request for that but I'm happy with enhancing scrolIntoView. This is maybe even better since that one already has a spec/testsuite and is already used by HTML5. I guess web developers asking for window.find would find this addition useful to implement a polyfill.

I'll reply on the blink-dev thread.