makeup-next-id
Advanced tools
Comparing version 0.4.1 to 0.4.2
{ | ||
"dependencies":[ | ||
"require: ./dist/index.js" | ||
] | ||
"dependencies": ["require: ./dist/index.js"] | ||
} |
@@ -7,5 +7,5 @@ "use strict"; | ||
exports.default = _default; | ||
var sequenceMap = {}; | ||
var defaultPrefix = 'nid'; | ||
var randomPortion = createRandomPortion(3); | ||
const sequenceMap = {}; | ||
const defaultPrefix = "nid"; | ||
const randomPortion = createRandomPortion(3); | ||
function randomNumber(max) { | ||
@@ -15,11 +15,11 @@ return Math.floor(Math.random() * max); | ||
function createRandomPortion(size) { | ||
var letters = 'abcdefghijklmnopqrstuvwxyz'; | ||
var digits = '0123456789'; | ||
var allChars = letters + digits; | ||
const letters = "abcdefghijklmnopqrstuvwxyz"; | ||
const digits = "0123456789"; | ||
const allChars = letters + digits; | ||
// to ensure a valid HTML ID (when prefix is empty), first character must be a letter | ||
var portion = letters[randomNumber(25)]; | ||
let portion = letters[randomNumber(25)]; | ||
// start iterating from 1, as we already have our first char | ||
for (var i = 1; i < size; i++) { | ||
for (let i = 1; i < size; i++) { | ||
portion += allChars[randomNumber(35)]; | ||
@@ -30,7 +30,7 @@ } | ||
function _default(el) { | ||
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultPrefix; | ||
var separator = prefix === '' ? '' : '-'; | ||
let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultPrefix; | ||
const separator = prefix === "" ? "" : "-"; | ||
// join first prefix with random portion to create key | ||
var key = "".concat(prefix).concat(separator).concat(randomPortion); | ||
const key = "".concat(prefix).concat(separator).concat(randomPortion); | ||
@@ -40,5 +40,5 @@ // initialise key in sequence map if necessary | ||
if (!el.id) { | ||
el.setAttribute('id', "".concat(key, "-").concat(sequenceMap[key]++)); | ||
el.setAttribute("id", "".concat(key, "-").concat(sequenceMap[key]++)); | ||
} | ||
return el.id; | ||
} |
{ | ||
"name": "makeup-next-id", | ||
"description": "Assign the next id in sequence to an element, if an id property does not already exist.", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"main": "./dist/cjs/index.js", | ||
@@ -13,3 +13,3 @@ "module": "./dist/mjs/index.js", | ||
}, | ||
"repository": "https://github.com/makeup/makeup-js/tree/master/packages/makeup-next-id", | ||
"repository": "https://github.com/makeup/makeup-js/tree/master/packages/core/makeup-next-id", | ||
"author": "Ian McBurnie <ianmcburnie@hotmail.com>", | ||
@@ -37,3 +37,4 @@ "license": "MIT", | ||
"extends @ebay/browserslist-config" | ||
] | ||
], | ||
"gitHead": "4d199965cba30b5f63cfc38b5b58544cfc5b27c1" | ||
} |
@@ -15,6 +15,6 @@ # makeup-next-id | ||
// import the module | ||
import nextId from 'makeup-next-id'; | ||
import nextId from "makeup-next-id"; | ||
// get NodeList | ||
const widgetEls = document.querySelectorAll('.widget'); | ||
const widgetEls = document.querySelectorAll(".widget"); | ||
@@ -41,12 +41,12 @@ // assign next id to each element | ||
## Custom Events | ||
## Custom Events | ||
* None | ||
- None | ||
## Dependencies | ||
* [nanoid](https://www.npmjs.com/package/nanoid) | ||
- [nanoid](https://www.npmjs.com/package/nanoid) | ||
## Polyfills | ||
* None | ||
- None |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
6615
101