Updating vuejs

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