Skip to content

v6.0.0

Choose a tag to compare

@ten1seven ten1seven released this 28 Oct 19:13
· 2 commits to main since this release

A rewrite in TypeScript on modern browser APIs. The data attributes, the session storage keys, the API and the dist/what-input.js file path are unchanged, so for most sites this is a drop-in upgrade.

  • Breaking: Drops support for Internet Explorer and other legacy browsers. The build targets ES2022 and is no longer transpiled.
  • Breaking: Detection is built on Pointer Events only. The mousedown, mousemove, touchstart, touchend, MSPointerDown, MSPointerMove, mousewheel and DOMMouseScroll listeners (and the 200ms touch-versus-mouse buffer they required) are gone.
  • Breaking: clearStorage() now removes only What Input's own what-input and what-intent keys instead of wiping the entire session storage.
  • Breaking: pointerdown now updates the intent as well as the input, even while a form field has focus. Only keyboard use inside form fields is buffered.
  • Breaking: unRegisterOnChange(fn) removes fn from both the input and intent lists.
  • Breaking: The InputMethod type no longer includes pointer, which was never actually reported.
  • Breaking: Requires Node 20+ for development. The build uses esbuild, the demo uses Vite and the tests use Vitest; Gulp, Webpack, Babel, Sass and Yarn are gone.
  • Added: A data-whathint attribute, ask('hint') and a hint event report what the device's primary pointer suggests (mouse, touch or unknown) from the pointer interaction media feature, before any interaction and live as devices are attached or removed. The existing attributes never use it.
  • Added: A data-whatfreeze attribute opts any element (or container) into the same intent buffering that form fields get, for custom controls driven by the arrow keys (#123).
  • Added: An ES module build (dist/what-input.mjs) with a proper exports map, module and unpkg fields. The UMD build (dist/what-input.js) and the minified build remain for <script> tags, CommonJS and AMD.
  • Added: whatInput is an EventTarget and dispatches input and intent events.
  • Added: whatInput.destroy() tears everything down (listeners are bound with an AbortController).
  • Added: ignoreKeys() and specificKeys() accept KeyboardEvent.key and KeyboardEvent.code strings alongside legacy keycodes. The defaults are now key names.
  • Added: Typing inside contenteditable elements and form-associated custom elements no longer changes the intent, just like form fields.
  • Fixed: Pressing a key on a checkbox or radio button switches the intent to keyboard; they are toggled, not typed into (#128).
  • Fixed: Long-presses in Firefox for Android no longer flash data-whatintent="mouse", because the emulated mouse events are no longer listened to (#94).
  • Added: Focus inside open shadow roots is reported for the inner element (via composedPath()), and the active-element check follows shadow roots when deciding whether a keypress is text entry.
  • Added: Persisted session storage values are validated before they are used.
  • Changed: Type declarations are generated from the source and shipped in dist/.
  • Changed: pointerdown and keydown are observed in the capture phase on window, so whatInput.ask() is already up to date inside any element's own event handler, even one that calls preventDefault() or stopPropagation() (#80).
  • Changed: When the script runs after DOMContentLoaded (dynamic import(), late-loaded scripts) the initial state is published immediately instead of never.
  • Changed: An interaction that happens before DOMContentLoaded is no longer overwritten by the persisted value.
  • Fixed: data-whatclasses separates all classes with commas (a,b,c); previously only the first space was replaced.
  • Fixed: data-whatclasses is removed when focus moves to an element without classes.

Install: npm install what-input@6 · Demo: https://ten1seven.github.io/what-input · Docs: README