$dom.component / $dom / component_mainOut
$dom.component_mainOut
Name | Type |
---|---|
elOut |
extends T_DOM_HETNM [keyof T_DOM_HETNM ] = HTMLElement |
-
component_mainOut
▸ destroy(): void
Method remove element form live DOM and returns null
let c= $dom.component("DIV", null);
c.mount(document.body, "replaceContent");
c= c.share.destroy();
//=> c===null AND <body></body>
void
▸ isStatic(): boolean
Methods returns if it was onupdate
used
boolean
▸ mount(el
, type?
): elOut
Add element to live DOM
Name | Type | Description |
---|---|---|
el |
HTMLElement |
Element where to places this component |
type? |
"replace" | "after" | "before" | "replaceContent" | "childFirst" | "childLast" |
Default childLast |
elOut
▸ update(data
): boolean
Method updates all registered varibles by keys onupdates
and calls follower functions
// SIMPLE example
const data_A= { a: "A" };
const data_A_update= { a: "AAA" };
const c= $dom.component("UL", null);
c.add("LI", null)
.onupdate(data_A, ({ a })=>({ textContent: a }));//`{ a }` add listener for "a"
c.mount(document.body);
c.update(data_A_update);
// EXAMPLE WITH `mapUpdate`
const data_B= { a: { b: "A" }};
const data_B_update= { a: { b: "AAA" }};
const c= $dom.component("UL", null, { mapUpdate: d=>({ a: d.a.b }) });
c.add("LI", null)
.onupdate(data_B, ({ a })=>({ textContent: a }));
c.mount(document.body);
c.update(data_B_update);
Name | Type | Description |
---|---|---|
data |
object |
Updates internal storage (via Object.assign – no deep copy!) |
boolean
▸ update(map
): boolean
Method updates all registered varibles by keys onupdates
and calls follower functions
// EXAMPLE WITH FUNCTION AS ARGUMENT OF `update`
const c= $dom.component("UL", null, { mapUpdate: d=>({ a: d.a.b }) });
c.add("LI", null)
.onupdate({ a: 1 }, ({ a })=>({ textContent: a }));
c.mount(document.body);
c.update(({ a })=> { a: ++a });
Name | Type | Description |
---|---|---|
map |
(data : object ) => object |
Function takes as parameter previous internal storage and returns updated one (internally used Object.assign – no deep copy!) |
boolean