html icon indicating copy to clipboard operation
html copied to clipboard

(scroll-to-text) fragmentDirectives should be allowed to be unique

Open vmpstr opened this issue 1 month ago • 6 comments

What is the issue with the HTML Standard?

The PR for this feature is being upstreamed here https://github.com/whatwg/html/pull/11895. One of the things that is exposed by the idl (https://wicg.github.io/scroll-to-text-fragment/#dom-document-fragmentdirective) is the fragmentDirective that lists all of the directives parsed from the URL.

In order to limit the amount of work that a user-agent has to do for each directive, I think this should allow or mandate that when constructing these directives, we only keep a unique set.

@flackr @domfarolino

vmpstr avatar Nov 21 '25 17:11 vmpstr

That API doesn't list any directives? It's just an empty object. Also, wouldn't listing them go against the privacy goals of this feature?

annevk avatar Nov 24 '25 07:11 annevk

Agreed, I don't see the issue here. Of course it looks like Chromium's FragmentDirective interface is NOT empty, which is confusing to me for the reasons that @annevk brought up. @bokand, and insight into what's happening here?

domfarolino avatar Nov 25 '25 21:11 domfarolino

The additional fields in Chromium are behind a flag and from additions we were considering and prototyping - I think we can remove them to avoid confusion...

The fragmentDirective interface was primarily intended as a way to feature detect and potential area for future extension but yeah, currently it's just empty.

bokand avatar Nov 26 '25 16:11 bokand

In that case, this might be OK to close since the behavioral differences from the unique set in the implementation would not be observable.

But yeah, cleaning up the spec to avoid confusion would be great too!

vmpstr avatar Nov 27 '25 16:11 vmpstr

But yeah, cleaning up the spec to avoid confusion would be great too!

Do you mean cleaning up Chromium's IDL?

zcorpan avatar Nov 28 '25 08:11 zcorpan

However, searching for the same text fragment several times would introduce unnecessary work and would cause timing differences. So, from an user agent's point of view, it might make sense to make the list of text directives unique after parsing them from the fragment and before searching the document. I'm not sure this needs to be added to the spec though, or if that's just an implementation detail.

jnjaeschke avatar Nov 30 '25 20:11 jnjaeschke