@@ -523,10 +523,24 @@ CompilerProto.compileElement = function (node, root) {
523
523
node . vue_effect = this . eval ( utils . attr ( node , 'effect' ) )
524
524
525
525
var prefix = config . prefix + '-' ,
526
- attrs = slice . call ( node . attributes ) ,
527
526
params = this . options . paramAttributes ,
528
527
attr , attrname , isDirective , exp , directives , directive , dirname
529
528
529
+ // v-with has special priority among the rest
530
+ // it needs to pull in the value from the parent before
531
+ // computed properties are evaluated, because at this stage
532
+ // the computed properties have not set up their dependencies yet.
533
+ if ( root ) {
534
+ var withExp = utils . attr ( node , 'with' )
535
+ if ( withExp ) {
536
+ directives = this . parseDirective ( 'with' , withExp , node , true )
537
+ for ( j = 0 , k = directives . length ; j < k ; j ++ ) {
538
+ this . bindDirective ( directives [ j ] , this . parent )
539
+ }
540
+ }
541
+ }
542
+
543
+ var attrs = slice . call ( node . attributes )
530
544
for ( i = 0 , l = attrs . length ; i < l ; i ++ ) {
531
545
532
546
attr = attrs [ i ]
@@ -542,12 +556,7 @@ CompilerProto.compileElement = function (node, root) {
542
556
// loop through clauses (separated by ",")
543
557
// inside each attribute
544
558
for ( j = 0 , k = directives . length ; j < k ; j ++ ) {
545
- directive = directives [ j ]
546
- if ( dirname === 'with' ) {
547
- this . bindDirective ( directive , this . parent )
548
- } else {
549
- this . bindDirective ( directive )
550
- }
559
+ this . bindDirective ( directives [ j ] )
551
560
}
552
561
} else if ( config . interpolate ) {
553
562
// non directive attribute, check interpolation tags
0 commit comments