Skip to content

Commit b3f6d79

Browse files
committed
[build] 2.0.0-beta.7
1 parent e833d95 commit b3f6d79

File tree

8 files changed

+386
-369
lines changed

8 files changed

+386
-369
lines changed

dist/vue.common.js

Lines changed: 117 additions & 96 deletions
Large diffs are not rendered by default.

dist/vue.js

Lines changed: 126 additions & 109 deletions
Large diffs are not rendered by default.

dist/vue.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/vue-server-renderer/build.js

Lines changed: 81 additions & 84 deletions
Large diffs are not rendered by default.

packages/vue-server-renderer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-server-renderer",
3-
"version": "2.0.0-beta.6",
3+
"version": "2.0.0-beta.7",
44
"description": "server renderer for Vue 2.0",
55
"main": "index.js",
66
"repository": {

packages/vue-template-compiler/build.js

Lines changed: 56 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,45 +1264,45 @@ function proxy(vm, key) {
12641264
}
12651265
}
12661266

1267-
var VNode = function VNode(tag, data, children, text, elm, ns, context, host, componentOptions) {
1267+
var VNode = // hoisted static node
1268+
// compoennt placeholder node
1269+
// rendered in this component's scope
1270+
function VNode(tag, data, children, text, elm, ns, context, componentOptions) {
12681271
this.tag = tag;
12691272
this.data = data;
12701273
this.children = children;
12711274
this.text = text;
12721275
this.elm = elm;
12731276
this.ns = ns;
12741277
this.context = context;
1275-
this.host = host;
12761278
this.key = data && data.key;
12771279
this.componentOptions = componentOptions;
12781280
this.child = undefined;
12791281
this.parent = undefined;
12801282
this.raw = false;
12811283
this.isStatic = false;
1284+
this.isRootInsert = true;
1285+
this.isComment = false;
12821286
// apply construct hook.
12831287
// this is applied during render, before patch happens.
12841288
// unlike other hooks, this is applied on both client and server.
12851289
var constructHook = data && data.hook && data.hook.construct;
12861290
if (constructHook) {
12871291
constructHook(this);
12881292
}
1289-
};
1293+
} // necessary for enter transition check
1294+
// contains raw HTML
1295+
// component instance
1296+
;
12901297

12911298
var emptyVNode = function emptyVNode() {
1292-
return new VNode(undefined, undefined, undefined, '');
1299+
var node = new VNode();
1300+
node.text = '';
1301+
node.isComment = true;
1302+
return node;
12931303
};
12941304

12951305
function normalizeChildren(children, ns) {
1296-
// Invoke children thunks. Components always receive their children
1297-
// as thunks so that they can perform the actual render inside their
1298-
// own dependency collection cycle. Also, since JSX automatically
1299-
// wraps component children in a thunk, we handle nested thunks to
1300-
// prevent situations such as <MyComponent>{ children }</MyComponent>
1301-
// from failing when it produces a double thunk.
1302-
while (typeof children === 'function') {
1303-
children = children();
1304-
}
1305-
13061306
if (isPrimitive(children)) {
13071307
return [createTextVNode(children)];
13081308
}
@@ -1317,7 +1317,7 @@ function normalizeChildren(children, ns) {
13171317
} else if (isPrimitive(c)) {
13181318
if (last && last.text) {
13191319
last.text += String(c);
1320-
} else {
1320+
} else if (c !== '') {
13211321
// convert primitive to vnode
13221322
res.push(createTextVNode(c));
13231323
}
@@ -1407,6 +1407,8 @@ function fnInvoker(o) {
14071407
};
14081408
}
14091409

1410+
var activeInstance = null;
1411+
14101412
function initLifecycle(vm) {
14111413
var options = vm.$options;
14121414

@@ -1467,13 +1469,16 @@ function lifecycleMixin(Vue) {
14671469
callHook(vm, 'beforeUpdate');
14681470
}
14691471
var prevEl = vm.$el;
1472+
var prevActiveInstance = activeInstance;
1473+
activeInstance = vm;
14701474
if (!vm._vnode) {
14711475
// Vue.prototype.__patch__ is injected in entry points
14721476
// based on the rendering backend used.
14731477
vm.$el = vm.__patch__(vm.$el, vnode, hydrating);
14741478
} else {
14751479
vm.$el = vm.__patch__(vm._vnode, vnode);
14761480
}
1481+
activeInstance = prevActiveInstance;
14771482
vm._vnode = vnode;
14781483
// update __vue__ reference
14791484
if (prevEl) {
@@ -1493,6 +1498,7 @@ function lifecycleMixin(Vue) {
14931498

14941499
Vue.prototype._updateFromParent = function (propsData, listeners, parentVnode, renderChildren) {
14951500
var vm = this;
1501+
var hasChildren = !!(vm.$options._renderChildren || renderChildren);
14961502
vm.$options._parentVnode = parentVnode;
14971503
vm.$options._renderChildren = renderChildren;
14981504
// update props
@@ -1517,6 +1523,10 @@ function lifecycleMixin(Vue) {
15171523
vm.$options._parentListeners = listeners;
15181524
vm._updateListeners(listeners, oldListeners);
15191525
}
1526+
// force udpate if has children
1527+
if (hasChildren) {
1528+
vm.$forceUpdate();
1529+
}
15201530
};
15211531

15221532
Vue.prototype.$forceUpdate = function () {
@@ -1581,12 +1591,7 @@ function callHook(vm, hook) {
15811591
var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy };
15821592
var hooksToMerge = Object.keys(hooks);
15831593

1584-
function createComponent(Ctor, data, parent, context, host, _children, tag) {
1585-
// ensure children is a thunk
1586-
if (process.env.NODE_ENV !== 'production' && _children && typeof _children !== 'function') {
1587-
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.');
1588-
}
1589-
1594+
function createComponent(Ctor, data, context, children, tag) {
15901595
if (!Ctor) {
15911596
return;
15921597
}
@@ -1597,7 +1602,7 @@ function createComponent(Ctor, data, parent, context, host, _children, tag) {
15971602

15981603
if (typeof Ctor !== 'function') {
15991604
if (process.env.NODE_ENV !== 'production') {
1600-
warn('Invalid Component definition: ' + Ctor, parent);
1605+
warn('Invalid Component definition: ' + Ctor, context);
16011606
}
16021607
return;
16031608
}
@@ -1609,9 +1614,8 @@ function createComponent(Ctor, data, parent, context, host, _children, tag) {
16091614
} else {
16101615
Ctor = resolveAsyncComponent(Ctor, function () {
16111616
// it's ok to queue this on every render because
1612-
// $forceUpdate is buffered. this is only called
1613-
// if the
1614-
parent.$forceUpdate();
1617+
// $forceUpdate is buffered by the scheduler.
1618+
context.$forceUpdate();
16151619
});
16161620
if (!Ctor) {
16171621
// return nothing if this is indeed an async component
@@ -1637,15 +1641,13 @@ function createComponent(Ctor, data, parent, context, host, _children, tag) {
16371641
});
16381642
}
16391643
return {
1640-
v: Ctor.options.render.call(null, parent.$createElement, {
1644+
v: Ctor.options.render.call(null, context.$createElement, {
16411645
props: props,
1642-
parent: parent,
16431646
data: data,
1644-
children: function children() {
1645-
return normalizeChildren(_children);
1646-
},
1647+
parent: context,
1648+
children: normalizeChildren(children),
16471649
slots: function slots() {
1648-
return resolveSlots(_children);
1650+
return resolveSlots(children);
16491651
}
16501652
})
16511653
};
@@ -1671,16 +1673,17 @@ function createComponent(Ctor, data, parent, context, host, _children, tag) {
16711673

16721674
// return a placeholder vnode
16731675
var name = Ctor.options.name || tag;
1674-
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: _children });
1676+
var vnode = new VNode('vue-component-' + Ctor.cid + (name ? '-' + name : ''), data, undefined, undefined, undefined, undefined, context, { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children });
16751677
return vnode;
16761678
}
16771679

1678-
function createComponentInstanceForVnode(vnode // we know it's MountedComponentVNode but flow doesn't
1680+
function createComponentInstanceForVnode(vnode, // we know it's MountedComponentVNode but flow doesn't
1681+
parent // activeInstance in lifecycle state
16791682
) {
16801683
var vnodeComponentOptions = vnode.componentOptions;
16811684
var options = {
16821685
_isComponent: true,
1683-
parent: vnodeComponentOptions.parent,
1686+
parent: parent,
16841687
propsData: vnodeComponentOptions.propsData,
16851688
_componentTag: vnodeComponentOptions.tag,
16861689
_parentVnode: vnode,
@@ -1698,7 +1701,7 @@ function createComponentInstanceForVnode(vnode // we know it's MountedComponentV
16981701

16991702
function init(vnode, hydrating) {
17001703
if (!vnode.child) {
1701-
var child = vnode.child = createComponentInstanceForVnode(vnode);
1704+
var child = vnode.child = createComponentInstanceForVnode(vnode, activeInstance);
17021705
child.$mount(hydrating ? vnode.elm : undefined, hydrating);
17031706
}
17041707
}
@@ -1711,10 +1714,6 @@ function prepatch(oldVnode, vnode) {
17111714
vnode, // new parent vnode
17121715
options.children // new children
17131716
);
1714-
// always update abstract components.
1715-
if (child.$options.abstract) {
1716-
child.$forceUpdate();
1717-
}
17181717
}
17191718

17201719
function insert(vnode) {
@@ -1853,12 +1852,6 @@ function createElement(tag, data, children) {
18531852
}
18541853

18551854
function _createElement(context, tag, data, children) {
1856-
var parent = renderState.activeInstance;
1857-
var host = context !== parent ? parent : undefined;
1858-
if (!parent) {
1859-
process.env.NODE_ENV !== 'production' && warn('createElement cannot be called outside of component ' + 'render functions.');
1860-
return;
1861-
}
18621855
if (data && data.__ob__) {
18631856
process.env.NODE_ENV !== 'production' && warn('Avoid using observed data object as vnode data: ' + JSON.stringify(data) + '\n' + 'Always create fresh vnode data objects in each render!', context);
18641857
return;
@@ -1872,26 +1865,22 @@ function _createElement(context, tag, data, children) {
18721865
var ns = config.getTagNamespace(tag);
18731866
if (config.isReservedTag(tag)) {
18741867
// platform built-in elements
1875-
return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context, host);
1868+
return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context);
18761869
} else if (Ctor = resolveAsset(context.$options, 'components', tag)) {
18771870
// component
1878-
return createComponent(Ctor, data, parent, context, host, children, tag);
1871+
return createComponent(Ctor, data, context, children, tag);
18791872
} else {
18801873
// unknown or unlisted namespaced elements
18811874
// check at runtime because it may get assigned a namespace when its
18821875
// parent normalizes children
1883-
return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context, host);
1876+
return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context);
18841877
}
18851878
} else {
18861879
// direct component options / constructor
1887-
return createComponent(tag, data, parent, context, host, children);
1880+
return createComponent(tag, data, context, children);
18881881
}
18891882
}
18901883

1891-
var renderState = {
1892-
activeInstance: null
1893-
};
1894-
18951884
function initRender(vm) {
18961885
vm.$vnode = null; // the placeholder node in parent tree
18971886
vm._vnode = null; // the root of the child tree
@@ -1912,11 +1901,6 @@ function renderMixin(Vue) {
19121901

19131902
Vue.prototype._render = function () {
19141903
var vm = this;
1915-
1916-
// set current active instance
1917-
var prev = renderState.activeInstance;
1918-
renderState.activeInstance = vm;
1919-
19201904
var _vm$$options = vm.$options;
19211905
var render = _vm$$options.render;
19221906
var staticRenderFns = _vm$$options.staticRenderFns;
@@ -1965,8 +1949,6 @@ function renderMixin(Vue) {
19651949
}
19661950
// set parent
19671951
vnode.parent = _parentVnode;
1968-
// restore render state
1969-
renderState.activeInstance = prev;
19701952
return vnode;
19711953
};
19721954

@@ -2034,8 +2016,12 @@ function renderMixin(Vue) {
20342016
}
20352017
var data = vnode.data;
20362018
for (var key in value) {
2037-
var hash = asProp || config.mustUseProp(key) ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {});
2038-
hash[key] = value[key];
2019+
if (key === 'class' || key === 'style') {
2020+
data[key] = value[key];
2021+
} else {
2022+
var hash = asProp || config.mustUseProp(key) ? data.domProps || (data.domProps = {}) : data.attrs || (data.attrs = {});
2023+
hash[key] = value[key];
2024+
}
20392025
}
20402026
}
20412027
}
@@ -3730,7 +3716,6 @@ var warn$2 = void 0;
37303716
var transforms$1 = void 0;
37313717
var dataGenFns = void 0;
37323718
var platformDirectives = void 0;
3733-
var isPlatformReservedTag$1 = void 0;
37343719
var staticRenderFns = void 0;
37353720
var currentOptions = void 0;
37363721

@@ -3743,7 +3728,6 @@ function generate(ast, options) {
37433728
transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
37443729
dataGenFns = pluckModuleFunction(options.modules, 'genData');
37453730
platformDirectives = options.directives || {};
3746-
isPlatformReservedTag$1 = options.isReservedTag || no;
37473731
var code = ast ? genElement(ast) : '_h("div")';
37483732
// console.log(code)
37493733
staticRenderFns = prevStaticRenderFns;
@@ -3774,9 +3758,7 @@ function genElement(el) {
37743758
code = genComponent(el);
37753759
} else {
37763760
var data = genData(el);
3777-
// if the element is potentially a component,
3778-
// wrap its children as a thunk.
3779-
var children = !el.inlineTemplate ? genChildren(el, !isPlatformReservedTag$1(el.tag) /* asThunk */) : null;
3761+
var children = el.inlineTemplate ? null : genChildren(el);
37803762
code = '_h(\'' + el.tag + '\'' + (data ? ',' + data : '' // data
37813763
) + (children ? ',' + children : '' // children
37823764
) + ')';
@@ -3915,12 +3897,10 @@ function genDirectives(el) {
39153897
}
39163898
}
39173899

3918-
function genChildren(el, asThunk) {
3919-
if (!el.children.length) {
3920-
return;
3900+
function genChildren(el) {
3901+
if (el.children.length) {
3902+
return '[' + el.children.map(genNode).join(',') + ']';
39213903
}
3922-
var code = '[' + el.children.map(genNode).join(',') + ']';
3923-
return asThunk ? 'function(){return ' + code + '}' : code;
39243904
}
39253905

39263906
function genNode(node) {
@@ -3943,7 +3923,7 @@ function genSlot(el) {
39433923
}
39443924

39453925
function genComponent(el) {
3946-
var children = genChildren(el, true);
3926+
var children = genChildren(el);
39473927
return '_h(' + el.component + ',' + genData(el) + (children ? ',' + children : '') + ')';
39483928
}
39493929

@@ -4053,7 +4033,9 @@ function transformNode(el, options) {
40534033
warn('class="' + staticClass + '": ' + 'Interpolation inside attributes has been deprecated. ' + 'Use v-bind or the colon shorthand instead.');
40544034
}
40554035
}
4056-
el.staticClass = JSON.stringify(staticClass);
4036+
if (staticClass) {
4037+
el.staticClass = JSON.stringify(staticClass);
4038+
}
40574039
var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
40584040
if (classBinding) {
40594041
el.classBinding = classBinding;

packages/vue-template-compiler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-template-compiler",
3-
"version": "2.0.0-beta.6",
3+
"version": "2.0.0-beta.7",
44
"description": "template compiler for Vue 2.0",
55
"main": "index.js",
66
"repository": {

src/core/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ Object.defineProperty(Vue.prototype, '$isServer', {
88
get: () => config._isServer
99
})
1010

11-
Vue.version = '2.0.0-beta.6'
11+
Vue.version = '2.0.0-beta.7'
1212

1313
export default Vue

0 commit comments

Comments
 (0)