Skip to content

Commit 179e9fd

Browse files
committed
[build] 2.0.0-rc.2
1 parent ac762c3 commit 179e9fd

File tree

8 files changed

+254
-132
lines changed

8 files changed

+254
-132
lines changed

dist/vue.common.js

Lines changed: 71 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ if (process.env.NODE_ENV !== 'production') {
428428
var has = key in target;
429429
var isAllowedGlobal = allowedGlobals(key);
430430
if (!has && !isAllowedGlobal) {
431-
warn('Trying to access non-existent property "' + key + '" while rendering. ' + 'Make sure to declare reactive data properties in the data option.', target);
431+
warn('Property or method "' + key + '" is not defined on the instance but ' + 'referenced during render. Make sure to declare reactive data ' + 'properties in the data option.', target);
432432
}
433433
return !isAllowedGlobal;
434434
}
@@ -1362,7 +1362,9 @@ function updateListeners(on, oldOn, add, remove) {
13621362
for (name in on) {
13631363
cur = on[name];
13641364
old = oldOn[name];
1365-
if (!old) {
1365+
if (!cur) {
1366+
process.env.NODE_ENV !== 'production' && warn('Handler for event "' + name + '" is undefined.');
1367+
} else if (!old) {
13661368
capture = name.charAt(0) === '!';
13671369
event = capture ? name.slice(1) : name;
13681370
if (Array.isArray(cur)) {
@@ -1471,15 +1473,16 @@ function lifecycleMixin(Vue) {
14711473
var prevEl = vm.$el;
14721474
var prevActiveInstance = activeInstance;
14731475
activeInstance = vm;
1474-
if (!vm._vnode) {
1476+
var prevVnode = vm._vnode;
1477+
vm._vnode = vnode;
1478+
if (!prevVnode) {
14751479
// Vue.prototype.__patch__ is injected in entry points
14761480
// based on the rendering backend used.
14771481
vm.$el = vm.__patch__(vm.$el, vnode, hydrating);
14781482
} else {
1479-
vm.$el = vm.__patch__(vm._vnode, vnode);
1483+
vm.$el = vm.__patch__(prevVnode, vnode);
14801484
}
14811485
activeInstance = prevActiveInstance;
1482-
vm._vnode = vnode;
14831486
// update __vue__ reference
14841487
if (prevEl) {
14851488
prevEl.__vue__ = null;
@@ -1535,11 +1538,6 @@ function lifecycleMixin(Vue) {
15351538
if (vm._watcher) {
15361539
vm._watcher.update();
15371540
}
1538-
if (vm._watchers.length) {
1539-
for (var i = 0; i < vm._watchers.length; i++) {
1540-
vm._watchers[i].update(true /* shallow */);
1541-
}
1542-
}
15431541
};
15441542

15451543
Vue.prototype.$destroy = function () {
@@ -1701,7 +1699,7 @@ parent // activeInstance in lifecycle state
17011699
}
17021700

17031701
function init(vnode, hydrating) {
1704-
if (!vnode.child) {
1702+
if (!vnode.child || vnode.child._isDestroyed) {
17051703
var child = vnode.child = createComponentInstanceForVnode(vnode, activeInstance);
17061704
child.$mount(hydrating ? vnode.elm : undefined, hydrating);
17071705
}
@@ -2822,8 +2820,7 @@ var KeepAlive = {
28222820
// so cid alone is not enough (#3269)
28232821
? opts.Ctor.cid + '::' + opts.tag : vnode.key;
28242822
if (this.cache[key]) {
2825-
var child = vnode.child = this.cache[key].child;
2826-
vnode.elm = this.$el = child.$el;
2823+
vnode.child = this.cache[key].child;
28272824
} else {
28282825
this.cache[key] = vnode;
28292826
}
@@ -2882,7 +2879,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
28822879
}
28832880
});
28842881

2885-
Vue.version = '2.0.0-rc.1';
2882+
Vue.version = '2.0.0-rc.2';
28862883

28872884
// attributes that should be using props for binding
28882885
var mustUseProp = makeMap('value,selected,checked,muted');
@@ -3239,6 +3236,13 @@ function createPatchFunction(backend) {
32393236
return vnode.elm;
32403237
}
32413238

3239+
function isPatchable(vnode) {
3240+
while (vnode.child) {
3241+
vnode = vnode.child._vnode;
3242+
}
3243+
return isDef(vnode.tag);
3244+
}
3245+
32423246
function invokeCreateHooks(vnode, insertedVnodeQueue) {
32433247
for (var _i = 0; _i < cbs.create.length; ++_i) {
32443248
cbs.create[_i](emptyNode, vnode);
@@ -3255,8 +3259,12 @@ function createPatchFunction(backend) {
32553259
insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
32563260
}
32573261
vnode.elm = vnode.child.$el;
3258-
invokeCreateHooks(vnode, insertedVnodeQueue);
3259-
setScope(vnode);
3262+
if (isPatchable(vnode)) {
3263+
invokeCreateHooks(vnode, insertedVnodeQueue);
3264+
setScope(vnode);
3265+
} else {
3266+
insertedVnodeQueue.push(vnode);
3267+
}
32603268
}
32613269

32623270
// set scope id attribute for scoped CSS.
@@ -3436,7 +3444,7 @@ function createPatchFunction(backend) {
34363444
var elm = vnode.elm = oldVnode.elm;
34373445
var oldCh = oldVnode.children;
34383446
var ch = vnode.children;
3439-
if (hasData) {
3447+
if (hasData && isPatchable(vnode)) {
34403448
for (i = 0; i < cbs.update.length; ++i) {
34413449
cbs.update[i](oldVnode, vnode);
34423450
}if (isDef(hook) && isDef(i = hook.update)) i(oldVnode, vnode);
@@ -3576,8 +3584,10 @@ function createPatchFunction(backend) {
35763584
// update parent placeholder node element.
35773585
if (vnode.parent) {
35783586
vnode.parent.elm = vnode.elm;
3579-
for (var _i4 = 0; _i4 < cbs.create.length; ++_i4) {
3580-
cbs.create[_i4](emptyNode, vnode.parent);
3587+
if (isPatchable(vnode)) {
3588+
for (var _i4 = 0; _i4 < cbs.create.length; ++_i4) {
3589+
cbs.create[_i4](emptyNode, vnode.parent);
3590+
}
35813591
}
35823592
}
35833593

@@ -4142,15 +4152,17 @@ function enter(vnode) {
41424152
el._enterCb = null;
41434153
});
41444154

4145-
// remove pending leave element on enter by injecting an insert hook
4146-
mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
4147-
var parent = el.parentNode;
4148-
var pendingNode = parent._pending && parent._pending[vnode.key];
4149-
if (pendingNode && pendingNode.tag === vnode.tag && pendingNode.elm._leaveCb) {
4150-
pendingNode.elm._leaveCb();
4151-
}
4152-
enterHook && enterHook(el, cb);
4153-
});
4155+
if (!vnode.data.show) {
4156+
// remove pending leave element on enter by injecting an insert hook
4157+
mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
4158+
var parent = el.parentNode;
4159+
var pendingNode = parent._pending && parent._pending[vnode.key];
4160+
if (pendingNode && pendingNode.tag === vnode.tag && pendingNode.elm._leaveCb) {
4161+
pendingNode.elm._leaveCb();
4162+
}
4163+
enterHook && enterHook(el, cb);
4164+
});
4165+
}
41544166

41554167
// start enter transition
41564168
beforeEnterHook && beforeEnterHook(el);
@@ -4165,6 +4177,10 @@ function enter(vnode) {
41654177
});
41664178
}
41674179

4180+
if (vnode.data.show) {
4181+
enterHook && enterHook(el, cb);
4182+
}
4183+
41684184
if (!expectsCSS && !userWantsControl) {
41694185
cb();
41704186
}
@@ -4434,7 +4450,9 @@ var show = {
44344450
if (value && transition && transition.appear && !isIE9) {
44354451
enter(vnode);
44364452
}
4437-
el.style.display = value ? '' : 'none';
4453+
var originalDisplay = el.style.display;
4454+
el.style.display = value ? originalDisplay : 'none';
4455+
el.__vOriginalDisplay = originalDisplay;
44384456
},
44394457
update: function update(el, _ref2, vnode) {
44404458
var value = _ref2.value;
@@ -4447,14 +4465,14 @@ var show = {
44474465
if (transition && !isIE9) {
44484466
if (value) {
44494467
enter(vnode);
4450-
el.style.display = '';
4468+
el.style.display = el.__vOriginalDisplay;
44514469
} else {
44524470
leave(vnode, function () {
44534471
el.style.display = 'none';
44544472
});
44554473
}
44564474
} else {
4457-
el.style.display = value ? '' : 'none';
4475+
el.style.display = value ? el.__vOriginalDisplay : 'none';
44584476
}
44594477
}
44604478
};
@@ -4505,6 +4523,19 @@ function extractTransitionData(comp) {
45054523
return data;
45064524
}
45074525

4526+
function placeholder(h, rawChild) {
4527+
return (/\d-keep-alive$/.test(rawChild.tag) ? h('keep-alive') : null
4528+
);
4529+
}
4530+
4531+
function hasParentTransition(vnode) {
4532+
while (vnode = vnode.parent) {
4533+
if (vnode.data.transition) {
4534+
return true;
4535+
}
4536+
}
4537+
}
4538+
45084539
var Transition = {
45094540
name: 'transition',
45104541
props: transitionProps,
@@ -4542,7 +4573,7 @@ var Transition = {
45424573

45434574
// if this is a component root node and the component's
45444575
// parent container node also has transition, skip.
4545-
if (this.$vnode.parent && this.$vnode.parent.data.transition) {
4576+
if (hasParentTransition(this.$vnode)) {
45464577
return rawChild;
45474578
}
45484579

@@ -4554,6 +4585,10 @@ var Transition = {
45544585
return rawChild;
45554586
}
45564587

4588+
if (this._leaving) {
4589+
return placeholder(h, rawChild);
4590+
}
4591+
45574592
child.key = child.key == null ? '__v' + (child.tag + this._uid) + '__' : child.key;
45584593
var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
45594594
var oldRawChild = this._vnode;
@@ -4566,12 +4601,13 @@ var Transition = {
45664601

45674602
// handle transition mode
45684603
if (mode === 'out-in') {
4569-
// return empty node and queue update when leave finishes
4604+
// return placeholder node and queue update when leave finishes
4605+
this._leaving = true;
45704606
mergeVNodeHook(oldData, 'afterLeave', function () {
4607+
_this._leaving = false;
45714608
_this.$forceUpdate();
45724609
});
4573-
return (/\d-keep-alive$/.test(rawChild.tag) ? h('keep-alive') : null
4574-
);
4610+
return placeholder(h, rawChild);
45754611
} else if (mode === 'in-out') {
45764612
(function () {
45774613
var delayedLeave = void 0;

0 commit comments

Comments
 (0)