Published npm package inputid

Published npm package inputid

Mar 24, 2021

I published a npm package:

https://www.npmjs.com/package/inputid

A Javascript value object representing an HTML form control ID, making sure the ID generation is deterministic and unique in a document.

[...]

Features

  • Deterministic ID generation based on HTML element attributes

  • Unique ID generation in a document

  • ID sanitization according to the document type

  • Removal of characters that might be problematic in CSS selectors

  • ID generation to find an element by its ID attribute or its related labels


[...]

An InputId instantiation is a value object representing a form control ID. It should be immutable and can be used as a String.

It doesn't require any arguments or configuration:

const InputId = require('inputid');

labelElement.htmlFor = inputElement.id = new InputId();

But you'd get better results if an HTML element or options are provided as an argument.

[...]

Enjoy this post?

Buy Pedro Amaral Couto a coffee