소스 검색

Move list of selfclosing tags into its own module

master
Dylan Baker 5 년 전
부모
커밋
a3e6a6df66
2개의 변경된 파일24개의 추가작업 그리고 22개의 파일을 삭제
  1. 2
    22
      src/compiler.js
  2. 22
    0
      src/util/selfClosingTags.js

+ 2
- 22
src/compiler.js 파일 보기

@@ -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
 

+ 22
- 0
src/util/selfClosingTags.js 파일 보기

@@ -0,0 +1,22 @@
1
+module.exports = [
2
+  'area',
3
+  'base',
4
+  'br',
5
+  'col',
6
+  'command',
7
+  '!doctype',
8
+  '!DOCTYPE',
9
+  'embed',
10
+  'hr',
11
+  'img',
12
+  'input',
13
+  'keygen',
14
+  'link',
15
+  'menuitem',
16
+  'meta',
17
+  'param',
18
+  'source',
19
+  'track',
20
+  'wbr',
21
+]
22
+

Loading…
취소
저장