This polyfills the HTML `invoketarget`/`invokeaction`, as proposed by the Open UI group.
npm install invokers-polyfillThis polyfills the HTML commandfor/command attributes, as proposed by the Open UI group.
To see the explainer of these, please visit https://open-ui.org/components/invokers.explainer/.
If you're using npm, you only need to import the package, like so:
``js`
import "invokers-polyfill";
This will automatically apply the polyfill if required.
If you'd like to manually apply the polyfill, you can instead import the isSupported and apply functions directly from the ./invoker.js file, which/fn
is mapped to :
`js`
import { isSupported, apply } from "invokers-polyfill/fn";
if (!isSupported()) apply();
An isPolyfilled function is also available, to detect if it has been polyfilled:
`js`
import { isSupported, isPolyfilled, apply } from "invokers-polyfill/fn";
if (!isSupported() && !isPolyfilled()) apply();
Alternatively, if you're not using a package manager, you can use the unpkg script:
`html`
type="module"
async
src="https://unpkg.com/invokers-polyfill@latest/invoker.min.js"
>
`html`
With the module imported, you can add commandfor and command attributes to your HTML:
`html`
The following built-in commands (aligned with current spec) are supported:
* toggle-popover/open-popover/close-popovershow-modal
* : open a
This polyfill does not handle the aria (e.g. aria-expanded`) of the command button the way browsers do. You are _strongly_ encouraged to handle this state yourself, to ensure your site is accessible.