makeup-next-id
Assigns the next id in sequence to an element, if an id property does not already exist.
A vanilla JavaScript port of jquery-next-id.
Experimental
This module is still in an experimental state, until it reaches v1.0.0 you must consider all minor releases as breaking changes. Patch releases may introduce new features, but will be backwards compatible.
Install
npm install makeup-next-id
yarn add makeup-next-id
Example
const nextId = require('makeup-next-id');
const widgets = document.querySelectorAll('.widget');
widgets.forEach(function(el) {
nextId(el, 'widget');
});
Markup before:
<div class="widget"></div>
<div class="widget"></div>
<div class="widget"></div>
Markup after:
<div class="widget" id="widget-1"></div>
<div class="widget" id="widget-2"></div>
<div class="widget" id="widget-3"></div>
Custom Events
Dependencies
Polyfills
Development
npm start
npm test
npm run lint
npm run fix
npm run build
npm run clean
Test Reports
Each test run will generate the following reports:
/reports/coverage
contains Istanbul code coverage report/reports/html
contains HTML test report
CI Build
https://travis-ci.org/makeup-js/makeup-next-id
Code Coverage
https://coveralls.io/github/makeup-js/makeup-next-id