Type: EventTarget
addEventListener
type format:
delegation:
listener(e):
misc:
| throttle | (l)throttle | (t)throttle | (lt)throttle | debounce | (l)debounce | (t)debounce | (lt)debounce |
leading:| | fire | | fire | | fire | | fire |
100:| | | | | | | | |
200:| fire | fire | fire | fire | | | | |
300:| | | | | | | | |
400:| fire | fire | fire | fire | | | | |
500:| | | | | | | | |
600:| fire | fire | fire | fire | | | | |
trailing:| | | fire | fire | | | fire | fire |
this
:
removeEventListener
all arguments are optional
this
:
get Event data
this method is very unsafe and changed without any notice eventdata is live, changing it changes the handler itself
Array<{type: String, namespaces: Array, selector: String, listener: Function, options: Object}>
:
Type: Window
jQuery like selector
returns if length is 1 then Node else NodeList (this case contains empty list)
(Node | NodeList)
:
open by objective windowFeature
(WindowOpenOptions)
WindowProxy
:
window.$open({
url: 'http://example.jp',
left: 'auto', // 'auto' means parent's center
top: 'auto', // 'auto' means parent's center
width: 'auto', // 'auto' means parent's half
height: 'auto', // 'auto' means parent's half
});
asynchronous JavaScript And XML
request by fetch || XMLHttpRequest default is fetch, but options has progress or async:false faillback to XMLHttpRequest
$ajax(setup) returns new Object
set asynchronous JavaScript And XML
(any)
Type: Document
get Cookie accessor
document.$cookie.hoge; // getter
document.$cookie.hoge = 'value'; // setter
document.$cookie.hoge = { // setter with attributes
value: 'value',
path: "/path/to/cookie",
maxAge: 3600,
};
document.$cookie.hoge = null; // delete
document.$cookie(); // get all key-value object
document.$cookie({ // mass assign(keep other, no attributes use default attributes)
hoge: 'HOGE',
fuga: {
value: 'FUGA',
path: '/',
},
});
document.$cookie.$defaultAttributes({path: '/'}); // mass setting default attributes(keep other)
document.$cookie.$defaultAttributes = {path: '/'}; // mass assign default attributes(delete other)
set Cookie value
(Dictionary?)
document.$cookie = { // mass assign(delete other, no attributes use default attributes)
hoge: 'HOGE',
fuga: {
value: 'FUGA',
path: '/',
},
};
get top-layer element
in the future, ":top-layer" pseudo-class may come, but not now
Element?
:
create Element from tag, attributes, children
(String)
Element
:
document.$createElement('span', {
logicalFalse: false,
logicalTrue: true,
data: {
a: 'a',
b: 'b',
},
class: ['a', 'b', 'c'],
style: {
color: 'red',
backgroundColor: 'red',
},
}, 'plain', 'a>b');
// <span logicaltrue="" data-a="a" data-b="b" class="a b c" style="color:red;background-color:red;">plaina>b</span>
document.$createElement('span#id.c1.c2[a=A][b=B]');
// <span id="id" class="c1 c2" a="A" b="B"></span>
create CSSRule
(String??)
(CSSRule | CSSStyleRule)
:
Type: (Document | DocumentFragment | Element)
Type: Node
get Bag for anything
$('input').$bag.hoge; // getter
$('input').$bag.hoge = 'value'; // setter
$('input').$bag({hoge: 'value'}); // mass setting(keep other)
$('input').$bag(); // get all key-value object
mass assign $bag
(Dictionary?)
$('input').$bag = {hoge: 'value'}; // mass assign(delete other)
$('input').$bag = (node, i) => ({hoge: 'value'}); // mass assign by callback(delete other)
replace children
exhange parameter of replaceChild, and variadic
this
:
The parameter order, new before old, is unusual
trim whitespace textnode
this
:
unwrap parent
this
:
<section>
<div>
text
<span>span</span>
</div>
</section>
$('div').$unwrap();
<div>
text
<span>span</span>
</div>
unwrap children
this
:
<section>
<div>
text
<span>span</span>
</div>
</section>
$('div').$unwrapChildren();
<section>
text
<span>span</span>
</section>
polling request
options:
this
:
Type: Element
simple accessor to NamedNodeMap(attribute)
(Object | Function)
:
$$('input').$attrs.name; // getter
$$('input').$attrs.name = 'value'; // setter
$$('input').$attrs({name: 'value'}); // mass setting(keep other)
$$('input').$attrs(); // get all key-value object
// false is delete that attribute
$$('input').$attrs.name = false;
$$('input').$attrs({name: false});
// $prefix means inherited attribute
$$('input').$attrs.$disabled; // returns true if the parent is disabled even if itself none
mass assign NamedNodeMap(attribute)
(Dictionary)
$$('input').$attrs = {name: 'value'}; // mass assign(delete other)
$$('input').$attrs = (node, i) => ({name: 'value'}); // mass assign by callback(delete other)
simple accessor to DOMStringMap(dataset)
(Object | Function)
:
$$('input').$data.name; // getter
$$('input').$data.name = 'value'; // setter
$$('input').$data({name: 'value'}); // mass setting(keep other)
$$('input').$data(); // get all key-value object
$$('input').$data('prefix'); // get structured object
// $prefix means objective data
$$('input').$data.$hoge; // returns Object starting with hoge
mass assign DOMStringMap(dataset)
(Dictionary)
$$('input').$data = {name: 'value'}; // mass assign(delete other)
$$('input').$data = (node, i) => ({name: 'value'}); // mass assign by callback(delete other)
simple accessor to DOMTokenList(classList)
(Object | Function)
:
$$('input').$class.name; // getter(always boolean)
$$('input').$class.name = 'flag'; // setter(cast to boolean)
$$('input').$class({name: 'flag'}); // mass setting(keep other)
$$('input').$class(); // get all keys array
// object|array is treated like vue.js
$$('input').$class({name: false});
$$('input').$class([{name: false}, 'other']);
mass assign DOMTokenList(classList)
((Dictionary | Array))
$$('input').$class = {name: 'flag'}; // mass assign(delete other)
$$('input').$class = (node, i) => ({name: 'flag'}); // mass assign by callback(delete other)
simple accessor to CSSStyleDeclaration(style)
(Object | Function)
:
$$('input').$style.color; // getter
$$('input').$style.color = 'value'; // setter
$$('input').$style({color: 'value'}); // mass setting(keep other)
$$('input').$style(); // get all key-value object
$$('input').$style(true); // get all key-value object with important
// $prefix means computed style
$$('input').$style.$; // returns computed style
$$('input').$style.$color; // returns computed style's color
$$('input').$style['$color::after']; // returns computed style's pseudo color
mass assign CSSStyleDeclaration(style)
(Dictionary)
$$('input').$style = {color: 'value'}; // mass assign(delete other)
$$('input').$style = (node, i) => ({color: 'value'}); // mass assign by callback(delete other)
fade in element
this does not involve visibility, you have to do it ourselves.
((Number | TransitionOptions)
= 400
)
(TransitionOptions
= {}
)
Promise<Boolean>
:
node.hidden = false;
await node.$fadeIn();
fade out element
this does not involve visibility, you have to do it ourselves.
((Number | TransitionOptions)
= 400
)
(TransitionOptions
= {}
)
Promise<Boolean>
:
await node.$fadeOut();
node.hidden = true;
slide to down element
this does not involve visibility, you have to do it ourselves.
((Number | TransitionOptions)
= 400
)
(TransitionOptions
= {}
)
Promise<Boolean>
:
slide to top element
this does not involve visibility, you have to do it ourselves.
((Number | TransitionOptions)
= 400
)
(TransitionOptions
= {}
)
Promise<Boolean>
:
slide to right element
this does not involve visibility, you have to do it ourselves.
((Number | TransitionOptions)
= 400
)
(TransitionOptions
= {}
)
Promise<Boolean>
:
slide to left element
this does not involve visibility, you have to do it ourselves.
((Number | TransitionOptions)
= 400
)
(TransitionOptions
= {}
)
Promise<Boolean>
:
is metadata content
Boolean
:
mark matched text nodes
this
:
<hgroup>
<h1>this is header</h1>
<p>this is subheader</p>
</hgroup>
$('hgroup').$markText('is');
<hgroup>
<h1>th<mark>is</mark> <mark>is</mark> header</h1>
<p>th<mark>is</mark> <mark>is</mark> subheader</p>
</hgroup>
Type: HTMLElement
get width/height irrespective of css
┌margin────────────────────────────────────┐
│ │
│ ┌border───────────────────────────────┐ │
│ │ │ │
│ │ ┌padding ───────────────────────┬SB┐ │ │
│ │ │ │ │ │ │
│ │ │ ┌content─────────────────────┤ │ │ │
│ │ │ │ │ │ │ │
│ │ │ └-────────────────────────┤ │ │ │
│ │ │ │ │ │ │
│ │ ├───────────────────────────┴─┤ │ │
│ │ ├scroll bar────────────────────────┤ │ │
│ │ └─────────────────────────────┘ │ │
│ │ │ │
│ └──────────────────────────────────┘ │
│ │
└───────────────────────────────────────┘
((String | SizeOptions)
= {}
)
{width: Number, height: Number}
:
get visibilityState
specification:
Boolean
:
Type: HTMLTemplateElement
render template content
this is experimental, very magical,evil and slow.
vars:
rendered nodes are auto inserted to after this if specified insert:null, no inserted
NodeList
:
Type: (HTMLStyleElement | HTMLLinkElement)
Type: HTMLScriptElement
Type: HTMLAnchorElement
Type: HTMLImageElement
Type: HTMLDialogElement
Type: HTMLFormElement
writeback value to attribute
this
:
Type: (HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement)
set input default value
(any)
get input value
(null | String | Array | File | FileList)
:
set input value
this trigger $change event
(any)
clear input value
clear doesn't mean reset. all input set blank, uncheck, unselect, empty file
this
:
writeback value to attribute
this
:
Type: (HTMLInputElement | RadioNodeList)
get input indeterminate
returns undefined if not checkbox and supports RadioNodeList.
Boolean?
:
set input indeterminate
accepts Array of Boolean
Type: HTMLInputElement
get input value as date
datetime-like's valueAsDate is UTC timezone, but this property is local timezone
Date
:
<input id="time" type="time">
$('#time').value = '12:34';
$('#time').valueAsDate; // Thu Jan 01 1970 21:34:00 GMT+0900
$('#time').$valueAsDate; // Thu Jan 01 1970 12:34:00 GMT+0900
set input value as date
datetime-like's valueAsDate is UTC timezone, but this property is local timezone and triming value the format(by step|value)
(Date?)
<input id="time0" type="time" step="">
<input id="time1" type="time" step="1">
$('#time0').valueAsDate = new Date('2014-12-24T12:34:56.789');
$('#time1').valueAsDate = new Date('2014-12-24T12:34:56.789');
$('#time0').value; // '03:34:56.789'
$('#time1').value; // '03:34:56.789'
$('#time0').$valueAsDate = new Date('2014-12-24T12:34:56.789');
$('#time1').$valueAsDate = new Date('2014-12-24T12:34:56.789');
$('#time0').value; // '12:34'
$('#time1').value; // '12:34:56'
get input value as number
datetime-like delegates to $valueAsDate, and other work the same as native
Number
:
set input value as number
datetime-like delegates to $valueAsDate, and other work the same as native
(Number?)
get belonging RadioNodeList
RadioNodeList?
:
Type: (HTMLSelectElement | HTMLDataListElement)
set option elements
preserveValue
((Array<HTMLOptionElement> | Array<HTMLOptGroupElement> | Dictionary))
this
:
// object mode
$('select').$options({
a1: 'A1',
a2: {label: 'A1', 'data-custom': 'custom'},
b1: {label: 'B1', optgroup: 'optgroup'},
b2: {label: 'B2', optgroup: 'optgroup'},
c1: document.$createElement('option', {label: 'C1'}),
});
// array mode
$('select').$options([
'a1',
{value: 'a1', label: 'A1', 'data-custom': 'custom'},
{value: 'b1', label: 'B1', optgroup: 'optgroup'},
{value: 'b2', label: 'B2', optgroup: 'optgroup'},
document.$createElement('option', {value: 'c1', label: 'C1'}),
]);
Type: HTMLSelectElement
Type: RadioNodeList
Type: URL
assign URL parts
(Dictionary)
this
:
assign URL parts and new URL
(Dictionary)
this
:
shortcut to this.$assign({searchParams})
(Dictionary)
this
:
Type: URLSearchParams
from Entries
(Dictionary)
this
:
assign params
(Dictionary)
this
:
Type: FormData
from Entries
(Dictionary)
to SearchParam(unset File entry)
URLSearchParams
:
Type: Blob
Type: Storage
Type: DOMRectReadOnly
contains other Geometry interfaces
true:
┌this─────────────┐
│ │
│ ┌other ───────┐ │
│ │ │ │
│ │ │ │
│ └──────────┘ │
│ │
└───────────────┘
false:
┌this─────────────┐
│ │
│ ┌other ────┼──┐
│ │ │ │
│ │ │ │
│ └───────┼──┘
│ │
└───────────────┘
false:
┌this─────────────┐
│ │
│ │ ┌other ───────┐
│ │ │ │
│ │ │ │
│ │ └──────────┘
│ │
└───────────────┘
((DOMRectReadOnly | DOMPointReadOnly))
Boolean
:
intersect other Geometry interfaces
true:
┌this─────────────┐
│ │
│ ┌other ───────┐ │
│ │ │ │
│ │ │ │
│ └──────────┘ │
│ │
└───────────────┘
true:
┌this─────────────┐
│ │
│ ┌other ────┼──┐
│ │ │ │
│ │ │ │
│ └───────┼──┘
│ │
└───────────────┘
false:
┌this─────────────┐
│ │
│ │ ┌other ───────┐
│ │ │ │
│ │ │ │
│ │ └──────────┘
│ │
└───────────────┘
((DOMRectReadOnly | DOMPointReadOnly))
Boolean
:
Type: FileList
Type: NodeList
functional querySelector
return first element from tree, not per NodeList
Element?
:
<div>
<span>1</span>
<span>2</span>
</div>
<div>
<span>3</span>
<span>4</span>
</div>
$$('div').$('span');
// <span>1</span>
functional querySelectorAll
return matched elements from tree, not per NodeList
NodeList
:
<div>
<span>1</span>
<span>2</span>
</div>
<div>
<span>3</span>
<span>4</span>
</div>
$$('div').$$('span');
// [<span>1</span>, <span>2</span>, <span>3</span>, <span>4</span>]
functional querySelectorAll with self
return matched elements from self and tree, not per NodeList
NodeList
:
<div>
<span>1</span>
<span>2</span>
</div>
<div>
<span>3</span>
<span>4</span>
</div>
$$('div').$$$('div,span');
// [<div></div>, <span>1</span>, <span>2</span>, <div></div>, <span>3</span>, <span>4</span>]
Type: (FileList | NodeList | DataTransferItemList)