@@ -126,9 +126,7 @@ function Compiler (vm, options) {
126126 compiler . compile ( el , true )
127127
128128 // bind deferred directives (child components)
129- for ( var i = 0 , l = compiler . deferred . length ; i < l ; i ++ ) {
130- compiler . bindDirective ( compiler . deferred [ i ] )
131- }
129+ compiler . deferred . forEach ( compiler . bindDirective , compiler )
132130
133131 // extract dependencies for computed properties
134132 compiler . parseDeps ( )
@@ -288,7 +286,7 @@ CompilerProto.compile = function (node, root) {
288286 }
289287
290288 // v-with has 2nd highest priority
291- } else if ( ! root && ( ( withKey = utils . attr ( node , 'with' ) ) || componentCtor ) ) {
289+ } else if ( root !== true && ( ( withKey = utils . attr ( node , 'with' ) ) || componentCtor ) ) {
292290
293291 directive = Directive . parse ( 'with' , withKey || '' , compiler , node )
294292 if ( directive ) {
@@ -369,10 +367,7 @@ CompilerProto.compileNode = function (node) {
369367 }
370368 // recursively compile childNodes
371369 if ( node . childNodes . length ) {
372- var nodes = slice . call ( node . childNodes )
373- for ( i = 0 , j = nodes . length ; i < j ; i ++ ) {
374- this . compile ( nodes [ i ] )
375- }
370+ slice . call ( node . childNodes ) . forEach ( this . compile , this )
376371 }
377372}
378373
@@ -387,7 +382,7 @@ CompilerProto.compileTextNode = function (node) {
387382
388383 for ( var i = 0 , l = tokens . length ; i < l ; i ++ ) {
389384 token = tokens [ i ]
390- directive = null
385+ directive = partialNodes = null
391386 if ( token . key ) { // a binding
392387 if ( token . key . charAt ( 0 ) === '>' ) { // a partial
393388 partialId = token . key . slice ( 1 ) . trim ( )
@@ -413,6 +408,8 @@ CompilerProto.compileTextNode = function (node) {
413408
414409 // insert node
415410 node . parentNode . insertBefore ( el , node )
411+
412+ // bind directive
416413 if ( directive ) {
417414 this . bindDirective ( directive )
418415 }
@@ -421,10 +418,7 @@ CompilerProto.compileTextNode = function (node) {
421418 // will change from the fragment to the correct parentNode.
422419 // This could affect directives that need access to its element's parentNode.
423420 if ( partialNodes ) {
424- for ( var j = 0 , k = partialNodes . length ; j < k ; j ++ ) {
425- this . compile ( partialNodes [ j ] )
426- }
427- partialNodes = null
421+ partialNodes . forEach ( this . compile , this )
428422 }
429423
430424 }
0 commit comments