
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
dom-for-node
Advanced tools
v3.*
_dom.js is focused on html and css creation.
The purposes of _dom.js are:
API documentation.
<script src="./path/to/_dom.js"></script>
For web translators like webpack.
Install :
npm install dom-for-node
Import (js) :
const _dom=require('dom-for-node');
Import (ts) :
import _dom from 'dom-for-node';
_dom(tagName,datas,childs,nameSpace)
string tagName : element tagnameobject datas [optional] : element attributes.Array childs [optional] : element childs. can contain strings and html elements.string nameSpace [optional] : element namesapace if any.HTMLElementExemple:
var inpt=_dom('input',{type:'text',value:'hello'});
document.body.appendChild(inpt);
var div=_dom('div',{style:{border:'solid 1px #0f0'}},[
'aaa',
_dom('u',['bbb']}),
'ccc'
]);
document.body.appendChild(div);
_dom.rule(selector, datas)
string selector : the new rule rule query selector.object datas [optional] : style datas if any.CSSStyleRuleExemple :
var tableRule=_dom.rule('table',{border:'solid 1px #0f0'});
setTimeout(function(){
tableRule.style.borderColor='#00f';
},2000);
_dom.rules(datas)
datas : sass like structured object.CSSStyleRule by selector and alias.Exemple :
var rules =_dom.rules({
'$color1':'#0f0',
'$color2':'#f00',
'table':{
border:'solid 1px $color1',
'& td':{
'&>div':{
alias:'subdiv',
border:'solid 1px $color2',
display:'block'
}
}
}
});
setTimeout(function(){
rules.table.style.borderColor='#00f';
rules.subdiv.style.color='#d06';
},2000);
Exemple
TS :
/**
* creates an Table of 1 line.
* @param {Array} childlist columns contents.
*/
export class TableLineModel extends DomModel {
static rulesData = {
">table": {
border: 'solid 1px #f00',
'>tr>td': {
border: 'solid 1px #00f',
}
},
};
private _container = _dom('td', {});
_domOnBuild(children?: (HTMLElement|string):[]): HTMLTableElement {
if(children)children.forEach(c=>this._container.append(c));
return _dom('table', { cellPadding: 0, cellSpacing: 0, border: 0 }, [
_dom('tbody', {}, [this._container])
]);
}
push(element:HTMLElement|string){
this._container.append(element);
}
}
/**
* creates an Table of 1 line.
* @param {Array} childlist columns contents.
*/
export class TableLineModel extends _dom.DomModel {
static rulesData = {
">table": {
border: 'solid 1px #f00',
'>tr>td': {
border: 'solid 1px #00f',
}
},
};
_container = _dom('td', {});
_domOnBuild(children) {
if(children)children.forEach(c=>this._container.append(c));
return _dom('table', { cellPadding: 0, cellSpacing: 0, border: 0 }, [
_dom('tbody', {}, [this._container])
]);
}
push(element){
this._container.append(element);
}
}
var tl=new TableLineModel(['000',_dom('div',{},['abc'])]);
// append element.
document.body.appendChild(tl.dom);
setTimeout(function(){
// calls component 'push' method.
tl.push('def');
},2000);
_dom.model(tagName,constructor,cssRules)
string tagName : the custom element name.
Must contain at least one "-" to avoid conflict with natives HTMLElements.
function constructor : Must return an HTMLElement.
Receive the arguments from _dom but the dont have to respect the classical nomenclature excepted tagName (the first).
object|function cssRules [optional] : is or returns an object describing rules like _dom.rules,
but the created collection will be insancied only once and shared among interfaces.
NB : You can use the Model creator to help generate model code.
_dom.model('table-line',function(tagName,children){
var doms={};
var build=function(){
doms.container = _dom('td', {});
if(children)children.forEach(c=>this._container.append(c));
doms.root = _dom('table', { cellPadding: 0, cellSpacing: 0, border: 0 }, [
_dom('tbody', {}, [doms.container])
]);
doms.root.push=function(element){
this._container.append(element);
};
};
build();
return doms.root;
},{
">table": {
border: 'solid 1px #f00',
'>tr>td': {
border: 'solid 1px #00f',
}
},
});
// ------ use
var tl=_dom('table-line',['000',_dom('div',{},['abc'])]);
// append element.
document.body.appendChild(tl.dom);
setTimeout(function(){
// calls component 'push' method.
tl.push('def');
},2000);
To create fast and easy the backbone of your component, you can use the model creator.(legacy js).
FAQs
v3.\*
We found that dom-for-node demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.