-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
44 lines (39 loc) · 955 Bytes
/
app.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
//////////////////////////////
// node-jsdom-starter //
//////////////////////////////
// Run:
// $ cd node-jsdom-starter
// $ npm install
// $ node app
// Imports
import { JSDOM } from 'jsdom';
import { dna } from 'dna-engine';
// Setup
const html = `
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Tasks</title>
</head>
<body>
<p id=task class=dna-template>~~title~~</p>
</body>
</html>
`;
const dom = new JSDOM(html);
dna.initGlobal(dom.window);
// To Do Application
const app = () => {
dna.clone('task', { title: 'Order bulgogi' });
dna.clone('task', { title: 'Eat bulgogi' });
};
app();
// Output
console.log();
console.log('Data model:');
console.log(dna.getModels('task'));
console.log();
console.log('Task elements:');
const elems = [...dom.window.document.getElementsByClassName('task')];
elems.forEach(elem => console.log(elem.outerHTML));