-
Notifications
You must be signed in to change notification settings - Fork 1
/
literal.js
47 lines (43 loc) · 812 Bytes
/
literal.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
const assert = require('assert')
const hv = require('..')
assert.strictEqual(hv(`
<script>var s
</script>
`),
`var s
`)
assert.strictEqual(hv(`
<ul>
<li each="item in state.items" key={item}>
<script>view(props, state)</script>
</li>
</ul>
`),
`h('ul', null, (state.items || []).map(function ($value, $index, $target) {
var item = $value
return h('li', { 'key': (item) }, view(props, state))
}, this))
`)
assert.strictEqual(hv(`
<ul>
<script each="item in state.items" key={item}>
view(item, actions)
</script>
</ul>
`),
`h('ul', null, (state.items || []).map(function ($value, $index, $target) {
var item = $value
return view(item, actions)
}, this))
`)
assert.strictEqual(hv(`
<script>
const a = 'foo'
</script>
<ul>
<li></li>
</ul>
`),
`const a = 'foo'
h('ul', null, h('li'))
`)