
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
generate_dom_id
Advanced tools
This module facilitates generate ids for dom elements
npm install generate_dom_id@latest -S
const GenerateDomId = require('../generate_dom_id');
var gen = new GenerateDomId('main');
gen.inc();
// <input id=main_1_1 type="text" /><label for="main_1_1"></label>
// <input id=main_1_2 type="text" /><label for="main_1_2">
console.log(blockA(gen.getSub()));
gen.inc();
// <div id=main_2_1>
// <p id=main_2_2>Hello world</p>
// </div>
console.log(blockB(gen.getSub()));
gen.inc();
// main_3_1
console.log(blockC(gen.getSub()));
function blockA(gen) {
var html = '';
for (var i = 0; i < 100; i++) {
var id = gen.inc();
html +=
'<input id='+id+' type="text" />'+
'<label for="'+id+'"></label>';
}
return html;
}
function blockB(gen) {
var html =
`<div id=${gen}>
<p id=${gen}>Hello world</p>
</div>`;
return html;
}
function blockC(gen) {
var id = gen.inc();
var html =
`<div>
<button id=${gen}>Remove</button>
</div>`;
return id;
}
npm run test
FAQs
Generate ids for html code
We found that generate_dom_id demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.