-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathjson.js
More file actions
55 lines (44 loc) · 1.07 KB
/
Copy pathjson.js
File metadata and controls
55 lines (44 loc) · 1.07 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
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
import { html, svg } from '../src/json/index.js';
const assert = (ok, message) => {
if (!ok) throw new Error(message);
};
function Rect(props) {
console.log(props.children[1]);
return svg`<rect x=${props.a} y=${props.b} />`;
}
const render = (where, what) => {
where(String(typeof what === 'function' ? what() : what));
};
render(console.log, html`<div><template><p test=${'ok'} />${'value'}</></div>`);
render(console.log, html`
<div hidden>
<p class=${'test'}>Hello</p>
<hr />
<svg>
<rect hidden />
</svg>
${'World'}
<rect />
</div>
`);
render(console.log, html`
<${Rect} a="1" b=${2} ?c=${false} ?d=${true}>
<p>Component</p>
</>
`);
render(console.log, html`
<!doctype html>
<texatea prop="value" />
<style> test </style>
<script> ${'test'} </script>
<p />
`);
render(console.log, html`
<!-- comment -->
<p />
<table><td /></>
<table><tr class=${'test'} /></>
<p />
`);
render(console.log, html`<hr><br>`);
render(console.log, html`<a ...${'props'} /> b`);