Updating vuejs

parent cf6087db
...@@ -731,8 +731,8 @@ module.exports = Object.getPrototypeOf || function (O) { ...@@ -731,8 +731,8 @@ module.exports = Object.getPrototypeOf || function (O) {
"use strict"; "use strict";
/* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*! /* WEBPACK VAR INJECTION */(function(global, setImmediate) {/*!
* Vue.js v2.5.13 * Vue.js v2.5.16
* (c) 2014-2017 Evan You * (c) 2014-2018 Evan You
* Released under the MIT License. * Released under the MIT License.
*/ */
...@@ -913,9 +913,15 @@ var hyphenate = cached(function (str) { ...@@ -913,9 +913,15 @@ var hyphenate = cached(function (str) {
}); });
/** /**
* Simple bind, faster than native * Simple bind polyfill for environments that do not support it... e.g.
* PhantomJS 1.x. Technically we don't need this anymore since native bind is
* now more performant in most browsers, but removing it would be breaking for
* code that was able to run in PhantomJS 1.x, so this must be kept for
* backwards compatibility.
*/ */
function bind (fn, ctx) {
/* istanbul ignore next */
function polyfillBind (fn, ctx) {
function boundFn (a) { function boundFn (a) {
var l = arguments.length; var l = arguments.length;
return l return l
...@@ -924,11 +930,19 @@ function bind (fn, ctx) { ...@@ -924,11 +930,19 @@ function bind (fn, ctx) {
: fn.call(ctx, a) : fn.call(ctx, a)
: fn.call(ctx) : fn.call(ctx)
} }
// record original fn length
boundFn._length = fn.length; boundFn._length = fn.length;
return boundFn return boundFn
} }
function nativeBind (fn, ctx) {
return fn.bind(ctx)
}
var bind = Function.prototype.bind
? nativeBind
: polyfillBind;
/** /**
* Convert an Array-like object to a real Array. * Convert an Array-like object to a real Array.
*/ */
...@@ -1158,7 +1172,7 @@ var config = ({ ...@@ -1158,7 +1172,7 @@ var config = ({
* Exposed for legacy reasons * Exposed for legacy reasons
*/ */
_lifecycleHooks: LIFECYCLE_HOOKS _lifecycleHooks: LIFECYCLE_HOOKS
}); })
/* */ /* */
...@@ -1202,7 +1216,6 @@ function parsePath (path) { ...@@ -1202,7 +1216,6 @@ function parsePath (path) {
/* */ /* */
// can we use __proto__? // can we use __proto__?
var hasProto = '__proto__' in {}; var hasProto = '__proto__' in {};
...@@ -1241,7 +1254,7 @@ var _isServer; ...@@ -1241,7 +1254,7 @@ var _isServer;
var isServerRendering = function () { var isServerRendering = function () {
if (_isServer === undefined) { if (_isServer === undefined) {
/* istanbul ignore if */ /* istanbul ignore if */
if (!inBrowser && typeof global !== 'undefined') { if (!inBrowser && !inWeex && typeof global !== 'undefined') {
// detect presence of vue-server-renderer and avoid // detect presence of vue-server-renderer and avoid
// Webpack shimming the process // Webpack shimming the process
_isServer = global['process'].env.VUE_ENV === 'server'; _isServer = global['process'].env.VUE_ENV === 'server';
...@@ -1498,8 +1511,7 @@ function createTextVNode (val) { ...@@ -1498,8 +1511,7 @@ function createTextVNode (val) {
// used for static nodes and slot nodes because they may be reused across // used for static nodes and slot nodes because they may be reused across
// multiple renders, cloning them avoids errors when DOM manipulations rely // multiple renders, cloning them avoids errors when DOM manipulations rely
// on their elm reference. // on their elm reference.
function cloneVNode (vnode, deep) { function cloneVNode (vnode) {
var componentOptions = vnode.componentOptions;
var cloned = new VNode( var cloned = new VNode(
vnode.tag, vnode.tag,
vnode.data, vnode.data,
...@@ -1507,7 +1519,7 @@ function cloneVNode (vnode, deep) { ...@@ -1507,7 +1519,7 @@ function cloneVNode (vnode, deep) {
vnode.text, vnode.text,
vnode.elm, vnode.elm,
vnode.context, vnode.context,
componentOptions, vnode.componentOptions,
vnode.asyncFactory vnode.asyncFactory
); );
cloned.ns = vnode.ns; cloned.ns = vnode.ns;
...@@ -1518,33 +1530,18 @@ function cloneVNode (vnode, deep) { ...@@ -1518,33 +1530,18 @@ function cloneVNode (vnode, deep) {
cloned.fnOptions = vnode.fnOptions; cloned.fnOptions = vnode.fnOptions;
cloned.fnScopeId = vnode.fnScopeId; cloned.fnScopeId = vnode.fnScopeId;
cloned.isCloned = true; cloned.isCloned = true;
if (deep) {
if (vnode.children) {
cloned.children = cloneVNodes(vnode.children, true);
}
if (componentOptions && componentOptions.children) {
componentOptions.children = cloneVNodes(componentOptions.children, true);
}
}
return cloned return cloned
} }
function cloneVNodes (vnodes, deep) {
var len = vnodes.length;
var res = new Array(len);
for (var i = 0; i < len; i++) {
res[i] = cloneVNode(vnodes[i], deep);
}
return res
}
/* /*
* not type checking this file because flow doesn't play well with * not type checking this file because flow doesn't play well with
* dynamically accessing methods on Array prototype * dynamically accessing methods on Array prototype
*/ */
var arrayProto = Array.prototype; var arrayProto = Array.prototype;
var arrayMethods = Object.create(arrayProto);[ var arrayMethods = Object.create(arrayProto);
var methodsToPatch = [
'push', 'push',
'pop', 'pop',
'shift', 'shift',
...@@ -1552,7 +1549,12 @@ var arrayMethods = Object.create(arrayProto);[ ...@@ -1552,7 +1549,12 @@ var arrayMethods = Object.create(arrayProto);[
'splice', 'splice',
'sort', 'sort',
'reverse' 'reverse'
].forEach(function (method) { ];
/**
* Intercept mutating methods and emit events
*/
methodsToPatch.forEach(function (method) {
// cache original method // cache original method
var original = arrayProto[method]; var original = arrayProto[method];
def(arrayMethods, method, function mutator () { def(arrayMethods, method, function mutator () {
...@@ -1583,20 +1585,20 @@ var arrayMethods = Object.create(arrayProto);[ ...@@ -1583,20 +1585,20 @@ var arrayMethods = Object.create(arrayProto);[
var arrayKeys = Object.getOwnPropertyNames(arrayMethods); var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
/** /**
* By default, when a reactive property is set, the new value is * In some cases we may want to disable observation inside a component's
* also converted to become reactive. However when passing down props, * update computation.
* we don't want to force conversion because the value may be a nested value
* under a frozen data structure. Converting it would defeat the optimization.
*/ */
var observerState = { var shouldObserve = true;
shouldConvert: true
}; function toggleObserving (value) {
shouldObserve = value;
}
/** /**
* Observer class that are attached to each observed * Observer class that is attached to each observed
* object. Once attached, the observer converts target * object. Once attached, the observer converts the target
* object's property keys into getter/setters that * object's property keys into getter/setters that
* collect dependencies and dispatches updates. * collect dependencies and dispatch updates.
*/ */
var Observer = function Observer (value) { var Observer = function Observer (value) {
this.value = value; this.value = value;
...@@ -1622,7 +1624,7 @@ var Observer = function Observer (value) { ...@@ -1622,7 +1624,7 @@ var Observer = function Observer (value) {
Observer.prototype.walk = function walk (obj) { Observer.prototype.walk = function walk (obj) {
var keys = Object.keys(obj); var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
defineReactive(obj, keys[i], obj[keys[i]]); defineReactive(obj, keys[i]);
} }
}; };
...@@ -1672,7 +1674,7 @@ function observe (value, asRootData) { ...@@ -1672,7 +1674,7 @@ function observe (value, asRootData) {
if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
ob = value.__ob__; ob = value.__ob__;
} else if ( } else if (
observerState.shouldConvert && shouldObserve &&
!isServerRendering() && !isServerRendering() &&
(Array.isArray(value) || isPlainObject(value)) && (Array.isArray(value) || isPlainObject(value)) &&
Object.isExtensible(value) && Object.isExtensible(value) &&
...@@ -1705,6 +1707,9 @@ function defineReactive ( ...@@ -1705,6 +1707,9 @@ function defineReactive (
// cater for pre-defined getter/setters // cater for pre-defined getter/setters
var getter = property && property.get; var getter = property && property.get;
if (!getter && arguments.length === 2) {
val = obj[key];
}
var setter = property && property.set; var setter = property && property.set;
var childOb = !shallow && observe(val); var childOb = !shallow && observe(val);
...@@ -1751,6 +1756,11 @@ function defineReactive ( ...@@ -1751,6 +1756,11 @@ function defineReactive (
* already exist. * already exist.
*/ */
function set (target, key, val) { function set (target, key, val) {
if ("development" !== 'production' &&
(isUndef(target) || isPrimitive(target))
) {
warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
}
if (Array.isArray(target) && isValidArrayIndex(key)) { if (Array.isArray(target) && isValidArrayIndex(key)) {
target.length = Math.max(target.length, key); target.length = Math.max(target.length, key);
target.splice(key, 1, val); target.splice(key, 1, val);
...@@ -1781,6 +1791,11 @@ function set (target, key, val) { ...@@ -1781,6 +1791,11 @@ function set (target, key, val) {
* Delete a property and trigger change if necessary. * Delete a property and trigger change if necessary.
*/ */
function del (target, key) { function del (target, key) {
if ("development" !== 'production' &&
(isUndef(target) || isPrimitive(target))
) {
warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
}
if (Array.isArray(target) && isValidArrayIndex(key)) { if (Array.isArray(target) && isValidArrayIndex(key)) {
target.splice(key, 1); target.splice(key, 1);
return return
...@@ -2247,23 +2262,29 @@ function validateProp ( ...@@ -2247,23 +2262,29 @@ function validateProp (
var prop = propOptions[key]; var prop = propOptions[key];
var absent = !hasOwn(propsData, key); var absent = !hasOwn(propsData, key);
var value = propsData[key]; var value = propsData[key];
// handle boolean props // boolean casting
if (isType(Boolean, prop.type)) { var booleanIndex = getTypeIndex(Boolean, prop.type);
if (booleanIndex > -1) {
if (absent && !hasOwn(prop, 'default')) { if (absent && !hasOwn(prop, 'default')) {
value = false; value = false;
} else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) { } else if (value === '' || value === hyphenate(key)) {
// only cast empty string / same name to boolean if
// boolean has higher priority
var stringIndex = getTypeIndex(String, prop.type);
if (stringIndex < 0 || booleanIndex < stringIndex) {
value = true; value = true;
} }
} }
}
// check default value // check default value
if (value === undefined) { if (value === undefined) {
value = getPropDefaultValue(vm, prop, key); value = getPropDefaultValue(vm, prop, key);
// since the default value is a fresh copy, // since the default value is a fresh copy,
// make sure to observe it. // make sure to observe it.
var prevShouldConvert = observerState.shouldConvert; var prevShouldObserve = shouldObserve;
observerState.shouldConvert = true; toggleObserving(true);
observe(value); observe(value);
observerState.shouldConvert = prevShouldConvert; toggleObserving(prevShouldObserve);
} }
if ( if (
true true
...@@ -2394,17 +2415,20 @@ function getType (fn) { ...@@ -2394,17 +2415,20 @@ function getType (fn) {
return match ? match[1] : '' return match ? match[1] : ''
} }
function isType (type, fn) { function isSameType (a, b) {
if (!Array.isArray(fn)) { return getType(a) === getType(b)
return getType(fn) === getType(type) }
function getTypeIndex (type, expectedTypes) {
if (!Array.isArray(expectedTypes)) {
return isSameType(expectedTypes, type) ? 0 : -1
} }
for (var i = 0, len = fn.length; i < len; i++) { for (var i = 0, len = expectedTypes.length; i < len; i++) {
if (getType(fn[i]) === getType(type)) { if (isSameType(expectedTypes[i], type)) {
return true return i
} }
} }
/* istanbul ignore next */ return -1
return false
} }
/* */ /* */
...@@ -2467,19 +2491,19 @@ function flushCallbacks () { ...@@ -2467,19 +2491,19 @@ function flushCallbacks () {
} }
} }
// Here we have async deferring wrappers using both micro and macro tasks. // Here we have async deferring wrappers using both microtasks and (macro) tasks.
// In < 2.4 we used micro tasks everywhere, but there are some scenarios where // In < 2.4 we used microtasks everywhere, but there are some scenarios where
// micro tasks have too high a priority and fires in between supposedly // microtasks have too high a priority and fire in between supposedly
// sequential events (e.g. #4521, #6690) or even between bubbling of the same // sequential events (e.g. #4521, #6690) or even between bubbling of the same
// event (#6566). However, using macro tasks everywhere also has subtle problems // event (#6566). However, using (macro) tasks everywhere also has subtle problems
// when state is changed right before repaint (e.g. #6813, out-in transitions). // when state is changed right before repaint (e.g. #6813, out-in transitions).
// Here we use micro task by default, but expose a way to force macro task when // Here we use microtask by default, but expose a way to force (macro) task when
// needed (e.g. in event handlers attached by v-on). // needed (e.g. in event handlers attached by v-on).
var microTimerFunc; var microTimerFunc;
var macroTimerFunc; var macroTimerFunc;
var useMacroTask = false; var useMacroTask = false;
// Determine (macro) Task defer implementation. // Determine (macro) task defer implementation.
// Technically setImmediate should be the ideal choice, but it's only available // Technically setImmediate should be the ideal choice, but it's only available
// in IE. The only polyfill that consistently queues the callback after all DOM // in IE. The only polyfill that consistently queues the callback after all DOM
// events triggered in the same loop is by using MessageChannel. // events triggered in the same loop is by using MessageChannel.
...@@ -2506,7 +2530,7 @@ if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) { ...@@ -2506,7 +2530,7 @@ if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
}; };
} }
// Determine MicroTask defer implementation. // Determine microtask defer implementation.
/* istanbul ignore next, $flow-disable-line */ /* istanbul ignore next, $flow-disable-line */
if (typeof Promise !== 'undefined' && isNative(Promise)) { if (typeof Promise !== 'undefined' && isNative(Promise)) {
var p = Promise.resolve(); var p = Promise.resolve();
...@@ -2526,7 +2550,7 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) { ...@@ -2526,7 +2550,7 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) {
/** /**
* Wrap a function so that if any code inside triggers state change, * Wrap a function so that if any code inside triggers state change,
* the changes are queued using a Task instead of a MicroTask. * the changes are queued using a (macro) task instead of a microtask.
*/ */
function withMacroTask (fn) { function withMacroTask (fn) {
return fn._withTask || (fn._withTask = function () { return fn._withTask || (fn._withTask = function () {
...@@ -2615,8 +2639,7 @@ if (true) { ...@@ -2615,8 +2639,7 @@ if (true) {
}; };
var hasProxy = var hasProxy =
typeof Proxy !== 'undefined' && typeof Proxy !== 'undefined' && isNative(Proxy);
Proxy.toString().match(/native code/);
if (hasProxy) { if (hasProxy) {
var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact'); var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
...@@ -2684,7 +2707,7 @@ function traverse (val) { ...@@ -2684,7 +2707,7 @@ function traverse (val) {
function _traverse (val, seen) { function _traverse (val, seen) {
var i, keys; var i, keys;
var isA = Array.isArray(val); var isA = Array.isArray(val);
if ((!isA && !isObject(val)) || Object.isFrozen(val)) { if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
return return
} }
if (val.__ob__) { if (val.__ob__) {
...@@ -3544,29 +3567,30 @@ function updateChildComponent ( ...@@ -3544,29 +3567,30 @@ function updateChildComponent (
// update $attrs and $listeners hash // update $attrs and $listeners hash
// these are also reactive so they may trigger child update if the child // these are also reactive so they may trigger child update if the child
// used them during render // used them during render
vm.$attrs = (parentVnode.data && parentVnode.data.attrs) || emptyObject; vm.$attrs = parentVnode.data.attrs || emptyObject;
vm.$listeners = listeners || emptyObject; vm.$listeners = listeners || emptyObject;
// update props // update props
if (propsData && vm.$options.props) { if (propsData && vm.$options.props) {
observerState.shouldConvert = false; toggleObserving(false);
var props = vm._props; var props = vm._props;
var propKeys = vm.$options._propKeys || []; var propKeys = vm.$options._propKeys || [];
for (var i = 0; i < propKeys.length; i++) { for (var i = 0; i < propKeys.length; i++) {
var key = propKeys[i]; var key = propKeys[i];
props[key] = validateProp(key, vm.$options.props, propsData, vm); var propOptions = vm.$options.props; // wtf flow?
props[key] = validateProp(key, propOptions, propsData, vm);
} }
observerState.shouldConvert = true; toggleObserving(true);
// keep a copy of raw propsData // keep a copy of raw propsData
vm.$options.propsData = propsData; vm.$options.propsData = propsData;
} }
// update listeners // update listeners
if (listeners) { listeners = listeners || emptyObject;
var oldListeners = vm.$options._parentListeners; var oldListeners = vm.$options._parentListeners;
vm.$options._parentListeners = listeners; vm.$options._parentListeners = listeners;
updateComponentListeners(vm, listeners, oldListeners); updateComponentListeners(vm, listeners, oldListeners);
}
// resolve slots + force update if has children // resolve slots + force update if has children
if (hasChildren) { if (hasChildren) {
vm.$slots = resolveSlots(renderChildren, parentVnode.context); vm.$slots = resolveSlots(renderChildren, parentVnode.context);
...@@ -3620,6 +3644,8 @@ function deactivateChildComponent (vm, direct) { ...@@ -3620,6 +3644,8 @@ function deactivateChildComponent (vm, direct) {
} }
function callHook (vm, hook) { function callHook (vm, hook) {
// #7573 disable dep collection when invoking lifecycle hooks
pushTarget();
var handlers = vm.$options[hook]; var handlers = vm.$options[hook];
if (handlers) { if (handlers) {
for (var i = 0, j = handlers.length; i < j; i++) { for (var i = 0, j = handlers.length; i < j; i++) {
...@@ -3633,6 +3659,7 @@ function callHook (vm, hook) { ...@@ -3633,6 +3659,7 @@ function callHook (vm, hook) {
if (vm._hasHookEvent) { if (vm._hasHookEvent) {
vm.$emit('hook:' + hook); vm.$emit('hook:' + hook);
} }
popTarget();
} }
/* */ /* */
...@@ -3777,7 +3804,7 @@ function queueWatcher (watcher) { ...@@ -3777,7 +3804,7 @@ function queueWatcher (watcher) {
/* */ /* */
var uid$2 = 0; var uid$1 = 0;
/** /**
* A watcher parses an expression, collects dependencies, * A watcher parses an expression, collects dependencies,
...@@ -3806,7 +3833,7 @@ var Watcher = function Watcher ( ...@@ -3806,7 +3833,7 @@ var Watcher = function Watcher (
this.deep = this.user = this.lazy = this.sync = false; this.deep = this.user = this.lazy = this.sync = false;
} }
this.cb = cb; this.cb = cb;
this.id = ++uid$2; // uid for batching this.id = ++uid$1; // uid for batching
this.active = true; this.active = true;
this.dirty = this.lazy; // for lazy watchers this.dirty = this.lazy; // for lazy watchers
this.deps = []; this.deps = [];
...@@ -4031,7 +4058,9 @@ function initProps (vm, propsOptions) { ...@@ -4031,7 +4058,9 @@ function initProps (vm, propsOptions) {
var keys = vm.$options._propKeys = []; var keys = vm.$options._propKeys = [];
var isRoot = !vm.$parent; var isRoot = !vm.$parent;
// root instance props should be converted // root instance props should be converted
observerState.shouldConvert = isRoot; if (!isRoot) {
toggleObserving(false);
}
var loop = function ( key ) { var loop = function ( key ) {
keys.push(key); keys.push(key);
var value = validateProp(key, propsOptions, propsData, vm); var value = validateProp(key, propsOptions, propsData, vm);
...@@ -4068,7 +4097,7 @@ function initProps (vm, propsOptions) { ...@@ -4068,7 +4097,7 @@ function initProps (vm, propsOptions) {
}; };
for (var key in propsOptions) loop( key ); for (var key in propsOptions) loop( key );
observerState.shouldConvert = true; toggleObserving(true);
} }
function initData (vm) { function initData (vm) {
...@@ -4114,11 +4143,15 @@ function initData (vm) { ...@@ -4114,11 +4143,15 @@ function initData (vm) {
} }
function getData (data, vm) { function getData (data, vm) {
// #7573 disable dep collection when invoking data getters
pushTarget();
try { try {
return data.call(vm, vm) return data.call(vm, vm)
} catch (e) { } catch (e) {
handleError(e, vm, "data()"); handleError(e, vm, "data()");
return {} return {}
} finally {
popTarget();
} }
} }
...@@ -4256,7 +4289,7 @@ function initWatch (vm, watch) { ...@@ -4256,7 +4289,7 @@ function initWatch (vm, watch) {
function createWatcher ( function createWatcher (
vm, vm,
keyOrFn, expOrFn,
handler, handler,
options options
) { ) {
...@@ -4267,7 +4300,7 @@ function createWatcher ( ...@@ -4267,7 +4300,7 @@ function createWatcher (
if (typeof handler === 'string') { if (typeof handler === 'string') {
handler = vm[handler]; handler = vm[handler];
} }
return vm.$watch(keyOrFn, handler, options) return vm.$watch(expOrFn, handler, options)
} }
function stateMixin (Vue) { function stateMixin (Vue) {
...@@ -4331,7 +4364,7 @@ function initProvide (vm) { ...@@ -4331,7 +4364,7 @@ function initProvide (vm) {
function initInjections (vm) { function initInjections (vm) {
var result = resolveInject(vm.$options.inject, vm); var result = resolveInject(vm.$options.inject, vm);
if (result) { if (result) {
observerState.shouldConvert = false; toggleObserving(false);
Object.keys(result).forEach(function (key) { Object.keys(result).forEach(function (key) {
/* istanbul ignore else */ /* istanbul ignore else */
if (true) { if (true) {
...@@ -4347,7 +4380,7 @@ function initInjections (vm) { ...@@ -4347,7 +4380,7 @@ function initInjections (vm) {
defineReactive(vm, key, result[key]); defineReactive(vm, key, result[key]);
} }
}); });
observerState.shouldConvert = true; toggleObserving(true);
} }
} }
...@@ -4367,7 +4400,7 @@ function resolveInject (inject, vm) { ...@@ -4367,7 +4400,7 @@ function resolveInject (inject, vm) {
var provideKey = inject[key].from; var provideKey = inject[key].from;
var source = vm; var source = vm;
while (source) { while (source) {
if (source._provided && provideKey in source._provided) { if (source._provided && hasOwn(source._provided, provideKey)) {
result[key] = source._provided[provideKey]; result[key] = source._provided[provideKey];
break break
} }
...@@ -4482,6 +4515,14 @@ function resolveFilter (id) { ...@@ -4482,6 +4515,14 @@ function resolveFilter (id) {
/* */ /* */
function isKeyNotMatch (expect, actual) {
if (Array.isArray(expect)) {
return expect.indexOf(actual) === -1
} else {
return expect !== actual
}
}
/** /**
* Runtime helper for checking keyCodes from config. * Runtime helper for checking keyCodes from config.
* exposed as Vue.prototype._k * exposed as Vue.prototype._k
...@@ -4490,16 +4531,15 @@ function resolveFilter (id) { ...@@ -4490,16 +4531,15 @@ function resolveFilter (id) {
function checkKeyCodes ( function checkKeyCodes (
eventKeyCode, eventKeyCode,
key, key,
builtInAlias, builtInKeyCode,
eventKeyName eventKeyName,
builtInKeyName
) { ) {
var keyCodes = config.keyCodes[key] || builtInAlias; var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
if (keyCodes) { if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
if (Array.isArray(keyCodes)) { return isKeyNotMatch(builtInKeyName, eventKeyName)
return keyCodes.indexOf(eventKeyCode) === -1 } else if (mappedKeyCode) {
} else { return isKeyNotMatch(mappedKeyCode, eventKeyCode)
return keyCodes !== eventKeyCode
}
} else if (eventKeyName) { } else if (eventKeyName) {
return hyphenate(eventKeyName) !== key return hyphenate(eventKeyName) !== key
} }
...@@ -4571,11 +4611,9 @@ function renderStatic ( ...@@ -4571,11 +4611,9 @@ function renderStatic (
var cached = this._staticTrees || (this._staticTrees = []); var cached = this._staticTrees || (this._staticTrees = []);
var tree = cached[index]; var tree = cached[index];
// if has already-rendered static tree and not inside v-for, // if has already-rendered static tree and not inside v-for,
// we can reuse the same tree by doing a shallow clone. // we can reuse the same tree.
if (tree && !isInFor) { if (tree && !isInFor) {
return Array.isArray(tree) return tree
? cloneVNodes(tree)
: cloneVNode(tree)
} }
// otherwise, render a fresh tree. // otherwise, render a fresh tree.
tree = cached[index] = this.$options.staticRenderFns[index].call( tree = cached[index] = this.$options.staticRenderFns[index].call(
...@@ -4673,6 +4711,24 @@ function FunctionalRenderContext ( ...@@ -4673,6 +4711,24 @@ function FunctionalRenderContext (
Ctor Ctor
) { ) {
var options = Ctor.options; var options = Ctor.options;
// ensure the createElement function in functional components
// gets a unique context - this is necessary for correct named slot check
var contextVm;
if (hasOwn(parent, '_uid')) {
contextVm = Object.create(parent);
// $flow-disable-line
contextVm._original = parent;
} else {
// the context vm passed in is a functional context as well.
// in this case we want to make sure we are able to get a hold to the
// real context instance.
contextVm = parent;
// $flow-disable-line
parent = parent._original;
}
var isCompiled = isTrue(options._compiled);
var needNormalization = !isCompiled;
this.data = data; this.data = data;
this.props = props; this.props = props;
this.children = children; this.children = children;
...@@ -4681,12 +4737,6 @@ function FunctionalRenderContext ( ...@@ -4681,12 +4737,6 @@ function FunctionalRenderContext (
this.injections = resolveInject(options.inject, parent); this.injections = resolveInject(options.inject, parent);
this.slots = function () { return resolveSlots(children, parent); }; this.slots = function () { return resolveSlots(children, parent); };
// ensure the createElement function in functional components
// gets a unique context - this is necessary for correct named slot check
var contextVm = Object.create(parent);
var isCompiled = isTrue(options._compiled);
var needNormalization = !isCompiled;
// support for compiled functional template // support for compiled functional template
if (isCompiled) { if (isCompiled) {
// exposing $options for renderStatic() // exposing $options for renderStatic()
...@@ -4699,7 +4749,7 @@ function FunctionalRenderContext ( ...@@ -4699,7 +4749,7 @@ function FunctionalRenderContext (
if (options._scopeId) { if (options._scopeId) {
this._c = function (a, b, c, d) { this._c = function (a, b, c, d) {
var vnode = createElement(contextVm, a, b, c, d, needNormalization); var vnode = createElement(contextVm, a, b, c, d, needNormalization);
if (vnode) { if (vnode && !Array.isArray(vnode)) {
vnode.fnScopeId = options._scopeId; vnode.fnScopeId = options._scopeId;
vnode.fnContext = parent; vnode.fnContext = parent;
} }
...@@ -4742,14 +4792,28 @@ function createFunctionalComponent ( ...@@ -4742,14 +4792,28 @@ function createFunctionalComponent (
var vnode = options.render.call(null, renderContext._c, renderContext); var vnode = options.render.call(null, renderContext._c, renderContext);
if (vnode instanceof VNode) { if (vnode instanceof VNode) {
vnode.fnContext = contextVm; return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options)
vnode.fnOptions = options; } else if (Array.isArray(vnode)) {
if (data.slot) { var vnodes = normalizeChildren(vnode) || [];
(vnode.data || (vnode.data = {})).slot = data.slot; var res = new Array(vnodes.length);
for (var i = 0; i < vnodes.length; i++) {
res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options);
} }
return res
} }
}
return vnode function cloneAndMarkFunctionalResult (vnode, data, contextVm, options) {
// #7817 clone node before setting fnContext, otherwise if the node is reused
// (e.g. it was from a cached normal slot) the fnContext causes named slots
// that should not be matched to match.
var clone = cloneVNode(vnode);
clone.fnContext = contextVm;
clone.fnOptions = options;
if (data.slot) {
(clone.data || (clone.data = {})).slot = data.slot;
}
return clone
} }
function mergeProps (to, from) { function mergeProps (to, from) {
...@@ -4779,7 +4843,7 @@ function mergeProps (to, from) { ...@@ -4779,7 +4843,7 @@ function mergeProps (to, from) {
/* */ /* */
// hooks to be invoked on component VNodes during patch // inline hooks to be invoked on component VNodes during patch
var componentVNodeHooks = { var componentVNodeHooks = {
init: function init ( init: function init (
vnode, vnode,
...@@ -4787,7 +4851,15 @@ var componentVNodeHooks = { ...@@ -4787,7 +4851,15 @@ var componentVNodeHooks = {
parentElm, parentElm,
refElm refElm
) { ) {
if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) { if (
vnode.componentInstance &&
!vnode.componentInstance._isDestroyed &&
vnode.data.keepAlive
) {
// kept-alive components, treat as a patch
var mountedNode = vnode; // work around flow
componentVNodeHooks.prepatch(mountedNode, mountedNode);
} else {
var child = vnode.componentInstance = createComponentInstanceForVnode( var child = vnode.componentInstance = createComponentInstanceForVnode(
vnode, vnode,
activeInstance, activeInstance,
...@@ -4795,10 +4867,6 @@ var componentVNodeHooks = { ...@@ -4795,10 +4867,6 @@ var componentVNodeHooks = {
refElm refElm
); );
child.$mount(hydrating ? vnode.elm : undefined, hydrating); child.$mount(hydrating ? vnode.elm : undefined, hydrating);
} else if (vnode.data.keepAlive) {
// kept-alive components, treat as a patch
var mountedNode = vnode; // work around flow
componentVNodeHooks.prepatch(mountedNode, mountedNode);
} }
}, },
...@@ -4933,8 +5001,8 @@ function createComponent ( ...@@ -4933,8 +5001,8 @@ function createComponent (
} }
} }
// merge component management hooks onto the placeholder node // install component management hooks onto the placeholder node
mergeHooks(data); installComponentHooks(data);
// return a placeholder vnode // return a placeholder vnode
var name = Ctor.options.name || tag; var name = Ctor.options.name || tag;
...@@ -4974,22 +5042,11 @@ function createComponentInstanceForVnode ( ...@@ -4974,22 +5042,11 @@ function createComponentInstanceForVnode (
return new vnode.componentOptions.Ctor(options) return new vnode.componentOptions.Ctor(options)
} }
function mergeHooks (data) { function installComponentHooks (data) {
if (!data.hook) { var hooks = data.hook || (data.hook = {});
data.hook = {};
}
for (var i = 0; i < hooksToMerge.length; i++) { for (var i = 0; i < hooksToMerge.length; i++) {
var key = hooksToMerge[i]; var key = hooksToMerge[i];
var fromParent = data.hook[key]; hooks[key] = componentVNodeHooks[key];
var ours = componentVNodeHooks[key];
data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
}
}
function mergeHook$1 (one, two) {
return function (a, b, c, d) {
one(a, b, c, d);
two(a, b, c, d);
} }
} }
...@@ -5106,8 +5163,11 @@ function _createElement ( ...@@ -5106,8 +5163,11 @@ function _createElement (
// direct component options / constructor // direct component options / constructor
vnode = createComponent(tag, data, context, children); vnode = createComponent(tag, data, context, children);
} }
if (isDef(vnode)) { if (Array.isArray(vnode)) {
if (ns) { applyNS(vnode, ns); } return vnode
} else if (isDef(vnode)) {
if (isDef(ns)) { applyNS(vnode, ns); }
if (isDef(data)) { registerDeepBindings(data); }
return vnode return vnode
} else { } else {
return createEmptyVNode() return createEmptyVNode()
...@@ -5124,13 +5184,26 @@ function applyNS (vnode, ns, force) { ...@@ -5124,13 +5184,26 @@ function applyNS (vnode, ns, force) {
if (isDef(vnode.children)) { if (isDef(vnode.children)) {
for (var i = 0, l = vnode.children.length; i < l; i++) { for (var i = 0, l = vnode.children.length; i < l; i++) {
var child = vnode.children[i]; var child = vnode.children[i];
if (isDef(child.tag) && (isUndef(child.ns) || isTrue(force))) { if (isDef(child.tag) && (
isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
applyNS(child, ns, force); applyNS(child, ns, force);
} }
} }
} }
} }
// ref #5318
// necessary to ensure parent re-render when deep bindings like :style and
// :class are used on slot nodes
function registerDeepBindings (data) {
if (isObject(data.style)) {
traverse(data.style);
}
if (isObject(data.class)) {
traverse(data.class);
}
}
/* */ /* */
function initRender (vm) { function initRender (vm) {
...@@ -5182,20 +5255,17 @@ function renderMixin (Vue) { ...@@ -5182,20 +5255,17 @@ function renderMixin (Vue) {
var render = ref.render; var render = ref.render;
var _parentVnode = ref._parentVnode; var _parentVnode = ref._parentVnode;
if (vm._isMounted) { // reset _rendered flag on slots for duplicate slot check
// if the parent didn't update, the slot nodes will be the ones from if (true) {
// last render. They need to be cloned to ensure "freshness" for this render.
for (var key in vm.$slots) { for (var key in vm.$slots) {
var slot = vm.$slots[key]; // $flow-disable-line
// _rendered is a flag added by renderSlot, but may not be present vm.$slots[key]._rendered = false;
// if the slot is passed from manually written render functions
if (slot._rendered || (slot[0] && slot[0].elm)) {
vm.$slots[key] = cloneVNodes(slot, true /* deep */);
}
} }
} }
vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject; if (_parentVnode) {
vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject;
}
// set parent vnode. this allows render functions to have access // set parent vnode. this allows render functions to have access
// to the data on the placeholder node. // to the data on the placeholder node.
...@@ -5243,13 +5313,13 @@ function renderMixin (Vue) { ...@@ -5243,13 +5313,13 @@ function renderMixin (Vue) {
/* */ /* */
var uid$1 = 0; var uid$3 = 0;
function initMixin (Vue) { function initMixin (Vue) {
Vue.prototype._init = function (options) { Vue.prototype._init = function (options) {
var vm = this; var vm = this;
// a uid // a uid
vm._uid = uid$1++; vm._uid = uid$3++;
var startTag, endTag; var startTag, endTag;
/* istanbul ignore if */ /* istanbul ignore if */
...@@ -5382,20 +5452,20 @@ function dedupe (latest, extended, sealed) { ...@@ -5382,20 +5452,20 @@ function dedupe (latest, extended, sealed) {
} }
} }
function Vue$3 (options) { function Vue (options) {
if ("development" !== 'production' && if ("development" !== 'production' &&
!(this instanceof Vue$3) !(this instanceof Vue)
) { ) {
warn('Vue is a constructor and should be called with the `new` keyword'); warn('Vue is a constructor and should be called with the `new` keyword');
} }
this._init(options); this._init(options);
} }
initMixin(Vue$3); initMixin(Vue);
stateMixin(Vue$3); stateMixin(Vue);
eventsMixin(Vue$3); eventsMixin(Vue);
lifecycleMixin(Vue$3); lifecycleMixin(Vue);
renderMixin(Vue$3); renderMixin(Vue);
/* */ /* */
...@@ -5624,13 +5694,15 @@ var KeepAlive = { ...@@ -5624,13 +5694,15 @@ var KeepAlive = {
} }
}, },
watch: { mounted: function mounted () {
include: function include (val) { var this$1 = this;
pruneCache(this, function (name) { return matches(val, name); });
}, this.$watch('include', function (val) {
exclude: function exclude (val) { pruneCache(this$1, function (name) { return matches(val, name); });
pruneCache(this, function (name) { return !matches(val, name); }); });
} this.$watch('exclude', function (val) {
pruneCache(this$1, function (name) { return !matches(val, name); });
});
}, },
render: function render () { render: function render () {
...@@ -5678,11 +5750,11 @@ var KeepAlive = { ...@@ -5678,11 +5750,11 @@ var KeepAlive = {
} }
return vnode || (slot && slot[0]) return vnode || (slot && slot[0])
} }
}; }
var builtInComponents = { var builtInComponents = {
KeepAlive: KeepAlive KeepAlive: KeepAlive
}; }
/* */ /* */
...@@ -5730,20 +5802,25 @@ function initGlobalAPI (Vue) { ...@@ -5730,20 +5802,25 @@ function initGlobalAPI (Vue) {
initAssetRegisters(Vue); initAssetRegisters(Vue);
} }
initGlobalAPI(Vue$3); initGlobalAPI(Vue);
Object.defineProperty(Vue$3.prototype, '$isServer', { Object.defineProperty(Vue.prototype, '$isServer', {
get: isServerRendering get: isServerRendering
}); });
Object.defineProperty(Vue$3.prototype, '$ssrContext', { Object.defineProperty(Vue.prototype, '$ssrContext', {
get: function get () { get: function get () {
/* istanbul ignore next */ /* istanbul ignore next */
return this.$vnode && this.$vnode.ssrContext return this.$vnode && this.$vnode.ssrContext
} }
}); });
Vue$3.version = '2.5.13'; // expose FunctionalRenderContext for ssr runtime helper installation
Object.defineProperty(Vue, 'FunctionalRenderContext', {
value: FunctionalRenderContext
});
Vue.version = '2.5.16';
/* */ /* */
...@@ -6017,8 +6094,8 @@ function setTextContent (node, text) { ...@@ -6017,8 +6094,8 @@ function setTextContent (node, text) {
node.textContent = text; node.textContent = text;
} }
function setAttribute (node, key, val) { function setStyleScope (node, scopeId) {
node.setAttribute(key, val); node.setAttribute(scopeId, '');
} }
...@@ -6034,7 +6111,7 @@ var nodeOps = Object.freeze({ ...@@ -6034,7 +6111,7 @@ var nodeOps = Object.freeze({
nextSibling: nextSibling, nextSibling: nextSibling,
tagName: tagName, tagName: tagName,
setTextContent: setTextContent, setTextContent: setTextContent,
setAttribute: setAttribute setStyleScope: setStyleScope
}); });
/* */ /* */
...@@ -6052,11 +6129,11 @@ var ref = { ...@@ -6052,11 +6129,11 @@ var ref = {
destroy: function destroy (vnode) { destroy: function destroy (vnode) {
registerRef(vnode, true); registerRef(vnode, true);
} }
}; }
function registerRef (vnode, isRemoval) { function registerRef (vnode, isRemoval) {
var key = vnode.data.ref; var key = vnode.data.ref;
if (!key) { return } if (!isDef(key)) { return }
var vm = vnode.context; var vm = vnode.context;
var ref = vnode.componentInstance || vnode.elm; var ref = vnode.componentInstance || vnode.elm;
...@@ -6187,7 +6264,25 @@ function createPatchFunction (backend) { ...@@ -6187,7 +6264,25 @@ function createPatchFunction (backend) {
} }
var creatingElmInVPre = 0; var creatingElmInVPre = 0;
function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) {
function createElm (
vnode,
insertedVnodeQueue,
parentElm,
refElm,
nested,
ownerArray,
index
) {
if (isDef(vnode.elm) && isDef(ownerArray)) {
// This vnode was used in a previous render!
// now it's used as a new node, overwriting its elm would cause
// potential patch errors down the road when it's used as an insertion
// reference node. Instead, we clone the node on-demand before creating
// associated DOM element for it.
vnode = ownerArray[index] = cloneVNode(vnode);
}
vnode.isRootInsert = !nested; // for transition enter check vnode.isRootInsert = !nested; // for transition enter check
if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) { if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
return return
...@@ -6210,6 +6305,7 @@ function createPatchFunction (backend) { ...@@ -6210,6 +6305,7 @@ function createPatchFunction (backend) {
); );
} }
} }
vnode.elm = vnode.ns vnode.elm = vnode.ns
? nodeOps.createElementNS(vnode.ns, tag) ? nodeOps.createElementNS(vnode.ns, tag)
: nodeOps.createElement(tag, vnode); : nodeOps.createElement(tag, vnode);
...@@ -6315,7 +6411,7 @@ function createPatchFunction (backend) { ...@@ -6315,7 +6411,7 @@ function createPatchFunction (backend) {
checkDuplicateKeys(children); checkDuplicateKeys(children);
} }
for (var i = 0; i < children.length; ++i) { for (var i = 0; i < children.length; ++i) {
createElm(children[i], insertedVnodeQueue, vnode.elm, null, true); createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
} }
} else if (isPrimitive(vnode.text)) { } else if (isPrimitive(vnode.text)) {
nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text))); nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
...@@ -6346,12 +6442,12 @@ function createPatchFunction (backend) { ...@@ -6346,12 +6442,12 @@ function createPatchFunction (backend) {
function setScope (vnode) { function setScope (vnode) {
var i; var i;
if (isDef(i = vnode.fnScopeId)) { if (isDef(i = vnode.fnScopeId)) {
nodeOps.setAttribute(vnode.elm, i, ''); nodeOps.setStyleScope(vnode.elm, i);
} else { } else {
var ancestor = vnode; var ancestor = vnode;
while (ancestor) { while (ancestor) {
if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) { if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
nodeOps.setAttribute(vnode.elm, i, ''); nodeOps.setStyleScope(vnode.elm, i);
} }
ancestor = ancestor.parent; ancestor = ancestor.parent;
} }
...@@ -6362,13 +6458,13 @@ function createPatchFunction (backend) { ...@@ -6362,13 +6458,13 @@ function createPatchFunction (backend) {
i !== vnode.fnContext && i !== vnode.fnContext &&
isDef(i = i.$options._scopeId) isDef(i = i.$options._scopeId)
) { ) {
nodeOps.setAttribute(vnode.elm, i, ''); nodeOps.setStyleScope(vnode.elm, i);
} }
} }
function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) { function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
for (; startIdx <= endIdx; ++startIdx) { for (; startIdx <= endIdx; ++startIdx) {
createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm); createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
} }
} }
...@@ -6478,7 +6574,7 @@ function createPatchFunction (backend) { ...@@ -6478,7 +6574,7 @@ function createPatchFunction (backend) {
? oldKeyToIdx[newStartVnode.key] ? oldKeyToIdx[newStartVnode.key]
: findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx); : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
if (isUndef(idxInOld)) { // New element if (isUndef(idxInOld)) { // New element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
} else { } else {
vnodeToMove = oldCh[idxInOld]; vnodeToMove = oldCh[idxInOld];
if (sameVnode(vnodeToMove, newStartVnode)) { if (sameVnode(vnodeToMove, newStartVnode)) {
...@@ -6487,7 +6583,7 @@ function createPatchFunction (backend) { ...@@ -6487,7 +6583,7 @@ function createPatchFunction (backend) {
canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm); canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
} else { } else {
// same key but different element. treat as new element // same key but different element. treat as new element
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
} }
} }
newStartVnode = newCh[++newStartIdx]; newStartVnode = newCh[++newStartIdx];
...@@ -6825,7 +6921,7 @@ var directives = { ...@@ -6825,7 +6921,7 @@ var directives = {
destroy: function unbindDirectives (vnode) { destroy: function unbindDirectives (vnode) {
updateDirectives(vnode, emptyNode); updateDirectives(vnode, emptyNode);
} }
}; }
function updateDirectives (oldVnode, vnode) { function updateDirectives (oldVnode, vnode) {
if (oldVnode.data.directives || vnode.data.directives) { if (oldVnode.data.directives || vnode.data.directives) {
...@@ -6936,7 +7032,7 @@ function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) { ...@@ -6936,7 +7032,7 @@ function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
var baseModules = [ var baseModules = [
ref, ref,
directives directives
]; ]
/* */ /* */
...@@ -6982,7 +7078,9 @@ function updateAttrs (oldVnode, vnode) { ...@@ -6982,7 +7078,9 @@ function updateAttrs (oldVnode, vnode) {
} }
function setAttr (el, key, value) { function setAttr (el, key, value) {
if (isBooleanAttr(key)) { if (el.tagName.indexOf('-') > -1) {
baseSetAttr(el, key, value);
} else if (isBooleanAttr(key)) {
// set attribute for blank value // set attribute for blank value
// e.g. <option disabled>Select one</option> // e.g. <option disabled>Select one</option>
if (isFalsyAttrValue(value)) { if (isFalsyAttrValue(value)) {
...@@ -7004,6 +7102,11 @@ function setAttr (el, key, value) { ...@@ -7004,6 +7102,11 @@ function setAttr (el, key, value) {
el.setAttributeNS(xlinkNS, key, value); el.setAttributeNS(xlinkNS, key, value);
} }
} else { } else {
baseSetAttr(el, key, value);
}
}
function baseSetAttr (el, key, value) {
if (isFalsyAttrValue(value)) { if (isFalsyAttrValue(value)) {
el.removeAttribute(key); el.removeAttribute(key);
} else { } else {
...@@ -7026,13 +7129,12 @@ function setAttr (el, key, value) { ...@@ -7026,13 +7129,12 @@ function setAttr (el, key, value) {
} }
el.setAttribute(key, value); el.setAttribute(key, value);
} }
}
} }
var attrs = { var attrs = {
create: updateAttrs, create: updateAttrs,
update: updateAttrs update: updateAttrs
}; }
/* */ /* */
...@@ -7070,7 +7172,7 @@ function updateClass (oldVnode, vnode) { ...@@ -7070,7 +7172,7 @@ function updateClass (oldVnode, vnode) {
var klass = { var klass = {
create: updateClass, create: updateClass,
update: updateClass update: updateClass
}; }
/* */ /* */
...@@ -7166,7 +7268,7 @@ function wrapFilter (exp, filter) { ...@@ -7166,7 +7268,7 @@ function wrapFilter (exp, filter) {
} else { } else {
var name = filter.slice(0, i); var name = filter.slice(0, i);
var args = filter.slice(i + 1); var args = filter.slice(i + 1);
return ("_f(\"" + name + "\")(" + exp + "," + args) return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
} }
} }
...@@ -7269,7 +7371,9 @@ function addHandler ( ...@@ -7269,7 +7371,9 @@ function addHandler (
events = el.events || (el.events = {}); events = el.events || (el.events = {});
} }
var newHandler = { value: value }; var newHandler = {
value: value.trim()
};
if (modifiers !== emptyObject) { if (modifiers !== emptyObject) {
newHandler.modifiers = modifiers; newHandler.modifiers = modifiers;
} }
...@@ -7404,6 +7508,9 @@ var expressionEndPos; ...@@ -7404,6 +7508,9 @@ var expressionEndPos;
function parseModel (val) { function parseModel (val) {
// Fix https://github.com/vuejs/vue/pull/7730
// allow v-model="obj.val " (trailing whitespace)
val = val.trim();
len = val.length; len = val.length;
if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) { if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
...@@ -7564,8 +7671,8 @@ function genCheckboxModel ( ...@@ -7564,8 +7671,8 @@ function genCheckboxModel (
'if(Array.isArray($$a)){' + 'if(Array.isArray($$a)){' +
"var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," + "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
'$$i=_i($$a,$$v);' + '$$i=_i($$a,$$v);' +
"if($$el.checked){$$i<0&&(" + value + "=$$a.concat([$$v]))}" + "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
"else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" + "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
"}else{" + (genAssignmentCode(value, '$$c')) + "}", "}else{" + (genAssignmentCode(value, '$$c')) + "}",
null, true null, true
); );
...@@ -7608,9 +7715,11 @@ function genDefaultModel ( ...@@ -7608,9 +7715,11 @@ function genDefaultModel (
var type = el.attrsMap.type; var type = el.attrsMap.type;
// warn if v-bind:value conflicts with v-model // warn if v-bind:value conflicts with v-model
// except for inputs with v-bind:type
if (true) { if (true) {
var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value']; var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
if (value$1) { var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
if (value$1 && !typeBinding) {
var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value'; var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
warn$1( warn$1(
binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " + binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
...@@ -7731,7 +7840,7 @@ function updateDOMListeners (oldVnode, vnode) { ...@@ -7731,7 +7840,7 @@ function updateDOMListeners (oldVnode, vnode) {
var events = { var events = {
create: updateDOMListeners, create: updateDOMListeners,
update: updateDOMListeners update: updateDOMListeners
}; }
/* */ /* */
...@@ -7825,7 +7934,7 @@ function isDirtyWithModifiers (elm, newVal) { ...@@ -7825,7 +7934,7 @@ function isDirtyWithModifiers (elm, newVal) {
var domProps = { var domProps = {
create: updateDOMProps, create: updateDOMProps,
update: updateDOMProps update: updateDOMProps
}; }
/* */ /* */
...@@ -7986,7 +8095,7 @@ function updateStyle (oldVnode, vnode) { ...@@ -7986,7 +8095,7 @@ function updateStyle (oldVnode, vnode) {
var style = { var style = {
create: updateStyle, create: updateStyle,
update: updateStyle update: updateStyle
}; }
/* */ /* */
...@@ -8359,15 +8468,17 @@ function enter (vnode, toggleDisplay) { ...@@ -8359,15 +8468,17 @@ function enter (vnode, toggleDisplay) {
addTransitionClass(el, startClass); addTransitionClass(el, startClass);
addTransitionClass(el, activeClass); addTransitionClass(el, activeClass);
nextFrame(function () { nextFrame(function () {
addTransitionClass(el, toClass);
removeTransitionClass(el, startClass); removeTransitionClass(el, startClass);
if (!cb.cancelled && !userWantsControl) { if (!cb.cancelled) {
addTransitionClass(el, toClass);
if (!userWantsControl) {
if (isValidDuration(explicitEnterDuration)) { if (isValidDuration(explicitEnterDuration)) {
setTimeout(cb, explicitEnterDuration); setTimeout(cb, explicitEnterDuration);
} else { } else {
whenTransitionEnds(el, type, cb); whenTransitionEnds(el, type, cb);
} }
} }
}
}); });
} }
...@@ -8465,15 +8576,17 @@ function leave (vnode, rm) { ...@@ -8465,15 +8576,17 @@ function leave (vnode, rm) {
addTransitionClass(el, leaveClass); addTransitionClass(el, leaveClass);
addTransitionClass(el, leaveActiveClass); addTransitionClass(el, leaveActiveClass);
nextFrame(function () { nextFrame(function () {
addTransitionClass(el, leaveToClass);
removeTransitionClass(el, leaveClass); removeTransitionClass(el, leaveClass);
if (!cb.cancelled && !userWantsControl) { if (!cb.cancelled) {
addTransitionClass(el, leaveToClass);
if (!userWantsControl) {
if (isValidDuration(explicitLeaveDuration)) { if (isValidDuration(explicitLeaveDuration)) {
setTimeout(cb, explicitLeaveDuration); setTimeout(cb, explicitLeaveDuration);
} else { } else {
whenTransitionEnds(el, type, cb); whenTransitionEnds(el, type, cb);
} }
} }
}
}); });
} }
leave && leave(el, cb); leave && leave(el, cb);
...@@ -8544,7 +8657,7 @@ var transition = inBrowser ? { ...@@ -8544,7 +8657,7 @@ var transition = inBrowser ? {
rm(); rm();
} }
} }
} : {}; } : {}
var platformModules = [ var platformModules = [
attrs, attrs,
...@@ -8553,7 +8666,7 @@ var platformModules = [ ...@@ -8553,7 +8666,7 @@ var platformModules = [
domProps, domProps,
style, style,
transition transition
]; ]
/* */ /* */
...@@ -8594,15 +8707,13 @@ var directive = { ...@@ -8594,15 +8707,13 @@ var directive = {
} else if (vnode.tag === 'textarea' || isTextInputType(el.type)) { } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
el._vModifiers = binding.modifiers; el._vModifiers = binding.modifiers;
if (!binding.modifiers.lazy) { if (!binding.modifiers.lazy) {
el.addEventListener('compositionstart', onCompositionStart);
el.addEventListener('compositionend', onCompositionEnd);
// Safari < 10.2 & UIWebView doesn't fire compositionend when // Safari < 10.2 & UIWebView doesn't fire compositionend when
// switching focus before confirming composition choice // switching focus before confirming composition choice
// this also fixes the issue where some browsers e.g. iOS Chrome // this also fixes the issue where some browsers e.g. iOS Chrome
// fires "change" instead of "input" on autocomplete. // fires "change" instead of "input" on autocomplete.
el.addEventListener('change', onCompositionEnd); el.addEventListener('change', onCompositionEnd);
if (!isAndroid) {
el.addEventListener('compositionstart', onCompositionStart);
el.addEventListener('compositionend', onCompositionEnd);
}
/* istanbul ignore if */ /* istanbul ignore if */
if (isIE9) { if (isIE9) {
el.vmodel = true; el.vmodel = true;
...@@ -8736,7 +8847,7 @@ var show = { ...@@ -8736,7 +8847,7 @@ var show = {
var oldValue = ref.oldValue; var oldValue = ref.oldValue;
/* istanbul ignore if */ /* istanbul ignore if */
if (value === oldValue) { return } if (!value === !oldValue) { return }
vnode = locateNode(vnode); vnode = locateNode(vnode);
var transition$$1 = vnode.data && vnode.data.transition; var transition$$1 = vnode.data && vnode.data.transition;
if (transition$$1) { if (transition$$1) {
...@@ -8766,12 +8877,12 @@ var show = { ...@@ -8766,12 +8877,12 @@ var show = {
el.style.display = el.__vOriginalDisplay; el.style.display = el.__vOriginalDisplay;
} }
} }
}; }
var platformDirectives = { var platformDirectives = {
model: directive, model: directive,
show: show show: show
}; }
/* */ /* */
...@@ -8960,7 +9071,7 @@ var Transition = { ...@@ -8960,7 +9071,7 @@ var Transition = {
return rawChild return rawChild
} }
}; }
/* */ /* */
...@@ -9034,7 +9145,7 @@ var TransitionGroup = { ...@@ -9034,7 +9145,7 @@ var TransitionGroup = {
this._vnode, this._vnode,
this.kept, this.kept,
false, // hydrating false, // hydrating
true // removeOnly (!important avoids unnecessary moves) true // removeOnly (!important, avoids unnecessary moves)
); );
this._vnode = this.kept; this._vnode = this.kept;
}, },
...@@ -9101,7 +9212,7 @@ var TransitionGroup = { ...@@ -9101,7 +9212,7 @@ var TransitionGroup = {
return (this._hasMove = info.hasTransform) return (this._hasMove = info.hasTransform)
} }
} }
}; }
function callPendingCbs (c) { function callPendingCbs (c) {
/* istanbul ignore if */ /* istanbul ignore if */
...@@ -9134,26 +9245,26 @@ function applyTranslation (c) { ...@@ -9134,26 +9245,26 @@ function applyTranslation (c) {
var platformComponents = { var platformComponents = {
Transition: Transition, Transition: Transition,
TransitionGroup: TransitionGroup TransitionGroup: TransitionGroup
}; }
/* */ /* */
// install platform specific utils // install platform specific utils
Vue$3.config.mustUseProp = mustUseProp; Vue.config.mustUseProp = mustUseProp;
Vue$3.config.isReservedTag = isReservedTag; Vue.config.isReservedTag = isReservedTag;
Vue$3.config.isReservedAttr = isReservedAttr; Vue.config.isReservedAttr = isReservedAttr;
Vue$3.config.getTagNamespace = getTagNamespace; Vue.config.getTagNamespace = getTagNamespace;
Vue$3.config.isUnknownElement = isUnknownElement; Vue.config.isUnknownElement = isUnknownElement;
// install platform runtime directives & components // install platform runtime directives & components
extend(Vue$3.options.directives, platformDirectives); extend(Vue.options.directives, platformDirectives);
extend(Vue$3.options.components, platformComponents); extend(Vue.options.components, platformComponents);
// install platform patch function // install platform patch function
Vue$3.prototype.__patch__ = inBrowser ? patch : noop; Vue.prototype.__patch__ = inBrowser ? patch : noop;
// public mount method // public mount method
Vue$3.prototype.$mount = function ( Vue.prototype.$mount = function (
el, el,
hydrating hydrating
) { ) {
...@@ -9163,11 +9274,16 @@ Vue$3.prototype.$mount = function ( ...@@ -9163,11 +9274,16 @@ Vue$3.prototype.$mount = function (
// devtools global hook // devtools global hook
/* istanbul ignore next */ /* istanbul ignore next */
Vue$3.nextTick(function () { if (inBrowser) {
setTimeout(function () {
if (config.devtools) { if (config.devtools) {
if (devtools) { if (devtools) {
devtools.emit('init', Vue$3); devtools.emit('init', Vue);
} else if ("development" !== 'production' && isChrome) { } else if (
"development" !== 'production' &&
"development" !== 'test' &&
isChrome
) {
console[console.info ? 'info' : 'log']( console[console.info ? 'info' : 'log'](
'Download the Vue Devtools extension for a better development experience:\n' + 'Download the Vue Devtools extension for a better development experience:\n' +
'https://github.com/vuejs/vue-devtools' 'https://github.com/vuejs/vue-devtools'
...@@ -9175,8 +9291,9 @@ Vue$3.nextTick(function () { ...@@ -9175,8 +9291,9 @@ Vue$3.nextTick(function () {
} }
} }
if ("development" !== 'production' && if ("development" !== 'production' &&
"development" !== 'test' &&
config.productionTip !== false && config.productionTip !== false &&
inBrowser && typeof console !== 'undefined' typeof console !== 'undefined'
) { ) {
console[console.info ? 'info' : 'log']( console[console.info ? 'info' : 'log'](
"You are running Vue in development mode.\n" + "You are running Vue in development mode.\n" +
...@@ -9184,7 +9301,8 @@ Vue$3.nextTick(function () { ...@@ -9184,7 +9301,8 @@ Vue$3.nextTick(function () {
"See more tips at https://vuejs.org/guide/deployment.html" "See more tips at https://vuejs.org/guide/deployment.html"
); );
} }
}, 0); }, 0);
}
/* */ /* */
...@@ -9274,7 +9392,7 @@ var klass$1 = { ...@@ -9274,7 +9392,7 @@ var klass$1 = {
staticKeys: ['staticClass'], staticKeys: ['staticClass'],
transformNode: transformNode, transformNode: transformNode,
genData: genData genData: genData
}; }
/* */ /* */
...@@ -9318,7 +9436,7 @@ var style$1 = { ...@@ -9318,7 +9436,7 @@ var style$1 = {
staticKeys: ['staticStyle'], staticKeys: ['staticStyle'],
transformNode: transformNode$1, transformNode: transformNode$1,
genData: genData$1 genData: genData$1
}; }
/* */ /* */
...@@ -9330,7 +9448,7 @@ var he = { ...@@ -9330,7 +9448,7 @@ var he = {
decoder.innerHTML = html; decoder.innerHTML = html;
return decoder.textContent return decoder.textContent
} }
}; }
/* */ /* */
...@@ -9376,7 +9494,8 @@ var startTagOpen = new RegExp(("^<" + qnameCapture)); ...@@ -9376,7 +9494,8 @@ var startTagOpen = new RegExp(("^<" + qnameCapture));
var startTagClose = /^\s*(\/?)>/; var startTagClose = /^\s*(\/?)>/;
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>")); var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
var doctype = /^<!DOCTYPE [^>]+>/i; var doctype = /^<!DOCTYPE [^>]+>/i;
var comment = /^<!--/; // #7298: escape - to avoid being pased as HTML comment when inlined in page
var comment = /^<!\--/;
var conditionalComment = /^<!\[/; var conditionalComment = /^<!\[/;
var IS_REGEX_CAPTURING_BROKEN = false; var IS_REGEX_CAPTURING_BROKEN = false;
...@@ -9506,7 +9625,7 @@ function parseHTML (html, options) { ...@@ -9506,7 +9625,7 @@ function parseHTML (html, options) {
endTagLength = endTag.length; endTagLength = endTag.length;
if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') { if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
text = text text = text
.replace(/<!--([\s\S]*?)-->/g, '$1') .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
.replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1'); .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
} }
if (shouldIgnoreFirstNewline(stackedTag, text)) { if (shouldIgnoreFirstNewline(stackedTag, text)) {
...@@ -9666,7 +9785,7 @@ function parseHTML (html, options) { ...@@ -9666,7 +9785,7 @@ function parseHTML (html, options) {
var onRE = /^@|^v-on:/; var onRE = /^@|^v-on:/;
var dirRE = /^v-|^@|^:/; var dirRE = /^v-|^@|^:/;
var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/; var forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/;
var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
var stripParensRE = /^\(|\)$/g; var stripParensRE = /^\(|\)$/g;
...@@ -10004,6 +10123,8 @@ function processFor (el) { ...@@ -10004,6 +10123,8 @@ function processFor (el) {
} }
} }
function parseFor (exp) { function parseFor (exp) {
var inMatch = exp.match(forAliasRE); var inMatch = exp.match(forAliasRE);
if (!inMatch) { return } if (!inMatch) { return }
...@@ -10326,8 +10447,19 @@ function checkForAliasModel (el, value) { ...@@ -10326,8 +10447,19 @@ function checkForAliasModel (el, value) {
function preTransformNode (el, options) { function preTransformNode (el, options) {
if (el.tag === 'input') { if (el.tag === 'input') {
var map = el.attrsMap; var map = el.attrsMap;
if (map['v-model'] && (map['v-bind:type'] || map[':type'])) { if (!map['v-model']) {
var typeBinding = getBindingAttr(el, 'type'); return
}
var typeBinding;
if (map[':type'] || map['v-bind:type']) {
typeBinding = getBindingAttr(el, 'type');
}
if (!map.type && !typeBinding && map['v-bind']) {
typeBinding = "(" + (map['v-bind']) + ").type";
}
if (typeBinding) {
var ifCondition = getAndRemoveAttr(el, 'v-if', true); var ifCondition = getAndRemoveAttr(el, 'v-if', true);
var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : ""; var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
var hasElse = getAndRemoveAttr(el, 'v-else', true) != null; var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
...@@ -10380,13 +10512,13 @@ function cloneASTElement (el) { ...@@ -10380,13 +10512,13 @@ function cloneASTElement (el) {
var model$2 = { var model$2 = {
preTransformNode: preTransformNode preTransformNode: preTransformNode
}; }
var modules$1 = [ var modules$1 = [
klass$1, klass$1,
style$1, style$1,
model$2 model$2
]; ]
/* */ /* */
...@@ -10408,7 +10540,7 @@ var directives$1 = { ...@@ -10408,7 +10540,7 @@ var directives$1 = {
model: model, model: model,
text: text, text: text,
html: html html: html
}; }
/* */ /* */
...@@ -10554,10 +10686,10 @@ function isDirectChildOfTemplateFor (node) { ...@@ -10554,10 +10686,10 @@ function isDirectChildOfTemplateFor (node) {
/* */ /* */
var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/; var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
// keyCode aliases // KeyboardEvent.keyCode aliases
var keyCodes = { var keyCodes = {
esc: 27, esc: 27,
tab: 9, tab: 9,
...@@ -10570,6 +10702,20 @@ var keyCodes = { ...@@ -10570,6 +10702,20 @@ var keyCodes = {
'delete': [8, 46] 'delete': [8, 46]
}; };
// KeyboardEvent.key aliases
var keyNames = {
esc: 'Escape',
tab: 'Tab',
enter: 'Enter',
space: ' ',
// #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
up: ['Up', 'ArrowUp'],
left: ['Left', 'ArrowLeft'],
right: ['Right', 'ArrowRight'],
down: ['Down', 'ArrowDown'],
'delete': ['Backspace', 'Delete']
};
// #4868: modifiers that prevent the execution of the listener // #4868: modifiers that prevent the execution of the listener
// need to explicitly return null so that we can determine whether to remove // need to explicitly return null so that we can determine whether to remove
// the listener for .once // the listener for .once
...@@ -10652,9 +10798,9 @@ function genHandler ( ...@@ -10652,9 +10798,9 @@ function genHandler (
code += genModifierCode; code += genModifierCode;
} }
var handlerCode = isMethodPath var handlerCode = isMethodPath
? handler.value + '($event)' ? ("return " + (handler.value) + "($event)")
: isFunctionExpression : isFunctionExpression
? ("(" + (handler.value) + ")($event)") ? ("return (" + (handler.value) + ")($event)")
: handler.value; : handler.value;
/* istanbul ignore if */ /* istanbul ignore if */
return ("function($event){" + code + handlerCode + "}") return ("function($event){" + code + handlerCode + "}")
...@@ -10670,12 +10816,15 @@ function genFilterCode (key) { ...@@ -10670,12 +10816,15 @@ function genFilterCode (key) {
if (keyVal) { if (keyVal) {
return ("$event.keyCode!==" + keyVal) return ("$event.keyCode!==" + keyVal)
} }
var code = keyCodes[key]; var keyCode = keyCodes[key];
var keyName = keyNames[key];
return ( return (
"_k($event.keyCode," + "_k($event.keyCode," +
(JSON.stringify(key)) + "," + (JSON.stringify(key)) + "," +
(JSON.stringify(code)) + "," + (JSON.stringify(keyCode)) + "," +
"$event.key)" "$event.key," +
"" + (JSON.stringify(keyName)) +
")"
) )
} }
...@@ -10702,7 +10851,7 @@ var baseDirectives = { ...@@ -10702,7 +10851,7 @@ var baseDirectives = {
on: on, on: on,
bind: bind$1, bind: bind$1,
cloak: noop cloak: noop
}; }
/* */ /* */
...@@ -11453,8 +11602,8 @@ var idToTemplate = cached(function (id) { ...@@ -11453,8 +11602,8 @@ var idToTemplate = cached(function (id) {
return el && el.innerHTML return el && el.innerHTML
}); });
var mount = Vue$3.prototype.$mount; var mount = Vue.prototype.$mount;
Vue$3.prototype.$mount = function ( Vue.prototype.$mount = function (
el, el,
hydrating hydrating
) { ) {
...@@ -11536,9 +11685,9 @@ function getOuterHTML (el) { ...@@ -11536,9 +11685,9 @@ function getOuterHTML (el) {
} }
} }
Vue$3.compile = compileToFunctions; Vue.compile = compileToFunctions;
module.exports = Vue$3; module.exports = Vue;
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(41), __webpack_require__(418).setImmediate)) /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(41), __webpack_require__(418).setImmediate))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment