Skip to content

Commit 1cb4886

Browse files
committed
[build] 2.0.0-beta.8
1 parent 5b80d05 commit 1cb4886

File tree

9 files changed

+310
-198
lines changed

9 files changed

+310
-198
lines changed

dist/vue.common.js

+72-49
Original file line numberDiff line numberDiff line change
@@ -1334,15 +1334,10 @@ function applyNS(vnode, ns) {
13341334
}
13351335
}
13361336

1337-
// in case the child is also an abstract component, e.g. <transition-control>
1338-
// we want to recrusively retrieve the real component to be rendered
1339-
function getRealChild(vnode) {
1340-
var compOptions = vnode && vnode.componentOptions;
1341-
if (compOptions && compOptions.Ctor.options.abstract) {
1342-
return getRealChild(compOptions.propsData && compOptions.propsData.child);
1343-
} else {
1344-
return vnode;
1345-
}
1337+
function getFirstComponentChild(children) {
1338+
return children && children.filter(function (c) {
1339+
return c && c.componentOptions;
1340+
})[0];
13461341
}
13471342

13481343
function mergeVNodeHook(def, key, hook) {
@@ -1528,8 +1523,9 @@ function lifecycleMixin(Vue) {
15281523
vm.$options._parentListeners = listeners;
15291524
vm._updateListeners(listeners, oldListeners);
15301525
}
1531-
// force udpate if has children
1526+
// resolve slots + force update if has children
15321527
if (hasChildren) {
1528+
vm.$slots = resolveSlots(renderChildren);
15331529
vm.$forceUpdate();
15341530
}
15351531
};
@@ -1890,7 +1886,7 @@ function initRender(vm) {
18901886
vm.$vnode = null; // the placeholder node in parent tree
18911887
vm._vnode = null; // the root of the child tree
18921888
vm._staticTrees = null;
1893-
vm.$slots = {};
1889+
vm.$slots = resolveSlots(vm.$options._renderChildren);
18941890
// bind the public createElement fn to this instance
18951891
// so that we get proper render context inside it.
18961892
vm.$createElement = bind(createElement, vm);
@@ -1909,7 +1905,6 @@ function renderMixin(Vue) {
19091905
var _vm$$options = vm.$options;
19101906
var render = _vm$$options.render;
19111907
var staticRenderFns = _vm$$options.staticRenderFns;
1912-
var _renderChildren = _vm$$options._renderChildren;
19131908
var _parentVnode = _vm$$options._parentVnode;
19141909

19151910

@@ -1919,9 +1914,6 @@ function renderMixin(Vue) {
19191914
// set parent vnode. this allows render functions to have access
19201915
// to the data on the placeholder node.
19211916
vm.$vnode = _parentVnode;
1922-
// resolve slots. becaues slots are rendered in parent scope,
1923-
// we set the activeInstance to parent.
1924-
vm.$slots = resolveSlots(_renderChildren);
19251917
// render self
19261918
var vnode = void 0;
19271919
try {
@@ -1965,11 +1957,23 @@ function renderMixin(Vue) {
19651957
Vue.prototype._n = toNumber;
19661958

19671959
// render static tree by index
1968-
Vue.prototype._m = function renderStatic(index) {
1960+
Vue.prototype._m = function renderStatic(index, isInFor) {
19691961
var tree = this._staticTrees[index];
1970-
if (!tree) {
1971-
tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy);
1962+
// if has already-rendered static tree and not inside v-for,
1963+
// we can reuse the same tree by indentity.
1964+
if (tree && !isInFor) {
1965+
return tree;
1966+
}
1967+
// otherwise, render a fresh tree.
1968+
tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy);
1969+
if (Array.isArray(tree)) {
1970+
for (var i = 0; i < tree.length; i++) {
1971+
tree[i].isStatic = true;
1972+
tree[i].key = '__static__' + index + '_' + i;
1973+
}
1974+
} else {
19721975
tree.isStatic = true;
1976+
tree.key = '__static__' + index;
19731977
}
19741978
return tree;
19751979
};
@@ -2020,12 +2024,12 @@ function renderMixin(Vue) {
20202024
value = toObject(value);
20212025
}
20222026
var data = vnode.data;
2023-
for (var key in value) {
2024-
if (key === 'class' || key === 'style') {
2025-
data[key] = value[key];
2027+
for (var _key in value) {
2028+
if (_key === 'class' || _key === 'style') {
2029+
data[_key] = value[_key];
20262030
} else {
2027-
var hash = asProp || config.mustUseProp(key) ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {});
2028-
hash[key] = value[key];
2031+
var hash = asProp || config.mustUseProp(_key) ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {});
2032+
hash[_key] = value[_key];
20292033
}
20302034
}
20312035
}
@@ -2803,29 +2807,26 @@ function initAssetRegisters(Vue) {
28032807
var KeepAlive = {
28042808
name: 'keep-alive',
28052809
abstract: true,
2806-
props: {
2807-
child: Object
2808-
},
28092810
created: function created() {
28102811
this.cache = Object.create(null);
28112812
},
28122813
render: function render() {
2813-
var rawChild = this.child;
2814-
var realChild = getRealChild(this.child);
2815-
if (realChild && realChild.componentOptions) {
2816-
var opts = realChild.componentOptions;
2814+
var vnode = getFirstComponentChild(this.$slots.default);
2815+
if (vnode && vnode.componentOptions) {
2816+
var opts = vnode.componentOptions;
2817+
var key = vnode.key == null
28172818
// same constructor may get registered as different local components
28182819
// so cid alone is not enough (#3269)
2819-
var key = opts.Ctor.cid + '::' + opts.tag;
2820+
? opts.Ctor.cid + '::' + opts.tag : vnode.key;
28202821
if (this.cache[key]) {
2821-
var child = realChild.child = this.cache[key].child;
2822-
realChild.elm = this.$el = child.$el;
2822+
var child = vnode.child = this.cache[key].child;
2823+
vnode.elm = this.$el = child.$el;
28232824
} else {
2824-
this.cache[key] = realChild;
2825+
this.cache[key] = vnode;
28252826
}
2826-
realChild.data.keepAlive = true;
2827+
vnode.data.keepAlive = true;
28272828
}
2828-
return rawChild;
2829+
return vnode;
28292830
},
28302831
destroyed: function destroyed() {
28312832
for (var key in this.cache) {
@@ -2878,7 +2879,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
28782879
}
28792880
});
28802881

2881-
Vue.version = '2.0.0-beta.7';
2882+
Vue.version = '2.0.0-beta.8';
28822883

28832884
// attributes that should be using props for binding
28842885
var mustUseProp = makeMap('value,selected,checked,muted');
@@ -3035,8 +3036,10 @@ var isIE = UA$1 && /msie|trident/.test(UA$1);
30353036
var isIE9 = UA$1 && UA$1.indexOf('msie 9.0') > 0;
30363037
var isAndroid = UA$1 && UA$1.indexOf('android') > 0;
30373038

3038-
// some browsers, e.g. PhantomJS, encodes angular brackets
3039-
// inside attribute values when retrieving innerHTML.
3039+
// According to
3040+
// https://w3c.github.io/DOM-Parsing/#dfn-serializing-an-attribute-value
3041+
// when serializing innerHTML, <, >, ", & should be encoded as entities.
3042+
// However, only some browsers, e.g. PhantomJS, encodes < and >.
30403043
// this causes problems with the in-browser parser.
30413044
var shouldDecodeTags = inBrowser ? function () {
30423045
var div = document.createElement('div');
@@ -3140,9 +3143,6 @@ function isDef(s) {
31403143
}
31413144

31423145
function sameVnode(vnode1, vnode2) {
3143-
if (vnode1.isStatic || vnode2.isStatic) {
3144-
return vnode1 === vnode2;
3145-
}
31463146
return vnode1.key === vnode2.key && vnode1.tag === vnode2.tag && vnode1.isComment === vnode2.isComment && !vnode1.data === !vnode2.data;
31473147
}
31483148

@@ -3384,8 +3384,8 @@ function createPatchFunction(backend) {
33843384
newStartVnode = newCh[++newStartIdx];
33853385
} else {
33863386
if (isUndef(oldKeyToIdx)) oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
3387-
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : newStartVnode.isStatic ? oldCh.indexOf(newStartVnode) : null;
3388-
if (isUndef(idxInOld) || idxInOld === -1) {
3387+
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
3388+
if (isUndef(idxInOld)) {
33893389
// New element
33903390
nodeOps.insertBefore(parentElm, createElm(newStartVnode, insertedVnodeQueue), oldStartVnode.elm);
33913391
newStartVnode = newCh[++newStartIdx];
@@ -3417,7 +3417,13 @@ function createPatchFunction(backend) {
34173417
}
34183418

34193419
function patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly) {
3420-
if (oldVnode === vnode) return;
3420+
if (oldVnode === vnode) {
3421+
return;
3422+
}
3423+
if (vnode.isStatic && oldVnode.isStatic && vnode.key === oldVnode.key) {
3424+
vnode.elm = oldVnode.elm;
3425+
return;
3426+
}
34213427
var i = void 0,
34223428
hook = void 0;
34233429
var hasData = isDef(i = vnode.data);
@@ -4072,7 +4078,7 @@ function enter(vnode) {
40724078
}
40734079

40744080
/* istanbul ignore if */
4075-
if (el._enterCb) {
4081+
if (el._enterCb || el.nodeType !== 1) {
40764082
return;
40774083
}
40784084

@@ -4176,7 +4182,7 @@ function leave(vnode, rm) {
41764182
}
41774183

41784184
/* istanbul ignore if */
4179-
if (el._leaveCb) {
4185+
if (el._leaveCb || el.nodeType !== 1) {
41804186
return;
41814187
}
41824188

@@ -4429,7 +4435,10 @@ var show = {
44294435
},
44304436
update: function update(el, _ref2, vnode) {
44314437
var value = _ref2.value;
4438+
var oldValue = _ref2.oldValue;
44324439

4440+
/* istanbul ignore if */
4441+
if (value === oldValue) return;
44334442
vnode = locateNode(vnode);
44344443
var transition = vnode.data && vnode.data.transition;
44354444
if (transition && !isIE9) {
@@ -4466,6 +4475,17 @@ var transitionProps = {
44664475
appearActiveClass: String
44674476
};
44684477

4478+
// in case the child is also an abstract component, e.g. <keep-alive>
4479+
// we want to recrusively retrieve the real component to be rendered
4480+
function getRealChild(vnode) {
4481+
var compOptions = vnode && vnode.componentOptions;
4482+
if (compOptions && compOptions.Ctor.options.abstract) {
4483+
return getRealChild(getFirstComponentChild(compOptions.children));
4484+
} else {
4485+
return vnode;
4486+
}
4487+
}
4488+
44694489
function extractTransitionData(comp) {
44704490
var data = {};
44714491
var options = comp.$options;
@@ -4527,8 +4547,11 @@ var Transition = {
45274547
// use getRealChild() to ignore abstract components e.g. keep-alive
45284548
var child = getRealChild(rawChild);
45294549
/* istanbul ignore if */
4530-
if (!child) return;
4531-
child.key = child.key || '__v' + (child.tag + this._uid) + '__';
4550+
if (!child) {
4551+
return rawChild;
4552+
}
4553+
4554+
child.key = child.key == null ? '__v' + (child.tag + this._uid) + '__' : child.key;
45324555
var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
45334556
var oldRawChild = this._vnode;
45344557
var oldChild = getRealChild(oldRawChild);

0 commit comments

Comments
 (0)