mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-02 03:57:36 +08:00
[build] 2.0.0-beta.1
This commit is contained in:
parent
d164cf537a
commit
a09e8bf9a3
210
dist/vue.common.js
vendored
210
dist/vue.common.js
vendored
@ -96,9 +96,9 @@ var capitalize = cached(function (str) {
|
||||
/**
|
||||
* Hyphenate a camelCase string.
|
||||
*/
|
||||
var hyphenateRE = /([a-z\d])([A-Z])/g;
|
||||
var hyphenateRE = /([^-])([A-Z])/g;
|
||||
var hyphenate = cached(function (str) {
|
||||
return str.replace(hyphenateRE, '$1-$2').toLowerCase();
|
||||
return str.replace(hyphenateRE, '$1-$2').replace(hyphenateRE, '$1-$2').toLowerCase();
|
||||
});
|
||||
|
||||
/**
|
||||
@ -285,7 +285,7 @@ function def(obj, key, val, enumerable) {
|
||||
/**
|
||||
* Parse simple path.
|
||||
*/
|
||||
var bailRE = /[^\w\.]/;
|
||||
var bailRE = /[^\w\.\$]/;
|
||||
function parsePath(path) {
|
||||
if (bailRE.test(path)) {
|
||||
return;
|
||||
@ -623,7 +623,7 @@ var Watcher = function () {
|
||||
this.getter = parsePath(expOrFn);
|
||||
if (!this.getter) {
|
||||
this.getter = function () {};
|
||||
process.env.NODE_ENV !== 'production' && warn('Failed watching path: ' + expOrFn + 'Watcher only accepts simple dot-delimited paths. ' + 'For full control, use a function instead.', vm);
|
||||
process.env.NODE_ENV !== 'production' && warn('Failed watching path: "' + expOrFn + '" ' + 'Watcher only accepts simple dot-delimited paths. ' + 'For full control, use a function instead.', vm);
|
||||
}
|
||||
}
|
||||
this.value = this.lazy ? undefined : this.get();
|
||||
@ -646,12 +646,12 @@ var Watcher = function () {
|
||||
} else {
|
||||
warn('Error during component render', this.vm);
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (config.errorHandler) {
|
||||
config.errorHandler.call(null, e, this.vm);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (config.errorHandler) {
|
||||
config.errorHandler.call(null, e, this.vm);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
// return old value when evaluation fails so the current UI is preserved
|
||||
// if the error was somehow handled by user
|
||||
@ -1109,13 +1109,13 @@ function initProps(vm) {
|
||||
var key = keys[i];
|
||||
/* istanbul ignore else */
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
defineReactive(vm, key, validateProp(vm, key, propsData), function () {
|
||||
defineReactive(vm, key, validateProp(key, props, propsData, vm), function () {
|
||||
if (vm.$parent && !observerState.isSettingProps) {
|
||||
warn('Avoid mutating a prop directly since the value will be ' + 'overwritten whenever the parent component re-renders. ' + 'Instead, use a data or computed property based on the prop\'s ' + ('value. Prop being mutated: "' + key + '"'), vm);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
defineReactive(vm, key, validateProp(vm, key, propsData));
|
||||
defineReactive(vm, key, validateProp(key, props, propsData, vm));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1326,7 +1326,9 @@ function normalizeChildren(children, ns) {
|
||||
last.text += c.text;
|
||||
} else {
|
||||
// inherit parent namespace
|
||||
if (ns && c.tag) c.ns = ns;
|
||||
if (ns) {
|
||||
applyNS(c, ns);
|
||||
}
|
||||
res.push(c);
|
||||
}
|
||||
}
|
||||
@ -1339,6 +1341,28 @@ function createTextVNode(val) {
|
||||
return new VNode(undefined, undefined, undefined, String(val));
|
||||
}
|
||||
|
||||
function applyNS(vnode, ns) {
|
||||
if (vnode.tag && !vnode.ns) {
|
||||
vnode.ns = ns;
|
||||
if (vnode.children) {
|
||||
for (var i = 0, l = vnode.children.length; i < l; i++) {
|
||||
applyNS(vnode.children[i], ns);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// in case the child is also an abstract component, e.g. <transition-control>
|
||||
// we want to recrusively retrieve the real component to be rendered
|
||||
function getRealChild(vnode) {
|
||||
var compOptions = vnode && vnode.componentOptions;
|
||||
if (compOptions && compOptions.Ctor.options._abstract) {
|
||||
return getRealChild(compOptions.propsData && compOptions.propsData.child);
|
||||
} else {
|
||||
return vnode;
|
||||
}
|
||||
}
|
||||
|
||||
function updateListeners(on, oldOn, add, remove) {
|
||||
var name = void 0,
|
||||
cur = void 0,
|
||||
@ -1463,15 +1487,9 @@ function lifecycleMixin(Vue) {
|
||||
if (vm.$el) {
|
||||
vm.$el.__vue__ = vm;
|
||||
}
|
||||
// update parent vnode element after patch
|
||||
var parentNode = vm.$options._parentVnode;
|
||||
if (parentNode) {
|
||||
parentNode.elm = vm.$el;
|
||||
// update parent $el if the parent is HOC
|
||||
// this is necessary because child is updated after parent
|
||||
if (vm.$parent && parentNode === vm.$parent._vnode) {
|
||||
vm.$parent.$el = vm.$el;
|
||||
}
|
||||
// if parent is an HOC, update its $el as well
|
||||
if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
|
||||
vm.$parent.$el = vm.$el;
|
||||
}
|
||||
if (vm._isMounted) {
|
||||
callHook(vm, 'updated');
|
||||
@ -1491,7 +1509,7 @@ function lifecycleMixin(Vue) {
|
||||
var propKeys = vm.$options._propKeys || [];
|
||||
for (var i = 0; i < propKeys.length; i++) {
|
||||
var key = propKeys[i];
|
||||
vm[key] = validateProp(vm, key, propsData);
|
||||
vm[key] = validateProp(key, vm.$options.props, propsData, vm);
|
||||
}
|
||||
observerState.shouldConvert = true;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
@ -1569,9 +1587,9 @@ function callHook(vm, hook) {
|
||||
var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy };
|
||||
var hooksToMerge = Object.keys(hooks);
|
||||
|
||||
function createComponent(Ctor, data, parent, context, host, children, tag) {
|
||||
function createComponent(Ctor, data, parent, context, host, _children, tag) {
|
||||
// ensure children is a thunk
|
||||
if (process.env.NODE_ENV !== 'production' && children && typeof children !== 'function') {
|
||||
if (process.env.NODE_ENV !== 'production' && _children && typeof _children !== 'function') {
|
||||
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.');
|
||||
}
|
||||
|
||||
@ -1616,10 +1634,22 @@ function createComponent(Ctor, data, parent, context, host, children, tag) {
|
||||
|
||||
// functional component
|
||||
if (Ctor.options.functional) {
|
||||
return Ctor.options.render.call(null, parent.$createElement, // h
|
||||
propsData || {}, // props
|
||||
normalizeChildren(children) // children
|
||||
);
|
||||
var _ret = function () {
|
||||
var props = {};
|
||||
var propOptions = Ctor.options.props;
|
||||
if (propOptions) {
|
||||
Object.keys(propOptions).forEach(function (key) {
|
||||
props[key] = validateProp(key, propOptions, propsData);
|
||||
});
|
||||
}
|
||||
return {
|
||||
v: Ctor.options.render.call(null, parent.$createElement, { props: props, parent: parent, data: data, children: function children() {
|
||||
return normalizeChildren(_children);
|
||||
} })
|
||||
};
|
||||
}();
|
||||
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
}
|
||||
|
||||
// merge component management hooks onto the placeholder node
|
||||
@ -1634,7 +1664,7 @@ function createComponent(Ctor, data, parent, context, host, children, tag) {
|
||||
|
||||
// return a placeholder vnode
|
||||
var name = Ctor.options.name || tag;
|
||||
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 });
|
||||
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 });
|
||||
return vnode;
|
||||
}
|
||||
|
||||
@ -1703,7 +1733,7 @@ function resolveAsyncComponent(factory, cb) {
|
||||
// pool callbacks
|
||||
factory.pendingCallbacks.push(cb);
|
||||
} else {
|
||||
var _ret = function () {
|
||||
var _ret2 = function () {
|
||||
factory.requested = true;
|
||||
var cbs = factory.pendingCallbacks = [cb];
|
||||
var sync = true;
|
||||
@ -1734,7 +1764,7 @@ function resolveAsyncComponent(factory, cb) {
|
||||
};
|
||||
}();
|
||||
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
if (typeof _ret2 === "object") return _ret2.v;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1821,21 +1851,22 @@ function _createElement(tag, data, children) {
|
||||
return emptyVNode();
|
||||
}
|
||||
if (typeof tag === 'string') {
|
||||
var namespace = config.getTagNamespace(tag);
|
||||
var Ctor = void 0;
|
||||
if (config.isReservedTag(tag)) {
|
||||
return new VNode(tag, data, normalizeChildren(children, namespace), undefined, undefined, namespace, context, host);
|
||||
// platform built-in elements
|
||||
return new VNode(tag, data, normalizeChildren(children), undefined, undefined, undefined, context, host);
|
||||
} else if (Ctor = resolveAsset(context.$options, 'components', tag)) {
|
||||
// component
|
||||
return createComponent(Ctor, data, parent, context, host, children, tag);
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!namespace && !(config.ignoredElements && config.ignoredElements.indexOf(tag) > -1) && config.isUnknownElement(tag)) {
|
||||
warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.');
|
||||
}
|
||||
}
|
||||
return new VNode(tag, data, normalizeChildren(children, namespace), undefined, undefined, namespace, context, host);
|
||||
// unknown or namespaced elements
|
||||
// check at runtime because it may get assigned a namespace when its
|
||||
// parent normalizes children
|
||||
var ns = config.getTagNamespace(tag);
|
||||
return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context, host);
|
||||
}
|
||||
} else {
|
||||
// direct component options / constructor
|
||||
return createComponent(tag, data, parent, context, host, children);
|
||||
}
|
||||
}
|
||||
@ -1845,7 +1876,8 @@ var renderState = {
|
||||
};
|
||||
|
||||
function initRender(vm) {
|
||||
vm._vnode = null;
|
||||
vm.$vnode = null; // the placeholder node in parent tree
|
||||
vm._vnode = null; // the root of the child tree
|
||||
vm._staticTrees = null;
|
||||
vm.$slots = {};
|
||||
// bind the public createElement fn to this instance
|
||||
@ -1878,7 +1910,9 @@ function renderMixin(Vue) {
|
||||
if (staticRenderFns && !this._staticTrees) {
|
||||
this._staticTrees = [];
|
||||
}
|
||||
|
||||
// set parent vnode. this allows render functions to have access
|
||||
// to the data on the placeholder node.
|
||||
this.$vnode = _parentVnode;
|
||||
// resolve slots. becaues slots are rendered in parent scope,
|
||||
// we set the activeInstance to parent.
|
||||
if (_renderChildren) {
|
||||
@ -2455,10 +2489,10 @@ function resolveAsset(options, type, id, warnMissing) {
|
||||
return res;
|
||||
}
|
||||
|
||||
function validateProp(vm, key, propsData) {
|
||||
function validateProp(key, propOptions, propsData, vm) {
|
||||
/* istanbul ignore if */
|
||||
if (!vm.$options.props || !propsData) return;
|
||||
var prop = vm.$options.props[key];
|
||||
if (!propsData) return;
|
||||
var prop = propOptions[key];
|
||||
var absent = !hasOwn(propsData, key);
|
||||
var value = propsData[key];
|
||||
// handle boolean props
|
||||
@ -2712,6 +2746,9 @@ function initAssetRegisters(Vue) {
|
||||
definition.name = definition.name || id;
|
||||
definition = Vue.extend(definition);
|
||||
}
|
||||
if (type === 'directive' && typeof definition === 'function') {
|
||||
definition = { bind: definition, update: definition };
|
||||
}
|
||||
this.options[type + 's'][id] = definition;
|
||||
return definition;
|
||||
}
|
||||
@ -2750,17 +2787,6 @@ var KeepAlive = {
|
||||
}
|
||||
};
|
||||
|
||||
// in case the child is also an abstract component, e.g. <transition-control>
|
||||
// we want to recrusively retrieve the real component to be rendered
|
||||
function getRealChild(vnode) {
|
||||
var compOptions = vnode && vnode.componentOptions;
|
||||
if (compOptions && compOptions.Ctor.options._abstract) {
|
||||
return getRealChild(compOptions.propsData.child);
|
||||
} else {
|
||||
return vnode;
|
||||
}
|
||||
}
|
||||
|
||||
var builtInComponents = {
|
||||
KeepAlive: KeepAlive
|
||||
};
|
||||
@ -2803,7 +2829,7 @@ Object.defineProperty(Vue.prototype, '$isServer', {
|
||||
}
|
||||
});
|
||||
|
||||
Vue.version = '2.0.0-alpha.8';
|
||||
Vue.version = '2.0.0-beta.1';
|
||||
|
||||
// attributes that should be using props for binding
|
||||
var mustUseProp = makeMap('value,selected,checked,muted');
|
||||
@ -3039,7 +3065,7 @@ function isDef(s) {
|
||||
}
|
||||
|
||||
function sameVnode(vnode1, vnode2) {
|
||||
return vnode1.key === vnode2.key && vnode1.tag === vnode2.tag;
|
||||
return vnode1.key === vnode2.key && vnode1.tag === vnode2.tag && !vnode1.data === !vnode2.data;
|
||||
}
|
||||
|
||||
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
||||
@ -3099,6 +3125,7 @@ function createPatchFunction(backend) {
|
||||
// component also has set the placeholder vnode's elm.
|
||||
// in that case we can just return the element and be done.
|
||||
if (isDef(i = vnode.child)) {
|
||||
vnode.elm = vnode.child.$el;
|
||||
invokeCreateHooks(vnode, insertedVnodeQueue);
|
||||
setScope(vnode);
|
||||
return vnode.elm;
|
||||
@ -3107,6 +3134,11 @@ function createPatchFunction(backend) {
|
||||
var children = vnode.children;
|
||||
var tag = vnode.tag;
|
||||
if (isDef(tag)) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!vnode.ns && !(config.ignoredElements && config.ignoredElements.indexOf(tag) > -1) && config.isUnknownElement(tag)) {
|
||||
warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.', vnode.context);
|
||||
}
|
||||
}
|
||||
elm = vnode.elm = vnode.ns ? nodeOps.createElementNS(vnode.ns, tag) : nodeOps.createElement(tag);
|
||||
setScope(vnode);
|
||||
if (Array.isArray(children)) {
|
||||
@ -3296,12 +3328,8 @@ function createPatchFunction(backend) {
|
||||
var i = void 0,
|
||||
hook = void 0;
|
||||
var hasData = isDef(i = vnode.data);
|
||||
if (hasData) {
|
||||
// ensure the oldVnode also has data during patch
|
||||
oldVnode.data = oldVnode.data || emptyData;
|
||||
if (isDef(hook = i.hook) && isDef(i = hook.prepatch)) {
|
||||
i(oldVnode, vnode);
|
||||
}
|
||||
if (hasData && isDef(hook = i.hook) && isDef(i = hook.prepatch)) {
|
||||
i(oldVnode, vnode);
|
||||
}
|
||||
var elm = vnode.elm = oldVnode.elm;
|
||||
var oldCh = oldVnode.children;
|
||||
@ -3425,6 +3453,15 @@ function createPatchFunction(backend) {
|
||||
|
||||
createElm(vnode, insertedVnodeQueue);
|
||||
|
||||
// component root element replaced.
|
||||
// update parent placeholder node element.
|
||||
if (vnode.parent) {
|
||||
vnode.parent.elm = vnode.elm;
|
||||
for (var _i4 = 0; _i4 < cbs.create.length; ++_i4) {
|
||||
cbs.create[_i4](emptyNode, vnode.parent);
|
||||
}
|
||||
}
|
||||
|
||||
if (parent !== null) {
|
||||
nodeOps.insertBefore(parent, vnode.elm, nodeOps.nextSibling(elm));
|
||||
removeVnodes(parent, [oldVnode], 0, 0);
|
||||
@ -3447,13 +3484,15 @@ var directives = {
|
||||
applyDirectives(oldVnode, vnode, 'update');
|
||||
},
|
||||
postpatch: function postupdateDirectives(oldVnode, vnode) {
|
||||
applyDirectives(oldVnode, vnode, 'postupdate');
|
||||
applyDirectives(oldVnode, vnode, 'componentUpdated');
|
||||
},
|
||||
destroy: function unbindDirectives(vnode) {
|
||||
applyDirectives(vnode, vnode, 'unbind');
|
||||
}
|
||||
};
|
||||
|
||||
var emptyModifiers = Object.create(null);
|
||||
|
||||
function applyDirectives(oldVnode, vnode, hook) {
|
||||
var dirs = vnode.data.directives;
|
||||
if (dirs) {
|
||||
@ -3464,12 +3503,11 @@ function applyDirectives(oldVnode, vnode, hook) {
|
||||
var def = resolveAsset(vnode.context.$options, 'directives', dir.name, true);
|
||||
var fn = def && def[hook];
|
||||
if (fn) {
|
||||
// only call update if value has changed
|
||||
if (isUpdate && oldDirs) {
|
||||
var oldValue = dir.oldValue = oldDirs[i].value;
|
||||
if (oldValue === dir.value) {
|
||||
continue;
|
||||
}
|
||||
dir.oldValue = oldDirs[i].value;
|
||||
}
|
||||
if (!dir.modifiers) {
|
||||
dir.modifiers = emptyModifiers;
|
||||
}
|
||||
fn(vnode.elm, dir, vnode, oldVnode);
|
||||
}
|
||||
@ -3818,17 +3856,16 @@ function enter(vnode) {
|
||||
var _resolveTransition = resolveTransition(data, vnode.context);
|
||||
|
||||
var css = _resolveTransition.css;
|
||||
var appear = _resolveTransition.appear;
|
||||
var enterClass = _resolveTransition.enterClass;
|
||||
var enterActiveClass = _resolveTransition.enterActiveClass;
|
||||
var appearClass = _resolveTransition.appearClass;
|
||||
var appearActiveClass = _resolveTransition.appearActiveClass;
|
||||
var beforeEnter = _resolveTransition.beforeEnter;
|
||||
var onEnter = _resolveTransition.onEnter;
|
||||
var enter = _resolveTransition.enter;
|
||||
var afterEnter = _resolveTransition.afterEnter;
|
||||
var enterCancelled = _resolveTransition.enterCancelled;
|
||||
var beforeAppear = _resolveTransition.beforeAppear;
|
||||
var onAppear = _resolveTransition.onAppear;
|
||||
var appear = _resolveTransition.appear;
|
||||
var afterAppear = _resolveTransition.afterAppear;
|
||||
var appearCancelled = _resolveTransition.appearCancelled;
|
||||
|
||||
@ -3841,7 +3878,7 @@ function enter(vnode) {
|
||||
var startClass = isAppear ? appearClass : enterClass;
|
||||
var activeClass = isAppear ? appearActiveClass : enterActiveClass;
|
||||
var beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
|
||||
var enterHook = isAppear ? onAppear || onEnter : onEnter;
|
||||
var enterHook = isAppear ? typeof appear === 'function' ? appear : enter : enter;
|
||||
var afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
|
||||
var enterCancelledHook = isAppear ? appearCancelled || enterCancelled : enterCancelled;
|
||||
|
||||
@ -3898,14 +3935,14 @@ function leave(vnode, rm) {
|
||||
var leaveClass = _resolveTransition2.leaveClass;
|
||||
var leaveActiveClass = _resolveTransition2.leaveActiveClass;
|
||||
var beforeLeave = _resolveTransition2.beforeLeave;
|
||||
var onLeave = _resolveTransition2.onLeave;
|
||||
var leave = _resolveTransition2.leave;
|
||||
var afterLeave = _resolveTransition2.afterLeave;
|
||||
var leaveCancelled = _resolveTransition2.leaveCancelled;
|
||||
var delayLeave = _resolveTransition2.delayLeave;
|
||||
|
||||
|
||||
var expectsCSS = css !== false;
|
||||
var userWantsControl = onLeave && onLeave.length > 2;
|
||||
var userWantsControl = leave && leave.length > 2;
|
||||
var cb = el._leaveCb = once(function () {
|
||||
if (expectsCSS) {
|
||||
removeTransitionClass(el, leaveActiveClass);
|
||||
@ -3940,7 +3977,7 @@ function leave(vnode, rm) {
|
||||
}
|
||||
});
|
||||
}
|
||||
onLeave && onLeave(el, vm, cb);
|
||||
leave && leave(el, vm, cb);
|
||||
if (!expectsCSS && !userWantsControl) {
|
||||
cb();
|
||||
}
|
||||
@ -4134,7 +4171,7 @@ var model = {
|
||||
}
|
||||
}
|
||||
if (vnode.tag === 'select') {
|
||||
setSelected(el, binding.value);
|
||||
setSelected(el, binding, vnode.context);
|
||||
} else {
|
||||
if (!isAndroid) {
|
||||
el.addEventListener('compositionstart', onCompositionStart);
|
||||
@ -4146,17 +4183,16 @@ var model = {
|
||||
}
|
||||
}
|
||||
},
|
||||
postupdate: function postupdate(el, binding, vnode) {
|
||||
var val = binding.value;
|
||||
componentUpdated: function componentUpdated(el, binding, vnode) {
|
||||
if (vnode.tag === 'select') {
|
||||
setSelected(el, val);
|
||||
setSelected(el, binding, vnode.context);
|
||||
// in case the options rendered by v-for have changed,
|
||||
// it's possible that the value is out-of-sync with the rendered options.
|
||||
// detect such cases and filter out values that no longer has a matchig
|
||||
// option in the DOM.
|
||||
var needReset = el.multiple ? val.some(function (v) {
|
||||
var needReset = el.multiple ? binding.value.some(function (v) {
|
||||
return hasNoMatchingOption(v, el.options);
|
||||
}) : hasNoMatchingOption(val, el.options);
|
||||
}) : hasNoMatchingOption(binding.value, el.options);
|
||||
if (needReset) {
|
||||
trigger(el, 'change');
|
||||
}
|
||||
@ -4164,10 +4200,14 @@ var model = {
|
||||
}
|
||||
};
|
||||
|
||||
function setSelected(el, value) {
|
||||
function setSelected(el, binding, vm) {
|
||||
var value = binding.value;
|
||||
var isMultiple = el.multiple;
|
||||
if (!isMultiple) {
|
||||
el.selectedIndex = -1;
|
||||
} else if (!Array.isArray(value)) {
|
||||
process.env.NODE_ENV !== 'production' && warn('<select multiple v-model="' + binding.expression + '"> ' + ('expects an Array value for its binding, but got ' + Object.prototype.toString.call(value).slice(8, -1)), vm);
|
||||
return;
|
||||
}
|
||||
for (var i = 0, l = el.options.length; i < l; i++) {
|
||||
var option = el.options[i];
|
||||
@ -4269,7 +4309,7 @@ var TransitionControl = {
|
||||
var _this = this;
|
||||
|
||||
var oldChild = this._vnode;
|
||||
var newChild = this.child;
|
||||
var newChild = getRealChild(this.child);
|
||||
if (oldChild && oldChild.data && (oldChild.tag !== newChild.tag || oldChild.key !== newChild.key)) {
|
||||
if (this.mode === 'out-in') {
|
||||
// return empty node
|
||||
|
228
dist/vue.js
vendored
228
dist/vue.js
vendored
@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* Vue.js v2.0.0-alpha.8
|
||||
* Vue.js v2.0.0-beta.1
|
||||
* (c) 2014-2016 Evan You
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
@ -105,9 +105,9 @@
|
||||
/**
|
||||
* Hyphenate a camelCase string.
|
||||
*/
|
||||
var hyphenateRE = /([a-z\d])([A-Z])/g;
|
||||
var hyphenateRE = /([^-])([A-Z])/g;
|
||||
var hyphenate = cached(function (str) {
|
||||
return str.replace(hyphenateRE, '$1-$2').toLowerCase();
|
||||
return str.replace(hyphenateRE, '$1-$2').replace(hyphenateRE, '$1-$2').toLowerCase();
|
||||
});
|
||||
|
||||
/**
|
||||
@ -294,7 +294,7 @@
|
||||
/**
|
||||
* Parse simple path.
|
||||
*/
|
||||
var bailRE = /[^\w\.]/;
|
||||
var bailRE = /[^\w\.\$]/;
|
||||
function parsePath(path) {
|
||||
if (bailRE.test(path)) {
|
||||
return;
|
||||
@ -632,7 +632,7 @@
|
||||
this.getter = parsePath(expOrFn);
|
||||
if (!this.getter) {
|
||||
this.getter = function () {};
|
||||
"development" !== 'production' && warn('Failed watching path: ' + expOrFn + 'Watcher only accepts simple dot-delimited paths. ' + 'For full control, use a function instead.', vm);
|
||||
"development" !== 'production' && warn('Failed watching path: "' + expOrFn + '" ' + 'Watcher only accepts simple dot-delimited paths. ' + 'For full control, use a function instead.', vm);
|
||||
}
|
||||
}
|
||||
this.value = this.lazy ? undefined : this.get();
|
||||
@ -655,12 +655,12 @@
|
||||
} else {
|
||||
warn('Error during component render', this.vm);
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (config.errorHandler) {
|
||||
config.errorHandler.call(null, e, this.vm);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (config.errorHandler) {
|
||||
config.errorHandler.call(null, e, this.vm);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
// return old value when evaluation fails so the current UI is preserved
|
||||
// if the error was somehow handled by user
|
||||
@ -1118,7 +1118,7 @@
|
||||
var key = keys[i];
|
||||
/* istanbul ignore else */
|
||||
if ("development" !== 'production') {
|
||||
defineReactive(vm, key, validateProp(vm, key, propsData), function () {
|
||||
defineReactive(vm, key, validateProp(key, props, propsData, vm), function () {
|
||||
if (vm.$parent && !observerState.isSettingProps) {
|
||||
warn('Avoid mutating a prop directly since the value will be ' + 'overwritten whenever the parent component re-renders. ' + 'Instead, use a data or computed property based on the prop\'s ' + ('value. Prop being mutated: "' + key + '"'), vm);
|
||||
}
|
||||
@ -1333,7 +1333,9 @@
|
||||
last.text += c.text;
|
||||
} else {
|
||||
// inherit parent namespace
|
||||
if (ns && c.tag) c.ns = ns;
|
||||
if (ns) {
|
||||
applyNS(c, ns);
|
||||
}
|
||||
res.push(c);
|
||||
}
|
||||
}
|
||||
@ -1346,6 +1348,28 @@
|
||||
return new VNode(undefined, undefined, undefined, String(val));
|
||||
}
|
||||
|
||||
function applyNS(vnode, ns) {
|
||||
if (vnode.tag && !vnode.ns) {
|
||||
vnode.ns = ns;
|
||||
if (vnode.children) {
|
||||
for (var i = 0, l = vnode.children.length; i < l; i++) {
|
||||
applyNS(vnode.children[i], ns);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// in case the child is also an abstract component, e.g. <transition-control>
|
||||
// we want to recrusively retrieve the real component to be rendered
|
||||
function getRealChild(vnode) {
|
||||
var compOptions = vnode && vnode.componentOptions;
|
||||
if (compOptions && compOptions.Ctor.options._abstract) {
|
||||
return getRealChild(compOptions.propsData && compOptions.propsData.child);
|
||||
} else {
|
||||
return vnode;
|
||||
}
|
||||
}
|
||||
|
||||
function updateListeners(on, oldOn, add, remove) {
|
||||
var name = void 0,
|
||||
cur = void 0,
|
||||
@ -1470,15 +1494,9 @@
|
||||
if (vm.$el) {
|
||||
vm.$el.__vue__ = vm;
|
||||
}
|
||||
// update parent vnode element after patch
|
||||
var parentNode = vm.$options._parentVnode;
|
||||
if (parentNode) {
|
||||
parentNode.elm = vm.$el;
|
||||
// update parent $el if the parent is HOC
|
||||
// this is necessary because child is updated after parent
|
||||
if (vm.$parent && parentNode === vm.$parent._vnode) {
|
||||
vm.$parent.$el = vm.$el;
|
||||
}
|
||||
// if parent is an HOC, update its $el as well
|
||||
if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
|
||||
vm.$parent.$el = vm.$el;
|
||||
}
|
||||
if (vm._isMounted) {
|
||||
callHook(vm, 'updated');
|
||||
@ -1498,7 +1516,7 @@
|
||||
var propKeys = vm.$options._propKeys || [];
|
||||
for (var i = 0; i < propKeys.length; i++) {
|
||||
var key = propKeys[i];
|
||||
vm[key] = validateProp(vm, key, propsData);
|
||||
vm[key] = validateProp(key, vm.$options.props, propsData, vm);
|
||||
}
|
||||
observerState.shouldConvert = true;
|
||||
if ("development" !== 'production') {
|
||||
@ -1576,9 +1594,9 @@
|
||||
var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy };
|
||||
var hooksToMerge = Object.keys(hooks);
|
||||
|
||||
function createComponent(Ctor, data, parent, context, host, children, tag) {
|
||||
function createComponent(Ctor, data, parent, context, host, _children, tag) {
|
||||
// ensure children is a thunk
|
||||
if ("development" !== 'production' && children && typeof children !== 'function') {
|
||||
if ("development" !== 'production' && _children && typeof _children !== 'function') {
|
||||
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.');
|
||||
}
|
||||
|
||||
@ -1623,10 +1641,22 @@
|
||||
|
||||
// functional component
|
||||
if (Ctor.options.functional) {
|
||||
return Ctor.options.render.call(null, parent.$createElement, // h
|
||||
propsData || {}, // props
|
||||
normalizeChildren(children) // children
|
||||
);
|
||||
var _ret = function () {
|
||||
var props = {};
|
||||
var propOptions = Ctor.options.props;
|
||||
if (propOptions) {
|
||||
Object.keys(propOptions).forEach(function (key) {
|
||||
props[key] = validateProp(key, propOptions, propsData);
|
||||
});
|
||||
}
|
||||
return {
|
||||
v: Ctor.options.render.call(null, parent.$createElement, { props: props, parent: parent, data: data, children: function children() {
|
||||
return normalizeChildren(_children);
|
||||
} })
|
||||
};
|
||||
}();
|
||||
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
}
|
||||
|
||||
// merge component management hooks onto the placeholder node
|
||||
@ -1641,7 +1671,7 @@
|
||||
|
||||
// return a placeholder vnode
|
||||
var name = Ctor.options.name || tag;
|
||||
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 });
|
||||
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 });
|
||||
return vnode;
|
||||
}
|
||||
|
||||
@ -1710,7 +1740,7 @@
|
||||
// pool callbacks
|
||||
factory.pendingCallbacks.push(cb);
|
||||
} else {
|
||||
var _ret = function () {
|
||||
var _ret2 = function () {
|
||||
factory.requested = true;
|
||||
var cbs = factory.pendingCallbacks = [cb];
|
||||
var sync = true;
|
||||
@ -1741,7 +1771,7 @@
|
||||
};
|
||||
}();
|
||||
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
if (typeof _ret2 === "object") return _ret2.v;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1828,21 +1858,22 @@
|
||||
return emptyVNode();
|
||||
}
|
||||
if (typeof tag === 'string') {
|
||||
var namespace = config.getTagNamespace(tag);
|
||||
var Ctor = void 0;
|
||||
if (config.isReservedTag(tag)) {
|
||||
return new VNode(tag, data, normalizeChildren(children, namespace), undefined, undefined, namespace, context, host);
|
||||
// platform built-in elements
|
||||
return new VNode(tag, data, normalizeChildren(children), undefined, undefined, undefined, context, host);
|
||||
} else if (Ctor = resolveAsset(context.$options, 'components', tag)) {
|
||||
// component
|
||||
return createComponent(Ctor, data, parent, context, host, children, tag);
|
||||
} else {
|
||||
if ("development" !== 'production') {
|
||||
if (!namespace && !(config.ignoredElements && config.ignoredElements.indexOf(tag) > -1) && config.isUnknownElement(tag)) {
|
||||
warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.');
|
||||
}
|
||||
}
|
||||
return new VNode(tag, data, normalizeChildren(children, namespace), undefined, undefined, namespace, context, host);
|
||||
// unknown or namespaced elements
|
||||
// check at runtime because it may get assigned a namespace when its
|
||||
// parent normalizes children
|
||||
var ns = config.getTagNamespace(tag);
|
||||
return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context, host);
|
||||
}
|
||||
} else {
|
||||
// direct component options / constructor
|
||||
return createComponent(tag, data, parent, context, host, children);
|
||||
}
|
||||
}
|
||||
@ -1852,7 +1883,8 @@
|
||||
};
|
||||
|
||||
function initRender(vm) {
|
||||
vm._vnode = null;
|
||||
vm.$vnode = null; // the placeholder node in parent tree
|
||||
vm._vnode = null; // the root of the child tree
|
||||
vm._staticTrees = null;
|
||||
vm.$slots = {};
|
||||
// bind the public createElement fn to this instance
|
||||
@ -1885,7 +1917,9 @@
|
||||
if (staticRenderFns && !this._staticTrees) {
|
||||
this._staticTrees = [];
|
||||
}
|
||||
|
||||
// set parent vnode. this allows render functions to have access
|
||||
// to the data on the placeholder node.
|
||||
this.$vnode = _parentVnode;
|
||||
// resolve slots. becaues slots are rendered in parent scope,
|
||||
// we set the activeInstance to parent.
|
||||
if (_renderChildren) {
|
||||
@ -2460,10 +2494,10 @@
|
||||
return res;
|
||||
}
|
||||
|
||||
function validateProp(vm, key, propsData) {
|
||||
function validateProp(key, propOptions, propsData, vm) {
|
||||
/* istanbul ignore if */
|
||||
if (!vm.$options.props || !propsData) return;
|
||||
var prop = vm.$options.props[key];
|
||||
if (!propsData) return;
|
||||
var prop = propOptions[key];
|
||||
var absent = !hasOwn(propsData, key);
|
||||
var value = propsData[key];
|
||||
// handle boolean props
|
||||
@ -2717,6 +2751,9 @@
|
||||
definition.name = definition.name || id;
|
||||
definition = Vue.extend(definition);
|
||||
}
|
||||
if (type === 'directive' && typeof definition === 'function') {
|
||||
definition = { bind: definition, update: definition };
|
||||
}
|
||||
this.options[type + 's'][id] = definition;
|
||||
return definition;
|
||||
}
|
||||
@ -2755,17 +2792,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
// in case the child is also an abstract component, e.g. <transition-control>
|
||||
// we want to recrusively retrieve the real component to be rendered
|
||||
function getRealChild(vnode) {
|
||||
var compOptions = vnode && vnode.componentOptions;
|
||||
if (compOptions && compOptions.Ctor.options._abstract) {
|
||||
return getRealChild(compOptions.propsData.child);
|
||||
} else {
|
||||
return vnode;
|
||||
}
|
||||
}
|
||||
|
||||
var builtInComponents = {
|
||||
KeepAlive: KeepAlive
|
||||
};
|
||||
@ -2808,7 +2834,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
Vue.version = '2.0.0-alpha.8';
|
||||
Vue.version = '2.0.0-beta.1';
|
||||
|
||||
// attributes that should be using props for binding
|
||||
var mustUseProp = makeMap('value,selected,checked,muted');
|
||||
@ -3044,7 +3070,7 @@ var nodeOps = Object.freeze({
|
||||
}
|
||||
|
||||
function sameVnode(vnode1, vnode2) {
|
||||
return vnode1.key === vnode2.key && vnode1.tag === vnode2.tag;
|
||||
return vnode1.key === vnode2.key && vnode1.tag === vnode2.tag && !vnode1.data === !vnode2.data;
|
||||
}
|
||||
|
||||
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
||||
@ -3104,6 +3130,7 @@ var nodeOps = Object.freeze({
|
||||
// component also has set the placeholder vnode's elm.
|
||||
// in that case we can just return the element and be done.
|
||||
if (isDef(i = vnode.child)) {
|
||||
vnode.elm = vnode.child.$el;
|
||||
invokeCreateHooks(vnode, insertedVnodeQueue);
|
||||
setScope(vnode);
|
||||
return vnode.elm;
|
||||
@ -3112,6 +3139,11 @@ var nodeOps = Object.freeze({
|
||||
var children = vnode.children;
|
||||
var tag = vnode.tag;
|
||||
if (isDef(tag)) {
|
||||
if ("development" !== 'production') {
|
||||
if (!vnode.ns && !(config.ignoredElements && config.ignoredElements.indexOf(tag) > -1) && config.isUnknownElement(tag)) {
|
||||
warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.', vnode.context);
|
||||
}
|
||||
}
|
||||
elm = vnode.elm = vnode.ns ? nodeOps.createElementNS(vnode.ns, tag) : nodeOps.createElement(tag);
|
||||
setScope(vnode);
|
||||
if (Array.isArray(children)) {
|
||||
@ -3301,12 +3333,8 @@ var nodeOps = Object.freeze({
|
||||
var i = void 0,
|
||||
hook = void 0;
|
||||
var hasData = isDef(i = vnode.data);
|
||||
if (hasData) {
|
||||
// ensure the oldVnode also has data during patch
|
||||
oldVnode.data = oldVnode.data || emptyData;
|
||||
if (isDef(hook = i.hook) && isDef(i = hook.prepatch)) {
|
||||
i(oldVnode, vnode);
|
||||
}
|
||||
if (hasData && isDef(hook = i.hook) && isDef(i = hook.prepatch)) {
|
||||
i(oldVnode, vnode);
|
||||
}
|
||||
var elm = vnode.elm = oldVnode.elm;
|
||||
var oldCh = oldVnode.children;
|
||||
@ -3430,6 +3458,15 @@ var nodeOps = Object.freeze({
|
||||
|
||||
createElm(vnode, insertedVnodeQueue);
|
||||
|
||||
// component root element replaced.
|
||||
// update parent placeholder node element.
|
||||
if (vnode.parent) {
|
||||
vnode.parent.elm = vnode.elm;
|
||||
for (var _i4 = 0; _i4 < cbs.create.length; ++_i4) {
|
||||
cbs.create[_i4](emptyNode, vnode.parent);
|
||||
}
|
||||
}
|
||||
|
||||
if (parent !== null) {
|
||||
nodeOps.insertBefore(parent, vnode.elm, nodeOps.nextSibling(elm));
|
||||
removeVnodes(parent, [oldVnode], 0, 0);
|
||||
@ -3452,13 +3489,15 @@ var nodeOps = Object.freeze({
|
||||
applyDirectives(oldVnode, vnode, 'update');
|
||||
},
|
||||
postpatch: function postupdateDirectives(oldVnode, vnode) {
|
||||
applyDirectives(oldVnode, vnode, 'postupdate');
|
||||
applyDirectives(oldVnode, vnode, 'componentUpdated');
|
||||
},
|
||||
destroy: function unbindDirectives(vnode) {
|
||||
applyDirectives(vnode, vnode, 'unbind');
|
||||
}
|
||||
};
|
||||
|
||||
var emptyModifiers = Object.create(null);
|
||||
|
||||
function applyDirectives(oldVnode, vnode, hook) {
|
||||
var dirs = vnode.data.directives;
|
||||
if (dirs) {
|
||||
@ -3469,12 +3508,11 @@ var nodeOps = Object.freeze({
|
||||
var def = resolveAsset(vnode.context.$options, 'directives', dir.name, true);
|
||||
var fn = def && def[hook];
|
||||
if (fn) {
|
||||
// only call update if value has changed
|
||||
if (isUpdate && oldDirs) {
|
||||
var oldValue = dir.oldValue = oldDirs[i].value;
|
||||
if (oldValue === dir.value) {
|
||||
continue;
|
||||
}
|
||||
dir.oldValue = oldDirs[i].value;
|
||||
}
|
||||
if (!dir.modifiers) {
|
||||
dir.modifiers = emptyModifiers;
|
||||
}
|
||||
fn(vnode.elm, dir, vnode, oldVnode);
|
||||
}
|
||||
@ -3823,17 +3861,16 @@ var nodeOps = Object.freeze({
|
||||
var _resolveTransition = resolveTransition(data, vnode.context);
|
||||
|
||||
var css = _resolveTransition.css;
|
||||
var appear = _resolveTransition.appear;
|
||||
var enterClass = _resolveTransition.enterClass;
|
||||
var enterActiveClass = _resolveTransition.enterActiveClass;
|
||||
var appearClass = _resolveTransition.appearClass;
|
||||
var appearActiveClass = _resolveTransition.appearActiveClass;
|
||||
var beforeEnter = _resolveTransition.beforeEnter;
|
||||
var onEnter = _resolveTransition.onEnter;
|
||||
var enter = _resolveTransition.enter;
|
||||
var afterEnter = _resolveTransition.afterEnter;
|
||||
var enterCancelled = _resolveTransition.enterCancelled;
|
||||
var beforeAppear = _resolveTransition.beforeAppear;
|
||||
var onAppear = _resolveTransition.onAppear;
|
||||
var appear = _resolveTransition.appear;
|
||||
var afterAppear = _resolveTransition.afterAppear;
|
||||
var appearCancelled = _resolveTransition.appearCancelled;
|
||||
|
||||
@ -3846,7 +3883,7 @@ var nodeOps = Object.freeze({
|
||||
var startClass = isAppear ? appearClass : enterClass;
|
||||
var activeClass = isAppear ? appearActiveClass : enterActiveClass;
|
||||
var beforeEnterHook = isAppear ? beforeAppear || beforeEnter : beforeEnter;
|
||||
var enterHook = isAppear ? onAppear || onEnter : onEnter;
|
||||
var enterHook = isAppear ? typeof appear === 'function' ? appear : enter : enter;
|
||||
var afterEnterHook = isAppear ? afterAppear || afterEnter : afterEnter;
|
||||
var enterCancelledHook = isAppear ? appearCancelled || enterCancelled : enterCancelled;
|
||||
|
||||
@ -3903,14 +3940,14 @@ var nodeOps = Object.freeze({
|
||||
var leaveClass = _resolveTransition2.leaveClass;
|
||||
var leaveActiveClass = _resolveTransition2.leaveActiveClass;
|
||||
var beforeLeave = _resolveTransition2.beforeLeave;
|
||||
var onLeave = _resolveTransition2.onLeave;
|
||||
var leave = _resolveTransition2.leave;
|
||||
var afterLeave = _resolveTransition2.afterLeave;
|
||||
var leaveCancelled = _resolveTransition2.leaveCancelled;
|
||||
var delayLeave = _resolveTransition2.delayLeave;
|
||||
|
||||
|
||||
var expectsCSS = css !== false;
|
||||
var userWantsControl = onLeave && onLeave.length > 2;
|
||||
var userWantsControl = leave && leave.length > 2;
|
||||
var cb = el._leaveCb = once(function () {
|
||||
if (expectsCSS) {
|
||||
removeTransitionClass(el, leaveActiveClass);
|
||||
@ -3945,7 +3982,7 @@ var nodeOps = Object.freeze({
|
||||
}
|
||||
});
|
||||
}
|
||||
onLeave && onLeave(el, vm, cb);
|
||||
leave && leave(el, vm, cb);
|
||||
if (!expectsCSS && !userWantsControl) {
|
||||
cb();
|
||||
}
|
||||
@ -4139,7 +4176,7 @@ var nodeOps = Object.freeze({
|
||||
}
|
||||
}
|
||||
if (vnode.tag === 'select') {
|
||||
setSelected(el, binding.value);
|
||||
setSelected(el, binding, vnode.context);
|
||||
} else {
|
||||
if (!isAndroid) {
|
||||
el.addEventListener('compositionstart', onCompositionStart);
|
||||
@ -4151,17 +4188,16 @@ var nodeOps = Object.freeze({
|
||||
}
|
||||
}
|
||||
},
|
||||
postupdate: function postupdate(el, binding, vnode) {
|
||||
var val = binding.value;
|
||||
componentUpdated: function componentUpdated(el, binding, vnode) {
|
||||
if (vnode.tag === 'select') {
|
||||
setSelected(el, val);
|
||||
setSelected(el, binding, vnode.context);
|
||||
// in case the options rendered by v-for have changed,
|
||||
// it's possible that the value is out-of-sync with the rendered options.
|
||||
// detect such cases and filter out values that no longer has a matchig
|
||||
// option in the DOM.
|
||||
var needReset = el.multiple ? val.some(function (v) {
|
||||
var needReset = el.multiple ? binding.value.some(function (v) {
|
||||
return hasNoMatchingOption(v, el.options);
|
||||
}) : hasNoMatchingOption(val, el.options);
|
||||
}) : hasNoMatchingOption(binding.value, el.options);
|
||||
if (needReset) {
|
||||
trigger(el, 'change');
|
||||
}
|
||||
@ -4169,10 +4205,14 @@ var nodeOps = Object.freeze({
|
||||
}
|
||||
};
|
||||
|
||||
function setSelected(el, value) {
|
||||
function setSelected(el, binding, vm) {
|
||||
var value = binding.value;
|
||||
var isMultiple = el.multiple;
|
||||
if (!isMultiple) {
|
||||
el.selectedIndex = -1;
|
||||
} else if (!Array.isArray(value)) {
|
||||
"development" !== 'production' && warn('<select multiple v-model="' + binding.expression + '"> ' + ('expects an Array value for its binding, but got ' + Object.prototype.toString.call(value).slice(8, -1)), vm);
|
||||
return;
|
||||
}
|
||||
for (var i = 0, l = el.options.length; i < l; i++) {
|
||||
var option = el.options[i];
|
||||
@ -4274,7 +4314,7 @@ var nodeOps = Object.freeze({
|
||||
var _this = this;
|
||||
|
||||
var oldChild = this._vnode;
|
||||
var newChild = this.child;
|
||||
var newChild = getRealChild(this.child);
|
||||
if (oldChild && oldChild.data && (oldChild.tag !== newChild.tag || oldChild.key !== newChild.key)) {
|
||||
if (this.mode === 'out-in') {
|
||||
// return empty node
|
||||
@ -4838,7 +4878,6 @@ var nodeOps = Object.freeze({
|
||||
var onRE = /^@|^v-on:/;
|
||||
var argRE = /:(.*)$/;
|
||||
var modifierRE = /\.[^\.]+/g;
|
||||
var camelRE = /[a-z\d][A-Z]/;
|
||||
|
||||
var decodeHTMLCached = cached(decodeHTML);
|
||||
|
||||
@ -4872,14 +4911,6 @@ var nodeOps = Object.freeze({
|
||||
expectHTML: options.expectHTML,
|
||||
isUnaryTag: options.isUnaryTag,
|
||||
start: function start(tag, attrs, unary) {
|
||||
// check camelCase tag
|
||||
if (camelRE.test(tag)) {
|
||||
"development" !== 'production' && warn$1('Found camelCase tag in template: <' + tag + '>. ' + ('I\'ve converted it to <' + hyphenate(tag) + '> for you.'));
|
||||
tag = hyphenate(tag);
|
||||
}
|
||||
|
||||
tag = tag.toLowerCase();
|
||||
|
||||
// check namespace.
|
||||
// inherit parent ns if there is one
|
||||
var ns = currentParent && currentParent.ns || platformGetTagNamespace(tag);
|
||||
@ -5443,7 +5474,7 @@ var nodeOps = Object.freeze({
|
||||
code = transforms$1[i](el, code);
|
||||
}
|
||||
// check keep-alive
|
||||
if (el.component && el.keepAlive) {
|
||||
if (el.keepAlive) {
|
||||
code = '_h("KeepAlive",{props:{child:' + code + '}})';
|
||||
}
|
||||
return code;
|
||||
@ -5843,13 +5874,14 @@ var nodeOps = Object.freeze({
|
||||
|
||||
var event = lazy ? 'change' : 'input';
|
||||
var needCompositionGuard = !lazy && type !== 'range';
|
||||
var isNative = el.tag === 'input' || el.tag === 'textarea';
|
||||
|
||||
var valueExpression = '$event.target.value' + (trim ? '.trim()' : '');
|
||||
var valueExpression = isNative ? '$event.target.value' + (trim ? '.trim()' : '') : '$event';
|
||||
var code = number || type === 'number' ? value + '=_n(' + valueExpression + ')' : value + '=' + valueExpression;
|
||||
if (needCompositionGuard) {
|
||||
if (isNative && needCompositionGuard) {
|
||||
code = 'if($event.target.composing)return;' + code;
|
||||
}
|
||||
addProp(el, 'value', '_s(' + value + ')');
|
||||
addProp(el, 'value', isNative ? '_s(' + value + ')' : '(' + value + ')');
|
||||
addHandler(el, event, code);
|
||||
if (needCompositionGuard) {
|
||||
// need runtime directive code to help with composition events
|
||||
|
6
dist/vue.min.js
vendored
6
dist/vue.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-server-renderer",
|
||||
"version": "2.0.0-alpha.8",
|
||||
"version": "2.0.0-beta.1",
|
||||
"description": "server renderer for Vue 2.0",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
|
@ -103,9 +103,9 @@ var capitalize = cached(function (str) {
|
||||
/**
|
||||
* Hyphenate a camelCase string.
|
||||
*/
|
||||
var hyphenateRE = /([a-z\d])([A-Z])/g;
|
||||
var hyphenateRE = /([^-])([A-Z])/g;
|
||||
var hyphenate = cached(function (str) {
|
||||
return str.replace(hyphenateRE, '$1-$2').toLowerCase();
|
||||
return str.replace(hyphenateRE, '$1-$2').replace(hyphenateRE, '$1-$2').toLowerCase();
|
||||
});
|
||||
|
||||
/**
|
||||
@ -315,7 +315,7 @@ function def(obj, key, val, enumerable) {
|
||||
/**
|
||||
* Parse simple path.
|
||||
*/
|
||||
var bailRE = /[^\w\.]/;
|
||||
var bailRE = /[^\w\.\$]/;
|
||||
function parsePath(path) {
|
||||
if (bailRE.test(path)) {
|
||||
return;
|
||||
@ -653,7 +653,7 @@ var Watcher = function () {
|
||||
this.getter = parsePath(expOrFn);
|
||||
if (!this.getter) {
|
||||
this.getter = function () {};
|
||||
process.env.NODE_ENV !== 'production' && warn('Failed watching path: ' + expOrFn + 'Watcher only accepts simple dot-delimited paths. ' + 'For full control, use a function instead.', vm);
|
||||
process.env.NODE_ENV !== 'production' && warn('Failed watching path: "' + expOrFn + '" ' + 'Watcher only accepts simple dot-delimited paths. ' + 'For full control, use a function instead.', vm);
|
||||
}
|
||||
}
|
||||
this.value = this.lazy ? undefined : this.get();
|
||||
@ -676,12 +676,12 @@ var Watcher = function () {
|
||||
} else {
|
||||
warn('Error during component render', this.vm);
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (config.errorHandler) {
|
||||
config.errorHandler.call(null, e, this.vm);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
/* istanbul ignore else */
|
||||
if (config.errorHandler) {
|
||||
config.errorHandler.call(null, e, this.vm);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
// return old value when evaluation fails so the current UI is preserved
|
||||
// if the error was somehow handled by user
|
||||
@ -1120,13 +1120,13 @@ function initProps(vm) {
|
||||
var key = keys[i];
|
||||
/* istanbul ignore else */
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
defineReactive(vm, key, validateProp(vm, key, propsData), function () {
|
||||
defineReactive(vm, key, validateProp(key, props, propsData, vm), function () {
|
||||
if (vm.$parent && !observerState.isSettingProps) {
|
||||
warn('Avoid mutating a prop directly since the value will be ' + 'overwritten whenever the parent component re-renders. ' + 'Instead, use a data or computed property based on the prop\'s ' + ('value. Prop being mutated: "' + key + '"'), vm);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
defineReactive(vm, key, validateProp(vm, key, propsData));
|
||||
defineReactive(vm, key, validateProp(key, props, propsData, vm));
|
||||
}
|
||||
};
|
||||
|
||||
@ -1337,7 +1337,9 @@ function normalizeChildren(children, ns) {
|
||||
last.text += c.text;
|
||||
} else {
|
||||
// inherit parent namespace
|
||||
if (ns && c.tag) c.ns = ns;
|
||||
if (ns) {
|
||||
applyNS(c, ns);
|
||||
}
|
||||
res.push(c);
|
||||
}
|
||||
}
|
||||
@ -1350,6 +1352,17 @@ function createTextVNode(val) {
|
||||
return new VNode(undefined, undefined, undefined, String(val));
|
||||
}
|
||||
|
||||
function applyNS(vnode, ns) {
|
||||
if (vnode.tag && !vnode.ns) {
|
||||
vnode.ns = ns;
|
||||
if (vnode.children) {
|
||||
for (var i = 0, l = vnode.children.length; i < l; i++) {
|
||||
applyNS(vnode.children[i], ns);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateListeners(on, oldOn, add, remove) {
|
||||
var name = void 0,
|
||||
cur = void 0,
|
||||
@ -1474,15 +1487,9 @@ function lifecycleMixin(Vue) {
|
||||
if (vm.$el) {
|
||||
vm.$el.__vue__ = vm;
|
||||
}
|
||||
// update parent vnode element after patch
|
||||
var parentNode = vm.$options._parentVnode;
|
||||
if (parentNode) {
|
||||
parentNode.elm = vm.$el;
|
||||
// update parent $el if the parent is HOC
|
||||
// this is necessary because child is updated after parent
|
||||
if (vm.$parent && parentNode === vm.$parent._vnode) {
|
||||
vm.$parent.$el = vm.$el;
|
||||
}
|
||||
// if parent is an HOC, update its $el as well
|
||||
if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
|
||||
vm.$parent.$el = vm.$el;
|
||||
}
|
||||
if (vm._isMounted) {
|
||||
callHook(vm, 'updated');
|
||||
@ -1502,7 +1509,7 @@ function lifecycleMixin(Vue) {
|
||||
var propKeys = vm.$options._propKeys || [];
|
||||
for (var i = 0; i < propKeys.length; i++) {
|
||||
var key = propKeys[i];
|
||||
vm[key] = validateProp(vm, key, propsData);
|
||||
vm[key] = validateProp(key, vm.$options.props, propsData, vm);
|
||||
}
|
||||
observerState.shouldConvert = true;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
@ -1580,9 +1587,9 @@ function callHook(vm, hook) {
|
||||
var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy };
|
||||
var hooksToMerge = Object.keys(hooks);
|
||||
|
||||
function createComponent(Ctor, data, parent, context, host, children, tag) {
|
||||
function createComponent(Ctor, data, parent, context, host, _children, tag) {
|
||||
// ensure children is a thunk
|
||||
if (process.env.NODE_ENV !== 'production' && children && typeof children !== 'function') {
|
||||
if (process.env.NODE_ENV !== 'production' && _children && typeof _children !== 'function') {
|
||||
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.');
|
||||
}
|
||||
|
||||
@ -1627,10 +1634,22 @@ function createComponent(Ctor, data, parent, context, host, children, tag) {
|
||||
|
||||
// functional component
|
||||
if (Ctor.options.functional) {
|
||||
return Ctor.options.render.call(null, parent.$createElement, // h
|
||||
propsData || {}, // props
|
||||
normalizeChildren(children) // children
|
||||
);
|
||||
var _ret = function () {
|
||||
var props = {};
|
||||
var propOptions = Ctor.options.props;
|
||||
if (propOptions) {
|
||||
Object.keys(propOptions).forEach(function (key) {
|
||||
props[key] = validateProp(key, propOptions, propsData);
|
||||
});
|
||||
}
|
||||
return {
|
||||
v: Ctor.options.render.call(null, parent.$createElement, { props: props, parent: parent, data: data, children: function children() {
|
||||
return normalizeChildren(_children);
|
||||
} })
|
||||
};
|
||||
}();
|
||||
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
}
|
||||
|
||||
// merge component management hooks onto the placeholder node
|
||||
@ -1645,7 +1664,7 @@ function createComponent(Ctor, data, parent, context, host, children, tag) {
|
||||
|
||||
// return a placeholder vnode
|
||||
var name = Ctor.options.name || tag;
|
||||
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 });
|
||||
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 });
|
||||
return vnode;
|
||||
}
|
||||
|
||||
@ -1714,7 +1733,7 @@ function resolveAsyncComponent(factory, cb) {
|
||||
// pool callbacks
|
||||
factory.pendingCallbacks.push(cb);
|
||||
} else {
|
||||
var _ret = function () {
|
||||
var _ret2 = function () {
|
||||
factory.requested = true;
|
||||
var cbs = factory.pendingCallbacks = [cb];
|
||||
var sync = true;
|
||||
@ -1745,7 +1764,7 @@ function resolveAsyncComponent(factory, cb) {
|
||||
};
|
||||
}();
|
||||
|
||||
if (typeof _ret === "object") return _ret.v;
|
||||
if (typeof _ret2 === "object") return _ret2.v;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1832,21 +1851,22 @@ function _createElement(tag, data, children) {
|
||||
return emptyVNode();
|
||||
}
|
||||
if (typeof tag === 'string') {
|
||||
var namespace = config.getTagNamespace(tag);
|
||||
var Ctor = void 0;
|
||||
if (config.isReservedTag(tag)) {
|
||||
return new VNode(tag, data, normalizeChildren(children, namespace), undefined, undefined, namespace, context, host);
|
||||
// platform built-in elements
|
||||
return new VNode(tag, data, normalizeChildren(children), undefined, undefined, undefined, context, host);
|
||||
} else if (Ctor = resolveAsset(context.$options, 'components', tag)) {
|
||||
// component
|
||||
return createComponent(Ctor, data, parent, context, host, children, tag);
|
||||
} else {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
if (!namespace && !(config.ignoredElements && config.ignoredElements.indexOf(tag) > -1) && config.isUnknownElement(tag)) {
|
||||
warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.');
|
||||
}
|
||||
}
|
||||
return new VNode(tag, data, normalizeChildren(children, namespace), undefined, undefined, namespace, context, host);
|
||||
// unknown or namespaced elements
|
||||
// check at runtime because it may get assigned a namespace when its
|
||||
// parent normalizes children
|
||||
var ns = config.getTagNamespace(tag);
|
||||
return new VNode(tag, data, normalizeChildren(children, ns), undefined, undefined, ns, context, host);
|
||||
}
|
||||
} else {
|
||||
// direct component options / constructor
|
||||
return createComponent(tag, data, parent, context, host, children);
|
||||
}
|
||||
}
|
||||
@ -1856,7 +1876,8 @@ var renderState = {
|
||||
};
|
||||
|
||||
function initRender(vm) {
|
||||
vm._vnode = null;
|
||||
vm.$vnode = null; // the placeholder node in parent tree
|
||||
vm._vnode = null; // the root of the child tree
|
||||
vm._staticTrees = null;
|
||||
vm.$slots = {};
|
||||
// bind the public createElement fn to this instance
|
||||
@ -1889,7 +1910,9 @@ function renderMixin(Vue) {
|
||||
if (staticRenderFns && !this._staticTrees) {
|
||||
this._staticTrees = [];
|
||||
}
|
||||
|
||||
// set parent vnode. this allows render functions to have access
|
||||
// to the data on the placeholder node.
|
||||
this.$vnode = _parentVnode;
|
||||
// resolve slots. becaues slots are rendered in parent scope,
|
||||
// we set the activeInstance to parent.
|
||||
if (_renderChildren) {
|
||||
@ -2443,10 +2466,10 @@ function resolveAsset(options, type, id, warnMissing) {
|
||||
return res;
|
||||
}
|
||||
|
||||
function validateProp(vm, key, propsData) {
|
||||
function validateProp(key, propOptions, propsData, vm) {
|
||||
/* istanbul ignore if */
|
||||
if (!vm.$options.props || !propsData) return;
|
||||
var prop = vm.$options.props[key];
|
||||
if (!propsData) return;
|
||||
var prop = propOptions[key];
|
||||
var absent = !hasOwn(propsData, key);
|
||||
var value = propsData[key];
|
||||
// handle boolean props
|
||||
@ -3074,7 +3097,6 @@ var bindRE = /^:|^v-bind:/;
|
||||
var onRE = /^@|^v-on:/;
|
||||
var argRE = /:(.*)$/;
|
||||
var modifierRE = /\.[^\.]+/g;
|
||||
var camelRE = /[a-z\d][A-Z]/;
|
||||
|
||||
var decodeHTMLCached = cached(entities.decodeHTML);
|
||||
|
||||
@ -3108,14 +3130,6 @@ function parse(template, options) {
|
||||
expectHTML: options.expectHTML,
|
||||
isUnaryTag: options.isUnaryTag,
|
||||
start: function start(tag, attrs, unary) {
|
||||
// check camelCase tag
|
||||
if (camelRE.test(tag)) {
|
||||
process.env.NODE_ENV !== 'production' && warn$1('Found camelCase tag in template: <' + tag + '>. ' + ('I\'ve converted it to <' + hyphenate(tag) + '> for you.'));
|
||||
tag = hyphenate(tag);
|
||||
}
|
||||
|
||||
tag = tag.toLowerCase();
|
||||
|
||||
// check namespace.
|
||||
// inherit parent ns if there is one
|
||||
var ns = currentParent && currentParent.ns || platformGetTagNamespace(tag);
|
||||
@ -3679,7 +3693,7 @@ function genElement(el) {
|
||||
code = transforms$1[i](el, code);
|
||||
}
|
||||
// check keep-alive
|
||||
if (el.component && el.keepAlive) {
|
||||
if (el.keepAlive) {
|
||||
code = '_h("KeepAlive",{props:{child:' + code + '}})';
|
||||
}
|
||||
return code;
|
||||
@ -4079,13 +4093,14 @@ function genDefaultModel(el, value, modifiers) {
|
||||
|
||||
var event = lazy ? 'change' : 'input';
|
||||
var needCompositionGuard = !lazy && type !== 'range';
|
||||
var isNative = el.tag === 'input' || el.tag === 'textarea';
|
||||
|
||||
var valueExpression = '$event.target.value' + (trim ? '.trim()' : '');
|
||||
var valueExpression = isNative ? '$event.target.value' + (trim ? '.trim()' : '') : '$event';
|
||||
var code = number || type === 'number' ? value + '=_n(' + valueExpression + ')' : value + '=' + valueExpression;
|
||||
if (needCompositionGuard) {
|
||||
if (isNative && needCompositionGuard) {
|
||||
code = 'if($event.target.composing)return;' + code;
|
||||
}
|
||||
addProp(el, 'value', '_s(' + value + ')');
|
||||
addProp(el, 'value', isNative ? '_s(' + value + ')' : '(' + value + ')');
|
||||
addHandler(el, event, code);
|
||||
if (needCompositionGuard) {
|
||||
// need runtime directive code to help with composition events
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vue-template-compiler",
|
||||
"version": "2.0.0-alpha.8",
|
||||
"version": "2.0.0-beta.1",
|
||||
"description": "template compiler for Vue 2.0",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
|
@ -8,6 +8,6 @@ Object.defineProperty(Vue.prototype, '$isServer', {
|
||||
get: () => config._isServer
|
||||
})
|
||||
|
||||
Vue.version = '2.0.0-alpha.8'
|
||||
Vue.version = '2.0.0-beta.1'
|
||||
|
||||
export default Vue
|
||||
|
Loading…
Reference in New Issue
Block a user