Open foolip opened 4 months ago
It makes a lot of sense to make the feature detectable. Else, polyfills that emulate the native highlighting, for example, by injecting <mark>
tags, might possibly break the page. See https://github.com/GoogleChromeLabs/link-to-text-fragment/issues/102 for a real-world example.
Can the situation be salvaged though? Is it a problem if the feature appears unsupported even though it's supported?
In the worst case someone would then inject/load a polyfill despite native support.
I've filed https://github.com/GoogleChromeLabs/text-fragments-polyfill/issues/157 to probe about what will happen with that polyfill.
Hmm, would the polyfill be an issue if a browser has support but claims not to? In that case it'd strip the :~:
part of the fragment off so the polyfill wouldn't see it, I think?
The bigger issue is we added it so that sites could selectively add a text directive to an anchor only for agents that it knows will strip it off, given that there were cases where adding it could break a site when followed - though this is fairly rare and I'm not sure if anyone uses it for that.
I'm curious to hear WebKit's take on https://webkit.org/b/273466 - if they did this intentionally and don't see any issues I suppose it might be a signal we could try unshipping it...
Hmm, would the polyfill be an issue if a browser has support but claims not to? In that case it'd strip the
:~:
part of the fragment off so the polyfill wouldn't see it, I think?
Correct, this is what I found out and documented in https://github.com/GoogleChromeLabs/text-fragments-polyfill/issues/157#issuecomment-2086029590.
Due to https://webkit.org/b/273466, web developers will not be able to rely on
document.fragmentDirective
to detect support for text fragments.The possible paths to interop are WebKit adding
document.fragmentDirective
or Chromium removing it. Either way makes it impossible to usedocument.fragmentDirective
for feature detection. I don't have an opinion on which way to go.