-
Notifications
You must be signed in to change notification settings - Fork 4
Description
oaf-routing needs to generate a unique CSS selector from a DOM element. It does this so it can serialise a unique specifier for the focused element just before a router navigation event rewrites the DOM. When the user navigates back or forward in their browser chrome, we restore the focused element, emulating what at least some browsers (Firefox, Safari) do natively.
Since forever, oaf-routing has used https://www.npmjs.com/package/unique-selector for this.
There are other libraries that have more weekly downloads, more stars and more recent releases. For example: https://www.npmjs.com/package/@medv/finder
I've recently made it possible to specify your own function to generate unique CSS selectors from a given element, so anyone is free to pass in @medv/finder or any other library or non-library solution (including a function that simply always returns undefined if focus restoration is not wanted).
With that change in place, it might even be worth removing the dependency on any selector library and forcing the caller to bring their own. That would decrease bundle size, etc.