1
1
/*
2
- VueJS v0.7.4
2
+ VueJS v0.7.5
3
3
(c) 2014 Evan You
4
4
License: MIT
5
5
*/
@@ -563,6 +563,7 @@ var prefix = 'v',
563
563
'text' ,
564
564
'repeat' ,
565
565
'partial' ,
566
+ 'with' ,
566
567
'component' ,
567
568
'component-id' ,
568
569
'transition'
@@ -1027,9 +1028,11 @@ CompilerProto.compile = function (node, root) {
1027
1028
1028
1029
// special attributes to check
1029
1030
var repeatExp ,
1030
- componentExp ,
1031
+ withKey ,
1031
1032
partialId ,
1032
- directive
1033
+ directive ,
1034
+ componentId = utils . attr ( node , 'component' ) || tagName . toLowerCase ( ) ,
1035
+ componentCtor = compiler . getOption ( 'components' , componentId )
1033
1036
1034
1037
// It is important that we access these attributes
1035
1038
// procedurally because the order matters.
@@ -1045,21 +1048,16 @@ CompilerProto.compile = function (node, root) {
1045
1048
// repeat block cannot have v-id at the same time.
1046
1049
directive = Directive . parse ( 'repeat' , repeatExp , compiler , node )
1047
1050
if ( directive ) {
1051
+ directive . Ctor = componentCtor
1048
1052
compiler . bindDirective ( directive )
1049
1053
}
1050
1054
1051
- // v-component has 2nd highest priority
1052
- } else if ( ! root && ( componentExp = utils . attr ( node , 'component' ) ) ) {
1055
+ // v-with has 2nd highest priority
1056
+ } else if ( ! root && ( ( withKey = utils . attr ( node , 'with' ) ) || componentCtor ) ) {
1053
1057
1054
- directive = Directive . parse ( 'component ' , componentExp , compiler , node )
1058
+ directive = Directive . parse ( 'with ' , withKey || '' , compiler , node )
1055
1059
if ( directive ) {
1056
- // component directive is a bit different from the others.
1057
- // when it has no argument, it should be treated as a
1058
- // simple directive with its key as the argument.
1059
- if ( componentExp . indexOf ( ':' ) === - 1 ) {
1060
- directive . isSimple = true
1061
- directive . arg = directive . key
1062
- }
1060
+ directive . Ctor = componentCtor
1063
1061
compiler . bindDirective ( directive )
1064
1062
}
1065
1063
@@ -2817,7 +2815,7 @@ module.exports = {
2817
2815
repeat : require ( './repeat' ) ,
2818
2816
model : require ( './model' ) ,
2819
2817
'if' : require ( './if' ) ,
2820
- component : require ( './component ' ) ,
2818
+ 'with' : require ( './with ' ) ,
2821
2819
2822
2820
attr : function ( value ) {
2823
2821
this . el . setAttribute ( this . arg , value )
@@ -3008,9 +3006,8 @@ module.exports = {
3008
3006
ctn = self . container = el . parentNode
3009
3007
3010
3008
// extract child VM information, if any
3011
- ViewModel = ViewModel || require ( '../viewmodel' )
3012
- var componentId = utils . attr ( el , 'component' )
3013
- self . ChildVM = self . compiler . getOption ( 'components' , componentId ) || ViewModel
3009
+ ViewModel = ViewModel || require ( '../viewmodel' )
3010
+ self . Ctor = self . Ctor || ViewModel
3014
3011
3015
3012
// extract transition information
3016
3013
self . hasTrans = el . hasAttribute ( config . attrs . transition )
@@ -3087,7 +3084,7 @@ module.exports = {
3087
3084
} , this . compiler )
3088
3085
}
3089
3086
3090
- item = new this . ChildVM ( {
3087
+ item = new this . Ctor ( {
3091
3088
el : node ,
3092
3089
data : data ,
3093
3090
compilerOptions : {
@@ -3350,8 +3347,8 @@ module.exports = {
3350
3347
}
3351
3348
}
3352
3349
} ) ;
3353
- require . register ( "vue/src/directives/component .js" , function ( exports , require , module ) {
3354
- var utils = require ( '../utils' )
3350
+ require . register ( "vue/src/directives/with .js" , function ( exports , require , module ) {
3351
+ var ViewModel
3355
3352
3356
3353
module . exports = {
3357
3354
@@ -3370,16 +3367,15 @@ module.exports = {
3370
3367
} ,
3371
3368
3372
3369
build : function ( value ) {
3373
- var Ctor = this . compiler . getOption ( 'components' , this . arg )
3374
- if ( ! Ctor ) utils . warn ( 'unknown component: ' + this . arg )
3375
- var options = {
3370
+ ViewModel = ViewModel || require ( '../viewmodel' )
3371
+ var Ctor = this . Ctor || ViewModel
3372
+ this . component = new Ctor ( {
3376
3373
el : this . el ,
3377
3374
data : value ,
3378
3375
compilerOptions : {
3379
3376
parentCompiler : this . compiler
3380
3377
}
3381
- }
3382
- this . component = new Ctor ( options )
3378
+ } )
3383
3379
} ,
3384
3380
3385
3381
unbind : function ( ) {
0 commit comments