Skip to content
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

Proposal: restrict matches to not span containment elements #89

Open
chrishtr opened this issue Feb 28, 2020 · 2 comments
Open

Proposal: restrict matches to not span containment elements #89

chrishtr opened this issue Feb 28, 2020 · 2 comments

Comments

@chrishtr
Copy link

As currently specified, it appears a text fragment identifier can match elements across a very wide swath of DOM, including the entire document, in one match. WICG/display-locking#125 on the display locking repo gives a real-world example where the match is very broad.

That issue also describes why this is a problem for semantics and usability of the beforematch event. It may also be a usability issue of scroll to text fragment, because the scroll will not show the entire match.

I propose that text fragment identifiers not be allowed to cross elements with contain: style layout. This specific restriction is chosen to match semantics of subtree-visibility, and resolve WICG/display-locking#125. Additional restrictions for other types of layout may be appropriate as well.

/cc @bokand @nickburris

--

One potential concern was raised by @vmpstr when discussing this proposal offline, which is that a site could "opt out" of scroll to text fragment by putting every word in a contain: style layout div. However, I don't think this is a significant problem because (a) I don't think it's a problem to worry about if sites go out of their way to avoid text fragments via extreme hacks, and (b) the site will have poor performance and layout behavior if they attempt it.

@bokand
Copy link
Collaborator

bokand commented Feb 28, 2020

I'd need to familiarize myself more with beforematch and contain:style layout but off hand it doesn't sound unreasonable. We'd have to be a little careful here as users are able to select text across these boundaries. The goal is that they'd be able to easily create a link to arbitrary text selections. If we restrict it, we have to find some UI to explain why the selection can't be linked to which is challenging given the UI constraints of a context menu. Cross-element matching was an explicit goal of ours.

Is contain: style layout just author-added or is this something that's also implicit in other circumstances?

a site could "opt out" of scroll to text fragment by putting every word in a contain: style layout div.

We're adding an explicit opt-out in #80 so I don't think we have to worry about this.

@chrishtr
Copy link
Author

Is contain: style layout just author-added or is this something that's also implicit in other circumstances?

It's usually author-added, but is also a side-effect of specifying subtree-visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants