/
document.js
42 lines (40 loc) · 1.12 KB
/
document.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
var IncrementalDOM = require('../../index.js')
/*
Mock document objects and makes body an idom descrpitor to wrap the app
*/
var document = {
doctype: function () {
IncrementalDOM.text('<!doctype html>')
},
head: function () {
//document.doctype()
IncrementalDOM.elementOpen('head')
IncrementalDOM.elementVoid('link', null, [
'href', '//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css',
'rel', 'stylesheet',
'type', 'text/css'
])
IncrementalDOM.elementVoid('link', null, [
'href', '//localvoid.github.io/idom-dbmonster/styles.css',
'rel', 'stylesheet',
'type', 'text/css'
])
IncrementalDOM.elementClose('head')
},
body: function (partial) {
document.head()
IncrementalDOM.elementOpen('body')
partial()
// script comes later to allow first render while streaming
IncrementalDOM.elementOpen('script', null, [
'src', '//localvoid.github.io/idom-dbmonster/main.js'
])
IncrementalDOM.elementClose('script')
IncrementalDOM.elementClose('body')
},
getElementById: function (id) {
return this.elementById[id]
},
elementById: {}
}
module.exports = document