|
@@ -1,4 +1,5 @@
|
1
|
1
|
const util = require('util')
|
|
2
|
+const selfClosingTags = require('./util/selfClosingTags')
|
2
|
3
|
|
3
|
4
|
module.exports = class Compiler {
|
4
|
5
|
constructor(tree, context) {
|
|
@@ -6,27 +7,6 @@ module.exports = class Compiler {
|
6
|
7
|
this.context = context
|
7
|
8
|
this.pos = 0
|
8
|
9
|
this.result = ''
|
9
|
|
- this.selfClosingTags = [
|
10
|
|
- 'area',
|
11
|
|
- 'base',
|
12
|
|
- 'br',
|
13
|
|
- 'col',
|
14
|
|
- 'command',
|
15
|
|
- '!doctype',
|
16
|
|
- '!DOCTYPE',
|
17
|
|
- 'embed',
|
18
|
|
- 'hr',
|
19
|
|
- 'img',
|
20
|
|
- 'input',
|
21
|
|
- 'keygen',
|
22
|
|
- 'link',
|
23
|
|
- 'menuitem',
|
24
|
|
- 'meta',
|
25
|
|
- 'param',
|
26
|
|
- 'source',
|
27
|
|
- 'track',
|
28
|
|
- 'wbr',
|
29
|
|
- ]
|
30
|
10
|
this.standardLibrary = {
|
31
|
11
|
cond: function(predicate, left, right) {
|
32
|
12
|
if (predicate) {
|
|
@@ -87,7 +67,7 @@ module.exports = class Compiler {
|
87
|
67
|
result += compiler.compile()
|
88
|
68
|
})
|
89
|
69
|
|
90
|
|
- if (!this.selfClosingTags.includes(node.functionName.name)) {
|
|
70
|
+ if (!selfClosingTags.includes(node.functionName.name)) {
|
91
|
71
|
result += `</${node.functionName.name}>`
|
92
|
72
|
}
|
93
|
73
|
|