This repository was archived by the owner on Dec 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
73 lines (50 loc) · 2.16 KB
/
index.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { html, render } from "./web_modules/lighterhtml.js";
import { html as HTML, render as Render } from "./web_modules/heresy.js";
import { Greetings, GreetingsOld, renderListDOMNode } from "./src/lighterHTML-example.js";
import { Greet } from "./src/heresy-example.js";
import { test } from "./src/test.js";
import { React, ReactDOM } from "https://unpkg.com/es-react";
import htm from 'https://unpkg.com/htm?module';
const reacthtml = htm.bind(React.createElement);
//this thing actually works
test()
//lighterHTML
const list1 = ["Hello", 1 ];
const list2 = ["egg", "<b>Bread</b>", "Coffee" ];
const list3 = ["Hello", '<b>Sam</b>'];
const list4 = ["Hello", html`<b>Sam</b>`];
document.querySelector('.app').append(renderListDOMNode(list1));
document.querySelector('.app').append(renderListDOMNode(list2));
document.querySelector('.app').append(renderListDOMNode(list3));
document.querySelector('.app').append(renderListDOMNode(list4));
const folks = ["John","Baba", "Jane"]
render(document.querySelector('.app'), Greetings(folks));
Render(document.querySelector('.app2'), HTML`<Greet props=${{name: "Abdul"}} />`)
//Some comparsions
console.group("React");
console.log("React component(instance) is object(function of its props and state):");
class HelloWorld extends React.Component {
render() {
return (
reacthtml`<div>Hello World!</div>`
)
}
}
console.log(" React <HelloWorld /> :");
console.dir( reacthtml`<HelloWorld />`);
console.groupEnd();
console.group("lighterHTML");
console.log("But what does lighterHTML & Heresy's html`` give you ?");
console.log(" lighterHTML's html`` gives you:");
console.log(" const Greet = name => html`<p>Hello ${name}!</p>`; \n Greet(John)");
console.log( GreetingsOld(folks).firstChild);
console.log(" DocumentFragment!?, heard that before https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment")
console.log( " or a collection of them:")
console.dir(GreetingsOld(folks));
console.groupEnd();
console.group("Heresy");
//heresy
console.log("Hesery's html`` gives you:");
console.log(" html`<Greet props=${{name: 'Abdul'}} />`");
console.dir(HTML`<Greet props=${{name: "Abdul"}} />`);
console.groupEnd();