@@ -11,13 +11,13 @@ var xtend = require('xtend')
11
11
12
12
module . exports = wrap
13
13
14
- var IN_TEMPLATE_MODE = 'IN_TEMPLATE_MODE'
15
- var DATA_MODE = 'DATA_STATE'
16
- var CHARACTER_TOKEN = 'CHARACTER_TOKEN'
17
- var START_TAG_TOKEN = 'START_TAG_TOKEN'
18
- var END_TAG_TOKEN = 'END_TAG_TOKEN'
19
- var COMMENT_TOKEN = 'COMMENT_TOKEN'
20
- var DOCTYPE_TOKEN = 'DOCTYPE_TOKEN'
14
+ var inTemplateMode = 'IN_TEMPLATE_MODE'
15
+ var dataState = 'DATA_STATE'
16
+ var characterToken = 'CHARACTER_TOKEN'
17
+ var startTagToken = 'START_TAG_TOKEN'
18
+ var endTagToken = 'END_TAG_TOKEN'
19
+ var commentToken = 'COMMENT_TOKEN'
20
+ var doctypeToken = 'DOCTYPE_TOKEN'
21
21
22
22
var parseOptions = {
23
23
sourceCodeLocationInfo : true ,
@@ -43,7 +43,7 @@ function wrap(tree, file) {
43
43
44
44
result = fromParse5 ( documentMode ( tree ) ? document ( ) : fragment ( ) , file )
45
45
46
- /* Unpack if possible and when not given a `root`. */
46
+ // Unpack if possible and when not given a `root`.
47
47
if ( tree . type !== 'root' && result . children . length === 1 ) {
48
48
return result . children [ 0 ]
49
49
}
@@ -77,7 +77,7 @@ function wrap(tree, file) {
77
77
}
78
78
79
79
parser . _bootstrap ( mock , context )
80
- parser . _pushTmplInsertionMode ( IN_TEMPLATE_MODE )
80
+ parser . _pushTmplInsertionMode ( inTemplateMode )
81
81
parser . _initTokenizerForFragmentParsing ( )
82
82
parser . _insertFakeRootElement ( )
83
83
parser . _resetInsertionMode ( )
@@ -137,17 +137,17 @@ function wrap(tree, file) {
137
137
if ( ! empty ) {
138
138
parser . _processToken ( endTag ( node ) )
139
139
140
- // Put the parser back in data mode : some elements, like
141
- // textareas and iframes, change the state.
142
- // See syntax-tree/hast-util-raw/issues/7 .
143
- // See https://github.com/inikulin/parse5/blob/2528196/packages/parse5/lib/tokenizer/index.js#L222
144
- tokenizer . state = DATA_MODE
140
+ // Put the parser back in the data state : some elements, like textareas
141
+ // and iframes, change the state.
142
+ // See < syntax-tree/hast-util-raw#7> .
143
+ // See < https://github.com/inikulin/parse5/blob/2528196/packages/parse5/lib/tokenizer/index.js#L222>.
144
+ tokenizer . state = dataState
145
145
}
146
146
}
147
147
148
148
function text ( node ) {
149
149
parser . _processToken ( {
150
- type : CHARACTER_TOKEN ,
150
+ type : characterToken ,
151
151
chars : node . value ,
152
152
location : createParse5Location ( node )
153
153
} )
@@ -157,7 +157,7 @@ function wrap(tree, file) {
157
157
var p5 = toParse5 ( node )
158
158
159
159
parser . _processToken ( {
160
- type : DOCTYPE_TOKEN ,
160
+ type : doctypeToken ,
161
161
name : p5 . name ,
162
162
forceQuirks : false ,
163
163
publicId : p5 . publicId ,
@@ -168,7 +168,7 @@ function wrap(tree, file) {
168
168
169
169
function comment ( node ) {
170
170
parser . _processToken ( {
171
- type : COMMENT_TOKEN ,
171
+ type : commentToken ,
172
172
data : node . value ,
173
173
location : createParse5Location ( node )
174
174
} )
@@ -179,15 +179,15 @@ function wrap(tree, file) {
179
179
var token
180
180
181
181
// Reset preprocessor:
182
- // https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/tokenizer/preprocessor.js
182
+ // See: < https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/tokenizer/preprocessor.js>.
183
183
preprocessor . html = null
184
184
preprocessor . endOfChunkHit = false
185
185
preprocessor . lastChunkWritten = false
186
186
preprocessor . lastCharPos = - 1
187
187
preprocessor . pos = - 1
188
188
189
189
// Reset preprocessor mixin:
190
- // https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/extensions/position-tracking/preprocessor-mixin.js
190
+ // See: < https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/extensions/position-tracking/preprocessor-mixin.js>.
191
191
posTracker . droppedBufferSize = 0
192
192
posTracker . line = start . line
193
193
posTracker . col = 1
@@ -196,18 +196,18 @@ function wrap(tree, file) {
196
196
posTracker . droppedBufferSize = start . offset
197
197
198
198
// Reset location tracker:
199
- // https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js
199
+ // See: < https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js>.
200
200
locationTracker . currentAttrLocation = null
201
201
locationTracker . ctLoc = createParse5Location ( node )
202
202
203
203
// See the code for `parse` and `parseFragment`:
204
- // https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/parser/index.js#L371
204
+ // See: < https://github.com/inikulin/parse5/blob/0491902/packages/parse5/lib/parser/index.js#L371>.
205
205
tokenizer . write ( node . value )
206
206
parser . _runParsingLoop ( null )
207
207
208
208
// Process final characters if they’re still there after hibernating.
209
209
// Similar to:
210
- // https://github.com/inikulin/parse5/blob/3bfa7d9/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js#L95
210
+ // See: < https://github.com/inikulin/parse5/blob/3bfa7d9/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js#L95>.
211
211
token = tokenizer . currentCharacterToken
212
212
213
213
if ( token ) {
@@ -218,7 +218,7 @@ function wrap(tree, file) {
218
218
}
219
219
220
220
// Reset tokenizer:
221
- // https://github.com/inikulin/parse5/blob/8b0048e/packages/parse5/lib/tokenizer/index.js#L215
221
+ // See: < https://github.com/inikulin/parse5/blob/8b0048e/packages/parse5/lib/tokenizer/index.js#L215>.
222
222
tokenizer . currentToken = null
223
223
tokenizer . currentCharacterToken = null
224
224
tokenizer . currentAttr = null
@@ -231,7 +231,7 @@ function startTag(node) {
231
231
location . startTag = xtend ( location )
232
232
233
233
return {
234
- type : START_TAG_TOKEN ,
234
+ type : startTagToken ,
235
235
tagName : node . tagName ,
236
236
selfClosing : false ,
237
237
attrs : attributes ( node ) ,
@@ -253,7 +253,7 @@ function endTag(node) {
253
253
location . endTag = xtend ( location )
254
254
255
255
return {
256
- type : END_TAG_TOKEN ,
256
+ type : endTagToken ,
257
257
tagName : node . tagName ,
258
258
attrs : [ ] ,
259
259
location : location
0 commit comments