Skip to content

Commit 900bfc1

Browse files
committed
[build] 2.0.0-alpha.5
1 parent 68a73cf commit 900bfc1

File tree

8 files changed

+219
-357
lines changed

8 files changed

+219
-357
lines changed

dist/vue.common.js

Lines changed: 46 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,28 +1054,6 @@ function del(obj, key) {
10541054
ob.dep.notify();
10551055
}
10561056

1057-
function proxy(vm, key) {
1058-
if (!isReserved(key)) {
1059-
Object.defineProperty(vm, key, {
1060-
configurable: true,
1061-
enumerable: true,
1062-
get: function proxyGetter() {
1063-
return vm._data[key];
1064-
},
1065-
set: function proxySetter(val) {
1066-
vm._data[key] = val;
1067-
}
1068-
});
1069-
}
1070-
}
1071-
1072-
// using Object type to avoid flow complaining
1073-
function unproxy(vm, key) {
1074-
if (!isReserved(key)) {
1075-
delete vm[key];
1076-
}
1077-
}
1078-
10791057
function initState(vm) {
10801058
vm._watchers = [];
10811059
initProps(vm);
@@ -1222,11 +1200,11 @@ function stateMixin(Vue) {
12221200
dataDef.get = function () {
12231201
return this._data;
12241202
};
1225-
dataDef.set = function (newData) {
1226-
if (newData !== this._data) {
1227-
setData(this, newData);
1228-
}
1229-
};
1203+
if (process.env.NODE_ENV !== 'production') {
1204+
dataDef.set = function (newData) {
1205+
warn('Avoid replacing instance root $data. ' + 'Use nested data properties instead.', this);
1206+
};
1207+
}
12301208
Object.defineProperty(Vue.prototype, '$data', dataDef);
12311209

12321210
Vue.prototype.$watch = function (expOrFn, cb, options) {
@@ -1243,37 +1221,19 @@ function stateMixin(Vue) {
12431221
};
12441222
}
12451223

1246-
function setData(vm, newData) {
1247-
newData = newData || {};
1248-
var oldData = vm._data;
1249-
vm._data = newData;
1250-
var keys = void 0,
1251-
key = void 0,
1252-
i = void 0;
1253-
// unproxy keys not present in new data
1254-
keys = Object.keys(oldData);
1255-
i = keys.length;
1256-
while (i--) {
1257-
key = keys[i];
1258-
if (!(key in newData)) {
1259-
unproxy(vm, key);
1260-
}
1261-
}
1262-
// proxy keys not already proxied,
1263-
// and trigger change for changed values
1264-
keys = Object.keys(newData);
1265-
i = keys.length;
1266-
while (i--) {
1267-
key = keys[i];
1268-
if (!hasOwn(vm, key)) {
1269-
// new property
1270-
proxy(vm, key);
1271-
}
1224+
function proxy(vm, key) {
1225+
if (!isReserved(key)) {
1226+
Object.defineProperty(vm, key, {
1227+
configurable: true,
1228+
enumerable: true,
1229+
get: function proxyGetter() {
1230+
return vm._data[key];
1231+
},
1232+
set: function proxySetter(val) {
1233+
vm._data[key] = val;
1234+
}
1235+
});
12721236
}
1273-
oldData.__ob__ && oldData.__ob__.vmCount--;
1274-
observe(newData);
1275-
newData.__ob__ && newData.__ob__.vmCount++;
1276-
vm.$forceUpdate();
12771237
}
12781238

12791239
var VNode = function () {
@@ -1593,7 +1553,10 @@ function createComponent(Ctor, data, parent, context, host, tag) {
15931553
data = data || {};
15941554

15951555
// merge component management hooks onto the placeholder node
1596-
mergeHooks(data);
1556+
// only need to do this if this is not a functional component
1557+
if (!Ctor.options.functional) {
1558+
mergeHooks(data);
1559+
}
15971560

15981561
// extract props
15991562
var propsData = extractProps(data, Ctor);
@@ -1773,12 +1736,24 @@ function mergeHook$1(a, b) {
17731736

17741737
function renderElementWithChildren(vnode, children) {
17751738
if (vnode) {
1776-
if (vnode.componentOptions) {
1739+
var componentOptions = vnode.componentOptions;
1740+
if (componentOptions) {
17771741
if (process.env.NODE_ENV !== 'production' && children && typeof children !== 'function') {
17781742
warn('A component\'s children should be a function that returns the ' + 'children array. This allows the component to track the children ' + 'dependencies and optimizes re-rendering.');
17791743
}
1780-
vnode.componentOptions.children = children;
1744+
var CtorOptions = componentOptions.Ctor.options;
1745+
// functional component
1746+
if (CtorOptions.functional) {
1747+
return CtorOptions.render.call(null, componentOptions.parent.$createElement, // h
1748+
componentOptions.propsData || {}, // props
1749+
normalizeChildren(children) // children
1750+
);
1751+
} else {
1752+
// normal component
1753+
componentOptions.children = children;
1754+
}
17811755
} else {
1756+
// normal element
17821757
vnode.setChildren(normalizeChildren(children));
17831758
}
17841759
}
@@ -1872,7 +1847,7 @@ function renderMixin(Vue) {
18721847
resolveSlots(vm, _renderChildren);
18731848
}
18741849
// render self
1875-
var vnode = render.call(vm._renderProxy);
1850+
var vnode = render.call(vm._renderProxy, vm.$createElement);
18761851
// return empty vnode in case the render function errored out
18771852
if (!(vnode instanceof VNode)) {
18781853
if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
@@ -2296,7 +2271,8 @@ function normalizeComponents(options) {
22962271
var components = options.components;
22972272
var def = void 0;
22982273
for (var key in components) {
2299-
if (isBuiltInTag(key) || config.isReservedTag(key)) {
2274+
var lower = key.toLowerCase();
2275+
if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
23002276
process.env.NODE_ENV !== 'production' && warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + key);
23012277
continue;
23022278
}
@@ -2757,7 +2733,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
27572733
}
27582734
});
27592735

2760-
Vue.version = '2.0.0-alpha.4';
2736+
Vue.version = '2.0.0-alpha.5';
27612737

27622738
// attributes that should be using props for binding
27632739
var mustUseProp = makeMap('value,selected,checked,muted');
@@ -3416,7 +3392,13 @@ function applyDirectives(oldVnode, vnode, hook) {
34163392

34173393
var ref = {
34183394
create: function create(_, vnode) {
3419-
registerRef(vnode, false);
3395+
registerRef(vnode);
3396+
},
3397+
update: function update(oldVnode, vnode) {
3398+
if (oldVnode.data.ref !== vnode.data.ref) {
3399+
registerRef(oldVnode, true);
3400+
registerRef(vnode);
3401+
}
34203402
},
34213403
destroy: function destroy(vnode) {
34223404
registerRef(vnode, true);

0 commit comments

Comments
 (0)