11/*!
2- * Vue.js v2.0.0-alpha.2
2+ * Vue.js v2.0.0-alpha.3
33 * (c) 2014-2016 Evan You
44 * Released under the MIT License.
55 */
12791279 }
12801280
12811281 var VNode = function ( ) {
1282- function VNode ( tag , data , children , text , elm , ns , context , componentOptions ) {
1282+ function VNode ( tag , data , children , text , elm , ns , context , host , componentOptions ) {
12831283 this . tag = tag ;
12841284 this . data = data ;
12851285 this . children = children ;
12861286 this . text = text ;
12871287 this . elm = elm ;
12881288 this . ns = ns ;
12891289 this . context = context ;
1290+ this . host = host ;
12901291 this . key = data && data . key ;
12911292 this . componentOptions = componentOptions ;
12921293 this . child = undefined ;
12931294 this . parent = undefined ;
1295+ this . raw = false ;
12941296 // apply construct hook.
12951297 // this is applied during render, before patch happens.
12961298 // unlike other hooks, this is applied on both client and server.
15571559 var hooks = { init : init , prepatch : prepatch , insert : insert , destroy : destroy } ;
15581560 var hooksToMerge = Object . keys ( hooks ) ;
15591561
1560- function createComponent ( Ctor , data , parent , context , tag ) {
1562+ function createComponent ( Ctor , data , parent , context , host , tag ) {
15611563 if ( ! Ctor ) {
15621564 return ;
15631565 }
16071609
16081610 // return a placeholder vnode
16091611 var name = Ctor . options . name || tag ;
1610- var vnode = new VNode ( 'vue-component-' + Ctor . cid + ( name ? '-' + name : '' ) , data , undefined , undefined , undefined , undefined , context , { Ctor : Ctor , propsData : propsData , listeners : listeners , parent : parent , tag : tag , children : undefined }
1612+ var vnode = new VNode ( 'vue-component-' + Ctor . cid + ( name ? '-' + name : '' ) , data , undefined , undefined , undefined , undefined , context , host , { Ctor : Ctor , propsData : propsData , listeners : listeners , parent : parent , tag : tag , children : undefined }
16111613 // children to be set later by renderElementWithChildren,
16121614 // but before the init hook
16131615 ) ;
17891791 // make sure to expose real self instead of proxy
17901792 var context = this . _self ;
17911793 var parent = renderState . activeInstance ;
1794+ var host = context !== parent ? parent : undefined ;
17921795 if ( ! parent ) {
17931796 "development" !== 'production' && warn ( 'createElement cannot be called outside of component ' + 'render functions.' ) ;
17941797 return ;
18001803 if ( typeof tag === 'string' ) {
18011804 var Ctor = void 0 ;
18021805 if ( config . isReservedTag ( tag ) ) {
1803- return new VNode ( tag , data , undefined , undefined , undefined , namespace , context ) ;
1806+ return new VNode ( tag , data , undefined , undefined , undefined , namespace , context , host ) ;
18041807 } else if ( Ctor = resolveAsset ( context . $options , 'components' , tag ) ) {
1805- return createComponent ( Ctor , data , parent , context , tag ) ;
1808+ return createComponent ( Ctor , data , parent , context , host , tag ) ;
18061809 } else {
18071810 if ( "development" !== 'production' ) {
18081811 if ( ! namespace && config . isUnknownElement ( tag ) ) {
18091812 warn ( 'Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.' ) ;
18101813 }
18111814 }
1812- return new VNode ( tag , data , undefined , undefined , undefined , namespace , context ) ;
1815+ return new VNode ( tag , data , undefined , undefined , undefined , namespace , context , host ) ;
18131816 }
18141817 } else {
1815- return createComponent ( tag , data , parent , context ) ;
1818+ return createComponent ( tag , data , parent , context , host ) ;
18161819 }
18171820 }
18181821
18211824 }
18221825
18231826 function renderStatic ( index ) {
1824- return this . _staticTrees [ index ] ;
1827+ return this . _staticTrees [ index ] || ( this . _staticTrees [ index ] = this . $options . staticRenderFns [ index ] . call ( this . _renderProxy ) ) ;
18251828 }
18261829
18271830 var renderState = {
18611864 var _parentVnode = _vm$$options . _parentVnode ;
18621865
18631866
1864- if ( staticRenderFns && ! vm . _staticTrees ) {
1865- // render static sub-trees for once on initial render
1866- renderStaticTrees ( vm , staticRenderFns ) ;
1867+ if ( staticRenderFns && ! this . _staticTrees ) {
1868+ this . _staticTrees = [ ] ;
18671869 }
1870+
18681871 // resolve slots. becaues slots are rendered in parent scope,
18691872 // we set the activeInstance to parent.
18701873 if ( _renderChildren ) {
19501953 } ;
19511954 }
19521955
1953- function renderStaticTrees ( vm , fns ) {
1954- var trees = vm . _staticTrees = new Array ( fns . length ) ;
1955- for ( var i = 0 ; i < fns . length ; i ++ ) {
1956- trees [ i ] = fns [ i ] . call ( vm . _renderProxy ) ;
1957- }
1958- }
1959-
19601956 function resolveSlots ( vm , renderChildren ) {
19611957 if ( renderChildren ) {
19621958 var children = normalizeChildren ( renderChildren ) ;
27612757 }
27622758 } ) ;
27632759
2764- Vue . version = '2.0.0-alpha.2 ' ;
2760+ Vue . version = '2.0.0-alpha.3 ' ;
27652761
27662762 // attributes that should be using props for binding
27672763 var mustUseProp = makeMap ( 'value,selected,checked,muted' ) ;
27702766
27712767 var isBooleanAttr = makeMap ( 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' + 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + 'required,reversed,scoped,seamless,selected,sortable,translate,' + 'truespeed,typemustmatch,visible' ) ;
27722768
2769+ var isAttr = makeMap ( 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' + 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' + 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' + 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' + 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' + 'form,formaction,headers,<th>,height,hidden,high,href,hreflang,http-equiv,' + 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' + 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' + 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' + 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' + 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' + 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' + 'target,title,type,usemap,value,width,wrap' ) ;
2770+
27732771 var xlinkNS = 'http://www.w3.org/1999/xlink' ;
27742772
27752773 var isXlink = function isXlink ( name ) {
@@ -3096,6 +3094,9 @@ var nodeOps = Object.freeze({
30963094 // of going through the normal attribute patching process.
30973095 function setScope ( vnode ) {
30983096 var i = void 0 ;
3097+ if ( isDef ( i = vnode . host ) && isDef ( i = i . $options . _scopeId ) ) {
3098+ nodeOps . setAttribute ( vnode . elm , i , '' ) ;
3099+ }
30993100 if ( isDef ( i = vnode . context ) && isDef ( i = i . $options . _scopeId ) ) {
31003101 nodeOps . setAttribute ( vnode . elm , i , '' ) ;
31013102 }
@@ -4751,12 +4752,12 @@ var nodeOps = Object.freeze({
47514752 }
47524753
47534754 var dirRE = / ^ v - | ^ @ | ^ : / ;
4755+ var forAliasRE = / ( .* ) \s + (?: i n | o f ) \s + ( .* ) / ;
4756+ var forIteratorRE = / \( ( [ ^ , ] * ) , ( [ ^ , ] * ) (?: , ( [ ^ , ] * ) ) ? \) / ;
47544757 var bindRE = / ^ : | ^ v - b i n d : / ;
47554758 var onRE = / ^ @ | ^ v - o n : / ;
47564759 var argRE = / : ( .* ) $ / ;
47574760 var modifierRE = / \. [ ^ \. ] + / g;
4758- var forAliasRE = / ( .* ) \s + (?: i n | o f ) \s + ( .* ) / ;
4759- var forIteratorRE = / \( ( [ ^ , ] * ) , ( [ ^ , ] * ) (?: , ( [ ^ , ] * ) ) ? \) / ;
47604761 var camelRE = / [ a - z \d ] [ A - Z ] / ;
47614762
47624763 var decodeHTMLCached = cached ( decodeHTML ) ;
@@ -4782,6 +4783,7 @@ var nodeOps = Object.freeze({
47824783 postTransforms = pluckModuleFunction ( options . modules , 'postTransformNode' ) ;
47834784 delimiters = options . delimiters ;
47844785 var stack = [ ] ;
4786+ var preserveWhitespace = options . preserveWhitespace !== false ;
47854787 var root = void 0 ;
47864788 var currentParent = void 0 ;
47874789 var inPre = false ;
@@ -4913,7 +4915,7 @@ var nodeOps = Object.freeze({
49134915 }
49144916 text = currentParent . tag === 'pre' || text . trim ( ) ? decodeHTMLCached ( text )
49154917 // only preserve whitespace if its not right after a starting tag
4916- : currentParent . children . length ? ' ' : '' ;
4918+ : preserveWhitespace && currentParent . children . length ? ' ' : '' ;
49174919 if ( text ) {
49184920 var expression = void 0 ;
49194921 if ( ! inPre && text !== ' ' && ( expression = parseText ( text , delimiters ) ) ) {
@@ -5344,9 +5346,9 @@ var nodeOps = Object.freeze({
53445346 }
53455347
53465348 function genElement ( el ) {
5347- if ( el . for ) {
5349+ if ( el . for && ! el . forProcessed ) {
53485350 return genFor ( el ) ;
5349- } else if ( el . if ) {
5351+ } else if ( el . if && ! el . ifProcessed ) {
53505352 return genIf ( el ) ;
53515353 } else if ( el . tag === 'template' && ! el . slotTarget ) {
53525354 return genChildren ( el ) || 'void 0' ;
@@ -5388,7 +5390,7 @@ var nodeOps = Object.freeze({
53885390
53895391 function genIf ( el ) {
53905392 var exp = el . if ;
5391- el . if = null ; // avoid recursion
5393+ el . ifProcessed = true ; // avoid recursion
53925394 return '(' + exp + ')?' + genElement ( el ) + ':' + genElse ( el ) ;
53935395 }
53945396
@@ -5401,7 +5403,7 @@ var nodeOps = Object.freeze({
54015403 var alias = el . alias ;
54025404 var iterator1 = el . iterator1 ? ',' + el . iterator1 : '' ;
54035405 var iterator2 = el . iterator2 ? ',' + el . iterator2 : '' ;
5404- el . for = null ; // avoid recursion
5406+ el . forProcessed = true ; // avoid recursion
54055407 return '(' + exp + ')&&_l((' + exp + '),' + ( 'function(' + alias + iterator1 + iterator2 + '){' ) + ( 'return ' + genElement ( el ) ) + '})' ;
54065408 }
54075409
@@ -5579,7 +5581,10 @@ var nodeOps = Object.freeze({
55795581 } ;
55805582 }
55815583
5582- var keywordRE = new RegExp ( '\\b' + ( 'do,if,in,for,let,new,try,var,case,else,with,await,break,catch,class,const,' + 'super,throw,while,yield,delete,export,import,return,switch,typeof,default,' + 'extends,finally,continue,debugger,function,arguments,instanceof' ) . split ( ',' ) . join ( '\\b|\\b' ) + '\\b' ) ;
5584+ // operators like typeof, instanceof and in are allowed
5585+ var prohibitedKeywordRE = new RegExp ( '\\b' + ( 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' + 'super,throw,while,yield,delete,export,import,return,switch,default,' + 'extends,finally,continue,debugger,function,arguments' ) . split ( ',' ) . join ( '\\b|\\b' ) + '\\b' ) ;
5586+ // check valid identifier for v-for
5587+ var identRE = / [ ^ \w $ \. ] (?: [ A - Z a - z _ $ ] [ \w $ ] * ) / ;
55835588
55845589 // detect problematic expressions in a template
55855590 function detectErrors ( ast ) {
@@ -5596,7 +5601,11 @@ var nodeOps = Object.freeze({
55965601 if ( dirRE . test ( name ) ) {
55975602 var value = node . attrsMap [ name ] ;
55985603 if ( value ) {
5599- checkExpression ( value , name + '="' + value + '"' , errors ) ;
5604+ if ( name === 'v-for' ) {
5605+ checkFor ( node , 'v-for="' + value + '"' , errors ) ;
5606+ } else {
5607+ checkExpression ( value , name + '="' + value + '"' , errors ) ;
5608+ }
56005609 }
56015610 }
56025611 }
@@ -5610,14 +5619,27 @@ var nodeOps = Object.freeze({
56105619 }
56115620 }
56125621
5622+ function checkFor ( node , text , errors ) {
5623+ checkExpression ( node . for || '' , text , errors ) ;
5624+ checkIdentifier ( node . alias , 'v-for alias' , text , errors ) ;
5625+ checkIdentifier ( node . iterator1 , 'v-for iterator' , text , errors ) ;
5626+ checkIdentifier ( node . iterator2 , 'v-for iterator' , text , errors ) ;
5627+ }
5628+
5629+ function checkIdentifier ( ident , type , text , errors ) {
5630+ if ( typeof ident === 'string' && ! identRE . test ( ident ) ) {
5631+ errors . push ( '- invalid ' + type + ' "' + ident + '" in expression: ' + text ) ;
5632+ }
5633+ }
5634+
56135635 function checkExpression ( exp , text , errors ) {
56145636 exp = stripToString ( exp ) ;
5615- var keywordMatch = exp . match ( keywordRE ) ;
5637+ var keywordMatch = exp . match ( prohibitedKeywordRE ) ;
56165638 if ( keywordMatch ) {
56175639 errors . push ( '- avoid using JavaScript keyword as property name: ' + ( '"' + keywordMatch [ 0 ] + '" in expression ' + text ) ) ;
56185640 } else {
56195641 try {
5620- new Function ( exp ) ;
5642+ new Function ( 'return ' + exp ) ;
56215643 } catch ( e ) {
56225644 errors . push ( '- invalid expression: ' + text ) ;
56235645 }
0 commit comments