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

Need a way to feature detect #19

Closed
bokand opened this issue Jun 27, 2019 · 3 comments · Fixed by #47
Closed

Need a way to feature detect #19

bokand opened this issue Jun 27, 2019 · 3 comments · Fixed by #47

Comments

@bokand
Copy link
Collaborator

bokand commented Jun 27, 2019

In #15 we're discussing ways to spec the feature such that it doesn't break pages that use the hash fragment for their own purposes. If we succeed in doing that, this means that UAs implementing this feature can follow links with the targetText to pages that would otherwise break with a hand-crafted fragment. The canonical example from that issue is https://www.webmd.com/skin-problems-and-treatments/lice-treatment#anything.

However, this would mean that a page sending a user to https://www.webmd.com/skin-problems-and-treatments/lice-treatment##targetText=sometext will load and work correctly in UAs that support the feature, but completely break the page for UAs that don't.

We should support some method of feature detection so pages can check whether adding a targetText has the potential to break the link and avoid adding it for UAs that don't support it.

@bokand
Copy link
Collaborator Author

bokand commented Sep 3, 2019

I propose adding an object on window.location that will only be present if the UA supports targetText. We should call this selector to allow future extension beyond just text. It would also give us a place to add APIs to allow adding APIs such as letting the page know whether the selector was successfully matched and scrolled.

@domenic
Copy link

domenic commented Sep 25, 2019

I'm curious why selector and not fragmentDirective? I think the spec concepts and developer-facing API should align, if possible.

I'll note that I am pretty sure you can feature detect in a roundabout way by doing something like:

<span hidden id="targetTextTest">put-a-guid-here</span>
<script>
window.location = "###targetText=put-a-guid-here";

if (document.querySelector("#targetTextTest").matches(":target")) {
  // feature is supported
}
</script>

(Possible modifications: if we don't plan to scroll to hidden things, then just make it 0x0, or transparent. Also, clean up after the feature detection, e.g. by removing the targetText from the window.location and removing the element from the DOM. Also, #1 implies we might change it to :target-within instead of :target.)

@bokand
Copy link
Collaborator Author

bokand commented Oct 9, 2019

I'm curious why selector and not fragmentDirective? I think the spec concepts and developer-facing API should align, if possible.

I agree, will change it.

I'll note that I am pretty sure you can feature detect in a roundabout way by doing something like

That won't work because, to mitigate concerns around cross-origin information exfiltration, we restrict the contexts around which the directive will be activated. This includes requiring a user-gesture. It's discussed in more detail in https://github.com/WICG/ScrollToTextFragment#security but I just realized we didn't put it in the spec so I filed #46 to followup on that.

chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 9, 2019
Update the feature detectability API to
window.location.fragmentDirective per
WICG/scroll-to-text-fragment#19

Also updated web platform tests and confirmed tests pass.

Bug: 1000308
Change-Id: Ib2391abe3d142d57cea61840e721ed35c81089af
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this issue Oct 11, 2019
Update the feature detectability API to
window.location.fragmentDirective per
WICG/scroll-to-text-fragment#19

Also updated web platform tests and confirmed tests pass.

Bug: 1000308
Change-Id: Ib2391abe3d142d57cea61840e721ed35c81089af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850364
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705010}
foolip pushed a commit to web-platform-tests/wpt that referenced this issue Oct 11, 2019
Update the feature detectability API to
window.location.fragmentDirective per
WICG/scroll-to-text-fragment#19

Also updated web platform tests and confirmed tests pass.

Bug: 1000308
Change-Id: Ib2391abe3d142d57cea61840e721ed35c81089af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850364
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705010}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this issue Oct 24, 2019
…ity API, a=testonly

Automatic update from web-platform-tests
Update scroll to text feature detectability API

Update the feature detectability API to
window.location.fragmentDirective per
WICG/scroll-to-text-fragment#19

Also updated web platform tests and confirmed tests pass.

Bug: 1000308
Change-Id: Ib2391abe3d142d57cea61840e721ed35c81089af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850364
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705010}

--

wpt-commits: 084d7fc3c77c1c5d581395fa834245ed527b0664
wpt-pr: 19610
xeonchen pushed a commit to xeonchen/gecko that referenced this issue Oct 24, 2019
…ity API, a=testonly

Automatic update from web-platform-tests
Update scroll to text feature detectability API

Update the feature detectability API to
window.location.fragmentDirective per
WICG/scroll-to-text-fragment#19

Also updated web platform tests and confirmed tests pass.

Bug: 1000308
Change-Id: Ib2391abe3d142d57cea61840e721ed35c81089af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850364
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#705010}

--

wpt-commits: 084d7fc3c77c1c5d581395fa834245ed527b0664
wpt-pr: 19610
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this issue Oct 27, 2019
…ity API, a=testonly

Automatic update from web-platform-tests
Update scroll to text feature detectability API

Update the feature detectability API to
window.location.fragmentDirective per
WICG/scroll-to-text-fragment#19

Also updated web platform tests and confirmed tests pass.

Bug: 1000308
Change-Id: Ib2391abe3d142d57cea61840e721ed35c81089af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850364
Commit-Queue: David Bokan <bokanchromium.org>
Reviewed-by: David Bokan <bokanchromium.org>
Cr-Commit-Position: refs/heads/master{#705010}

--

wpt-commits: 084d7fc3c77c1c5d581395fa834245ed527b0664
wpt-pr: 19610

UltraBlame original commit: 627cd54b6eeac59971c7640c8f18d4238675e3d6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this issue Oct 27, 2019
…ity API, a=testonly

Automatic update from web-platform-tests
Update scroll to text feature detectability API

Update the feature detectability API to
window.location.fragmentDirective per
WICG/scroll-to-text-fragment#19

Also updated web platform tests and confirmed tests pass.

Bug: 1000308
Change-Id: Ib2391abe3d142d57cea61840e721ed35c81089af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850364
Commit-Queue: David Bokan <bokanchromium.org>
Reviewed-by: David Bokan <bokanchromium.org>
Cr-Commit-Position: refs/heads/master{#705010}

--

wpt-commits: 084d7fc3c77c1c5d581395fa834245ed527b0664
wpt-pr: 19610

UltraBlame original commit: 627cd54b6eeac59971c7640c8f18d4238675e3d6
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this issue Oct 27, 2019
…ity API, a=testonly

Automatic update from web-platform-tests
Update scroll to text feature detectability API

Update the feature detectability API to
window.location.fragmentDirective per
WICG/scroll-to-text-fragment#19

Also updated web platform tests and confirmed tests pass.

Bug: 1000308
Change-Id: Ib2391abe3d142d57cea61840e721ed35c81089af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850364
Commit-Queue: David Bokan <bokanchromium.org>
Reviewed-by: David Bokan <bokanchromium.org>
Cr-Commit-Position: refs/heads/master{#705010}

--

wpt-commits: 084d7fc3c77c1c5d581395fa834245ed527b0664
wpt-pr: 19610

UltraBlame original commit: 627cd54b6eeac59971c7640c8f18d4238675e3d6
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

Successfully merging a pull request may close this issue.

2 participants