UNPKG

@ulu/frontend

Version:

A versatile SCSS and JavaScript component library offering configurable, accessible components and flexible integration into any project, with SCSS modules suitable for modern JS frameworks.

22 lines (19 loc) 342 B
/** * @module utils/id */ let idCount = 0; /** * Create new uid */ export function newId() { return `ulu-uid-${ ++idCount }`; } /** * Sets an ID if element doesn't have one vie newUid * @param {Node} element Element to make sure has an id */ export function ensureId(element) { if (!element.id) { element.id = newId(); } }