-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (27 loc) · 834 Bytes
/
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
const { h, patch } = tinyVirtualDom;
const $rootElement = document.getElementById('app');
var currentTree = h('ul', null,
h('li', { style: { color: '#090' } }, 'One'),
h('li', { style: { color: '#900' } }, 'Two'),
h('li', { style: { color: '#009' } }, 'Three')
);
// first time
patch($rootElement, currentTree);
// wait 2 secs
setTimeout(() => {
let nextTree = h('ul', null,
h('li', { style: { color: '#090' } }, 'One'),
h('li', { style: { color: '#909' } }, 'Two')
);
patch($rootElement, nextTree, currentTree);
currentTree = nextTree;
}, 2000);
// wait 4 secs
setTimeout(() => {
let nextTree = h('ul', null,
h('li', { style: { color: '#111' } }, 'Hello'),
h('li', { style: { color: '#999' } }, 'Hi!')
);
patch($rootElement, nextTree, currentTree);
currentTree = nextTree;
}, 4000);