@@ -11,13 +11,13 @@ var xtend = require('xtend')
1111
1212module . exports = wrap
1313
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'
2121
2222var parseOptions = {
2323 sourceCodeLocationInfo : true ,
@@ -43,7 +43,7 @@ function wrap(tree, file) {
4343
4444 result = fromParse5 ( documentMode ( tree ) ? document ( ) : fragment ( ) , file )
4545
46- /* Unpack if possible and when not given a `root`. */
46+ // Unpack if possible and when not given a `root`.
4747 if ( tree . type !== 'root' && result . children . length === 1 ) {
4848 return result . children [ 0 ]
4949 }
@@ -77,7 +77,7 @@ function wrap(tree, file) {
7777 }
7878
7979 parser . _bootstrap ( mock , context )
80- parser . _pushTmplInsertionMode ( IN_TEMPLATE_MODE )
80+ parser . _pushTmplInsertionMode ( inTemplateMode )
8181 parser . _initTokenizerForFragmentParsing ( )
8282 parser . _insertFakeRootElement ( )
8383 parser . _resetInsertionMode ( )
@@ -137,17 +137,17 @@ function wrap(tree, file) {
137137 if ( ! empty ) {
138138 parser . _processToken ( endTag ( node ) )
139139
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
145145 }
146146 }
147147
148148 function text ( node ) {
149149 parser . _processToken ( {
150- type : CHARACTER_TOKEN ,
150+ type : characterToken ,
151151 chars : node . value ,
152152 location : createParse5Location ( node )
153153 } )
@@ -157,7 +157,7 @@ function wrap(tree, file) {
157157 var p5 = toParse5 ( node )
158158
159159 parser . _processToken ( {
160- type : DOCTYPE_TOKEN ,
160+ type : doctypeToken ,
161161 name : p5 . name ,
162162 forceQuirks : false ,
163163 publicId : p5 . publicId ,
@@ -168,7 +168,7 @@ function wrap(tree, file) {
168168
169169 function comment ( node ) {
170170 parser . _processToken ( {
171- type : COMMENT_TOKEN ,
171+ type : commentToken ,
172172 data : node . value ,
173173 location : createParse5Location ( node )
174174 } )
@@ -179,15 +179,15 @@ function wrap(tree, file) {
179179 var token
180180
181181 // 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>.
183183 preprocessor . html = null
184184 preprocessor . endOfChunkHit = false
185185 preprocessor . lastChunkWritten = false
186186 preprocessor . lastCharPos = - 1
187187 preprocessor . pos = - 1
188188
189189 // 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>.
191191 posTracker . droppedBufferSize = 0
192192 posTracker . line = start . line
193193 posTracker . col = 1
@@ -196,18 +196,18 @@ function wrap(tree, file) {
196196 posTracker . droppedBufferSize = start . offset
197197
198198 // 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>.
200200 locationTracker . currentAttrLocation = null
201201 locationTracker . ctLoc = createParse5Location ( node )
202202
203203 // 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>.
205205 tokenizer . write ( node . value )
206206 parser . _runParsingLoop ( null )
207207
208208 // Process final characters if they’re still there after hibernating.
209209 // 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>.
211211 token = tokenizer . currentCharacterToken
212212
213213 if ( token ) {
@@ -218,7 +218,7 @@ function wrap(tree, file) {
218218 }
219219
220220 // 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>.
222222 tokenizer . currentToken = null
223223 tokenizer . currentCharacterToken = null
224224 tokenizer . currentAttr = null
@@ -231,7 +231,7 @@ function startTag(node) {
231231 location . startTag = xtend ( location )
232232
233233 return {
234- type : START_TAG_TOKEN ,
234+ type : startTagToken ,
235235 tagName : node . tagName ,
236236 selfClosing : false ,
237237 attrs : attributes ( node ) ,
@@ -253,7 +253,7 @@ function endTag(node) {
253253 location . endTag = xtend ( location )
254254
255255 return {
256- type : END_TAG_TOKEN ,
256+ type : endTagToken ,
257257 tagName : node . tagName ,
258258 attrs : [ ] ,
259259 location : location
0 commit comments