This repository was archived by the owner on Jan 9, 2026. It is now read-only.
forked from jaandrle/dollar_dom_component
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_p2.sub.html
More file actions
28 lines (23 loc) · 1.32 KB
/
example_p2.sub.html
File metadata and controls
28 lines (23 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
gulp_place("app._BUILD_.example_el= toELID(app._BUILD_.example_el_id++)", "eval");
gulp_place("app._BUILD_.example_onkeyup= toKeyUp(app._BUILD_.example_el)", "eval");
<p>The same example with using JavaScript desctructuring syntax:</p>
<div class="output" id="gulp_place('app._BUILD_.example_el', 'variable')"></div>
<script onkeyup="gulp_place('app._BUILD_.example_onkeyup', 'variable')" contenteditable="">
(function(element_id){
//EXAMPLE START
const container= document.getElementById(element_id);
textInputComponent({ label_type: "name", placeholder: "Peter" }).mount(container);
textInputComponent({ label_type: "surname", placeholder: "Black" }).mount(container);
function textInputComponent({ label_type= "name", placeholder }){
const { add, share, update }= $dom.component("DIV");
add("LABEL", { textContent: `Type your ${label_type}: ` });
add("INPUT", { type: "text", placeholder, onkeyup });
add("P", { textContent: `Your ${label_type} is: ` }, -2);
add("STRONG", null).onupdate({ textContent: " - " }, ({ textContent })=> ({ textContent }));
return share;
function onkeyup(){ update({ textContent: this.value }); }
}
//EXAMPLE END
})("gulp_place('app._BUILD_.example_el', 'variable')");
</script>
<!-- example source links -->