@@ -171,43 +171,52 @@ function compileTextNode (node, options) {
171
171
return null
172
172
}
173
173
var frag = document . createDocumentFragment ( )
174
- var dirs = options . directives
175
- var el , token , value
174
+ var el , token
176
175
for ( var i = 0 , l = tokens . length ; i < l ; i ++ ) {
177
176
token = tokens [ i ]
178
- value = token . value
179
- if ( token . tag ) {
180
- if ( token . oneTime ) {
181
- el = document . createTextNode ( value )
182
- } else {
183
- if ( token . html ) {
184
- el = document . createComment ( 'v-html' )
185
- token . type = 'html'
186
- token . def = dirs . html
187
- token . descriptor = dirParser . parse ( value ) [ 0 ]
188
- } else if ( token . partial ) {
189
- el = document . createComment ( 'v-partial' )
190
- token . type = 'partial'
191
- token . def = dirs . partial
192
- token . descriptor = dirParser . parse ( value ) [ 0 ]
193
- } else {
194
- // IE will clean up empty textNodes during
195
- // frag.cloneNode(true), so we have to give it
196
- // something here...
197
- el = document . createTextNode ( ' ' )
198
- token . type = 'text'
199
- token . def = dirs . text
200
- token . descriptor = dirParser . parse ( value ) [ 0 ]
201
- }
202
- }
203
- } else {
204
- el = document . createTextNode ( value )
205
- }
177
+ el = token . tag
178
+ ? processTextToken ( token , options )
179
+ : document . createTextNode ( token . value )
206
180
frag . appendChild ( el )
207
181
}
208
182
return makeTextNodeLinkFn ( tokens , frag , options )
209
183
}
210
184
185
+ /**
186
+ * Process a single text token.
187
+ *
188
+ * @param {Object } token
189
+ * @param {Object } options
190
+ * @return {Node }
191
+ */
192
+
193
+ function processTextToken ( token , options ) {
194
+ var el
195
+ if ( token . oneTime ) {
196
+ el = document . createTextNode ( token . value )
197
+ } else {
198
+ if ( token . html ) {
199
+ el = document . createComment ( 'v-html' )
200
+ setTokenType ( 'html' )
201
+ } else if ( token . partial ) {
202
+ el = document . createComment ( 'v-partial' )
203
+ setTokenType ( 'partial' )
204
+ } else {
205
+ // IE will clean up empty textNodes during
206
+ // frag.cloneNode(true), so we have to give it
207
+ // something here...
208
+ el = document . createTextNode ( ' ' )
209
+ setTokenType ( 'text' )
210
+ }
211
+ }
212
+ function setTokenType ( type ) {
213
+ token . type = type
214
+ token . def = options . directives [ type ]
215
+ token . descriptor = dirParser . parse ( token . value ) [ 0 ]
216
+ }
217
+ return el
218
+ }
219
+
211
220
/**
212
221
* Build a function that processes a textNode.
213
222
*
0 commit comments