11/*
2- VueJS v0.7.4
2+ VueJS v0.7.5
33 (c) 2014 Evan You
44 License: MIT
55*/
@@ -563,6 +563,7 @@ var prefix = 'v',
563563 'text' ,
564564 'repeat' ,
565565 'partial' ,
566+ 'with' ,
566567 'component' ,
567568 'component-id' ,
568569 'transition'
@@ -1027,9 +1028,11 @@ CompilerProto.compile = function (node, root) {
10271028
10281029 // special attributes to check
10291030 var repeatExp ,
1030- componentExp ,
1031+ withKey ,
10311032 partialId ,
1032- directive
1033+ directive ,
1034+ componentId = utils . attr ( node , 'component' ) || tagName . toLowerCase ( ) ,
1035+ componentCtor = compiler . getOption ( 'components' , componentId )
10331036
10341037 // It is important that we access these attributes
10351038 // procedurally because the order matters.
@@ -1045,21 +1048,16 @@ CompilerProto.compile = function (node, root) {
10451048 // repeat block cannot have v-id at the same time.
10461049 directive = Directive . parse ( 'repeat' , repeatExp , compiler , node )
10471050 if ( directive ) {
1051+ directive . Ctor = componentCtor
10481052 compiler . bindDirective ( directive )
10491053 }
10501054
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 ) ) {
10531057
1054- directive = Directive . parse ( 'component ' , componentExp , compiler , node )
1058+ directive = Directive . parse ( 'with ' , withKey || '' , compiler , node )
10551059 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
10631061 compiler . bindDirective ( directive )
10641062 }
10651063
@@ -2817,7 +2815,7 @@ module.exports = {
28172815 repeat : require ( './repeat' ) ,
28182816 model : require ( './model' ) ,
28192817 'if' : require ( './if' ) ,
2820- component : require ( './component ' ) ,
2818+ 'with' : require ( './with ' ) ,
28212819
28222820 attr : function ( value ) {
28232821 this . el . setAttribute ( this . arg , value )
@@ -3008,9 +3006,8 @@ module.exports = {
30083006 ctn = self . container = el . parentNode
30093007
30103008 // 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
30143011
30153012 // extract transition information
30163013 self . hasTrans = el . hasAttribute ( config . attrs . transition )
@@ -3087,7 +3084,7 @@ module.exports = {
30873084 } , this . compiler )
30883085 }
30893086
3090- item = new this . ChildVM ( {
3087+ item = new this . Ctor ( {
30913088 el : node ,
30923089 data : data ,
30933090 compilerOptions : {
@@ -3350,8 +3347,8 @@ module.exports = {
33503347 }
33513348}
33523349} ) ;
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
33553352
33563353module . exports = {
33573354
@@ -3370,16 +3367,15 @@ module.exports = {
33703367 } ,
33713368
33723369 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 ( {
33763373 el : this . el ,
33773374 data : value ,
33783375 compilerOptions : {
33793376 parentCompiler : this . compiler
33803377 }
3381- }
3382- this . component = new Ctor ( options )
3378+ } )
33833379 } ,
33843380
33853381 unbind : function ( ) {
0 commit comments