# invokers-polyfill

> This polyfills the HTML `command`/`commandfor`, as proposed by the Open UI group.

Latest version **1.0.4** (published 2026-08-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install invokers-polyfill
pnpm add invokers-polyfill
yarn add invokers-polyfill
bun add invokers-polyfill
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2026-08-20 |
| First published | 2023-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 156 |
| Author | Keith Cirkel |
| Maintainers | keithamus |

## Links

- npm: https://www.npmjs.com/package/invokers-polyfill
- Repository: https://github.com/keithamus/invokers-polyfill
- Homepage: https://github.com/keithamus/invokers-polyfill#readme
- Issues: https://github.com/keithamus/invokers-polyfill/issues
- npm.io page: https://npm.io/package/invokers-polyfill

## Recent versions

- 1.0.4 (latest) — 2026-08-20
- 1.0.3 — 2026-04-09
- 1.0.2 — 2026-03-30
- 1.0.1 — 2026-03-03
- 1.0.0 — 2026-03-02
- 0.6.1 — 2026-01-07
- 0.6.0 — 2026-01-07
- 0.5.7 — 2025-08-29
- 0.5.6 — 2025-08-05
- 0.5.5 — 2025-05-27
- 0.5.4 — 2025-04-28
- 0.5.3 — 2025-04-28
- 0.5.2 — 2025-02-25
- 0.5.1 — 2025-02-24
- 0.5.0 — 2025-02-24
- … 17 more at https://npm.io/package/invokers-polyfill/versions

## README

# Invoker Buttons Polyfill

This polyfills the HTML [`commandfor`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/commandForElement)/[`command`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLButtonElement/command) attributes, as proposed by the Open UI group.

To see the explainer of these, please visit https://open-ui.org/components/invokers.explainer/,
and have a look at the [MDN Invoker Commands API Docs](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API).

## Installation

### With npm

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
is mapped to `/fn`:

```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
<!-- polyfill automatically -->
<script
  type="module"
  async
  src="https://unpkg.com/invokers-polyfill@latest/invoker.min.js"
></script>
```

```html
<!-- polyfill manually -->
<script type="module" async>
  import {isSupported, apply} from "https://unpkg.com/invokers-polyfill@latest/invoker.js"
  if (!isSupported()) apply();
</script>
```

## Usage

With the module imported, you can add `commandfor` and `command` attributes to your HTML:

```html
<button commandfor="my-dialog" command="show-modal">Open Dialog!</button>
<dialog id="my-dialog">I'm a dialog!</dialog>
```

## Supported commands

The following built-in commands (aligned with current spec) are supported:

* `toggle-popover`/`open-popover`/`close-popover`
* `show-modal`: open a `<dialog>` element in modal mode
* `close`: close a `<dialog>` open (either in modal or non-modal mode)
* `request-close`: close a `<dialog>` but emit a `cancel` event first, allowing a user to eventually prevent it. `requestClose` is only available from Safari 18.4, the `requestClose` will be polyfilled on older browsers.

## Limitations

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.

---
_Source: https://npm.io/package/invokers-polyfill · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
