Bug 224833 - [GTK] API to list all anchors aka element ids / URL fragment/hash of the current page
Summary: [GTK] API to list all anchors aka element ids / URL fragment/hash of the curr...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-20 14:53 PDT by Haelwenn (lanodan) Monnier
Modified: 2021-04-20 14:53 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Haelwenn (lanodan) Monnier 2021-04-20 14:53:47 PDT
URL fragments: Anchors defined with the `id` (and formerly `name`) attribute in HTML, visible via `location.hash` in JavaScript.

This is possible to do right now via executing code in JavaScriptCore on page loads but it would probably be more efficient* to have a proper API endpoint to list the available fragments.

A use case for this would be to list fragments either in a menu or when completing the URL.

*: document.anchors seems to be only for the `name` attribute and I haven't found a better solution than going through each node and checking if they have an `id` attribute