Skip to content

Consider new unique selector library #592

@danielnixon

Description

@danielnixon

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions