0.5.2 • Published 3 months ago

makeup-next-id v0.5.2

Weekly downloads
98
License
MIT
Repository
-
Last release
3 months ago

makeup-next-id

Assigns the next id in sequence to an element, if an id property does not already exist.

The id will consist of a configurable prefix (default: 'nid'), followed by three randomly generated chars, then a number in sequence. For example: nid-sdv-1, nid-sdv-2, nid-sdv-3, etc.

Experimental

This module is still in an experimental state, until it reaches v1 you must consider all minor releases as breaking changes.

Example

// import the module
import nextId from "makeup-next-id";

// get NodeList
const widgetEls = document.querySelectorAll(".widget");

// assign next id to each element
widgetEls.forEach((el) => nextId(el));

Markup before:

<div class="widget"></div>
<div class="widget"></div>
<div class="widget"></div>

Markup after:

<div class="widget" id="nid-tCa-1"></div>
<div class="widget" id="nid-tCa-2"></div>
<div class="widget" id="nid-tCa-3"></div>

Custom Events

  • None

Dependencies

Polyfills

  • None
0.5.2

3 months ago

0.5.1

5 months ago

0.5.0

7 months ago

0.4.2

7 months ago

0.4.1

2 years ago

0.3.0

3 years ago

0.4.0

3 years ago

0.2.0

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.3

6 years ago

0.0.2

7 years ago

0.0.1

7 years ago