Skip to content

Commit c422de1

Browse files
committed
[build] 2.0.0-alpha.3
1 parent 9e14146 commit c422de1

File tree

8 files changed

+211
-123
lines changed

8 files changed

+211
-123
lines changed

dist/vue.common.js

+20-19
Original file line numberDiff line numberDiff line change
@@ -1272,18 +1272,20 @@ function setData(vm, newData) {
12721272
}
12731273

12741274
var VNode = function () {
1275-
function VNode(tag, data, children, text, elm, ns, context, componentOptions) {
1275+
function VNode(tag, data, children, text, elm, ns, context, host, componentOptions) {
12761276
this.tag = tag;
12771277
this.data = data;
12781278
this.children = children;
12791279
this.text = text;
12801280
this.elm = elm;
12811281
this.ns = ns;
12821282
this.context = context;
1283+
this.host = host;
12831284
this.key = data && data.key;
12841285
this.componentOptions = componentOptions;
12851286
this.child = undefined;
12861287
this.parent = undefined;
1288+
this.raw = false;
12871289
// apply construct hook.
12881290
// this is applied during render, before patch happens.
12891291
// unlike other hooks, this is applied on both client and server.
@@ -1550,7 +1552,7 @@ function callHook(vm, hook) {
15501552
var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy };
15511553
var hooksToMerge = Object.keys(hooks);
15521554

1553-
function createComponent(Ctor, data, parent, context, tag) {
1555+
function createComponent(Ctor, data, parent, context, host, tag) {
15541556
if (!Ctor) {
15551557
return;
15561558
}
@@ -1600,7 +1602,7 @@ function createComponent(Ctor, data, parent, context, tag) {
16001602

16011603
// return a placeholder vnode
16021604
var name = Ctor.options.name || tag;
1603-
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 }
1605+
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 }
16041606
// children to be set later by renderElementWithChildren,
16051607
// but before the init hook
16061608
);
@@ -1782,6 +1784,7 @@ function renderElement(tag, data, namespace) {
17821784
// make sure to expose real self instead of proxy
17831785
var context = this._self;
17841786
var parent = renderState.activeInstance;
1787+
var host = context !== parent ? parent : undefined;
17851788
if (!parent) {
17861789
process.env.NODE_ENV !== 'production' && warn('createElement cannot be called outside of component ' + 'render functions.');
17871790
return;
@@ -1793,19 +1796,19 @@ function renderElement(tag, data, namespace) {
17931796
if (typeof tag === 'string') {
17941797
var Ctor = void 0;
17951798
if (config.isReservedTag(tag)) {
1796-
return new VNode(tag, data, undefined, undefined, undefined, namespace, context);
1799+
return new VNode(tag, data, undefined, undefined, undefined, namespace, context, host);
17971800
} else if (Ctor = resolveAsset(context.$options, 'components', tag)) {
1798-
return createComponent(Ctor, data, parent, context, tag);
1801+
return createComponent(Ctor, data, parent, context, host, tag);
17991802
} else {
18001803
if (process.env.NODE_ENV !== 'production') {
18011804
if (!namespace && config.isUnknownElement(tag)) {
18021805
warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.');
18031806
}
18041807
}
1805-
return new VNode(tag, data, undefined, undefined, undefined, namespace, context);
1808+
return new VNode(tag, data, undefined, undefined, undefined, namespace, context, host);
18061809
}
18071810
} else {
1808-
return createComponent(tag, data, parent, context);
1811+
return createComponent(tag, data, parent, context, host);
18091812
}
18101813
}
18111814

@@ -1814,7 +1817,7 @@ function renderText(str) {
18141817
}
18151818

18161819
function renderStatic(index) {
1817-
return this._staticTrees[index];
1820+
return this._staticTrees[index] || (this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy));
18181821
}
18191822

18201823
var renderState = {
@@ -1854,10 +1857,10 @@ function renderMixin(Vue) {
18541857
var _parentVnode = _vm$$options._parentVnode;
18551858

18561859

1857-
if (staticRenderFns && !vm._staticTrees) {
1858-
// render static sub-trees for once on initial render
1859-
renderStaticTrees(vm, staticRenderFns);
1860+
if (staticRenderFns && !this._staticTrees) {
1861+
this._staticTrees = [];
18601862
}
1863+
18611864
// resolve slots. becaues slots are rendered in parent scope,
18621865
// we set the activeInstance to parent.
18631866
if (_renderChildren) {
@@ -1943,13 +1946,6 @@ function renderMixin(Vue) {
19431946
};
19441947
}
19451948

1946-
function renderStaticTrees(vm, fns) {
1947-
var trees = vm._staticTrees = new Array(fns.length);
1948-
for (var i = 0; i < fns.length; i++) {
1949-
trees[i] = fns[i].call(vm._renderProxy);
1950-
}
1951-
}
1952-
19531949
function resolveSlots(vm, renderChildren) {
19541950
if (renderChildren) {
19551951
var children = normalizeChildren(renderChildren);
@@ -2756,7 +2752,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
27562752
}
27572753
});
27582754

2759-
Vue.version = '2.0.0-alpha.2';
2755+
Vue.version = '2.0.0-alpha.3';
27602756

27612757
// attributes that should be using props for binding
27622758
var mustUseProp = makeMap('value,selected,checked,muted');
@@ -2765,6 +2761,8 @@ var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
27652761

27662762
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');
27672763

2764+
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');
2765+
27682766
var xlinkNS = 'http://www.w3.org/1999/xlink';
27692767

27702768
var isXlink = function isXlink(name) {
@@ -3080,6 +3078,9 @@ function createPatchFunction(backend) {
30803078
// of going through the normal attribute patching process.
30813079
function setScope(vnode) {
30823080
var i = void 0;
3081+
if (isDef(i = vnode.host) && isDef(i = i.$options._scopeId)) {
3082+
nodeOps.setAttribute(vnode.elm, i, '');
3083+
}
30833084
if (isDef(i = vnode.context) && isDef(i = i.$options._scopeId)) {
30843085
nodeOps.setAttribute(vnode.elm, i, '');
30853086
}

dist/vue.js

+53-31
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
*/
@@ -1279,18 +1279,20 @@
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.
@@ -1557,7 +1559,7 @@
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
}
@@ -1607,7 +1609,7 @@
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
);
@@ -1789,6 +1791,7 @@
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;
@@ -1800,19 +1803,19 @@
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

@@ -1821,7 +1824,7 @@
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 = {
@@ -1861,10 +1864,10 @@
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) {
@@ -1950,13 +1953,6 @@
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);
@@ -2761,7 +2757,7 @@
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');
@@ -2770,6 +2766,8 @@
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+(?:in|of)\s+(.*)/;
4756+
var forIteratorRE = /\(([^,]*),([^,]*)(?:,([^,]*))?\)/;
47544757
var bindRE = /^:|^v-bind:/;
47554758
var onRE = /^@|^v-on:/;
47564759
var argRE = /:(.*)$/;
47574760
var modifierRE = /\.[^\.]+/g;
4758-
var forAliasRE = /(.*)\s+(?:in|of)\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-Za-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

Comments
 (0)