
Noliter
Write code with no literal and get tiny bundle
Install
npm install noliter
API
Constants
DOM manipulation
ga/sa
ga
is abbreviation of get attribute
.
sa
is abbreviation of set attributes
.
import {
$,
TAG_NAME_DIV,
ATTR_ID,
ATTR_CLASS
} from 'noliter';
const div = $(TAG_NAME_DIV)
.sa(
ATTR_ID, 'my-id',
ATTR_CLASS, 'class-name'
);
div.ga(ATTR_ID) === 'my-id';
div.ga(ATTR_CLASS) === 'class-name';
gp/sp
gp
is abbreviation of get property
.
sp
is abbreviation of set properties
.
import {
$,
TAG_NAME_INPUT,
PROP_CHECKED,
PROP_DISABLED
} from 'noliter';
const input = $(TAG_NAME_INPUT)
.sp(
PROP_CHECKED, true,
PROP_DISABLED, true
);
div.gp(PROP_CHECKED) === true;
div.gp(PROP_DISABLED) === true;
add
This method appends multiple parameters as children.
You can pass string
or element
or instance
.
import {
$,
TAG_NAME_DIV
} from 'noliter';
$(TAG_NAME_DIV)
.add(
'text',
document.createElement('div'),
$(TAG_NAME_DIV)
);
on
It's same with addEventListener
method.
import {
$,
TAG_NAME_BUTTON,
EVENT_TYPE_BLUR,
EVENT_TYPE_FOCUS
} from 'noliter';
$(TAG_NAME_BUTTON)
.add('click me')
.on(
EVENT_TYPE_BLUR,
() => console.log('blur')
)
.on(
EVENT_TYPE_FOCUS,
() => console.log('focus'),
{ passive: true }
);