(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.vue = factory()); }(this, function () { 'use strict'; /* */ var emptyobject = object.freeze({}); // these helpers produce better vm code in js engines due to their // explicitness and function inlining. function isundef (v) { return v === undefined || v === null } function isdef (v) { return v !== undefined && v !== null } function istrue (v) { return v === true } function isfalse (v) { return v === false } /** * check if value is primitive. */ function isprimitive (value) { return ( typeof value === 'string' || typeof value === 'number' || // $flow-disable-line typeof value === 'symbol' || typeof value === 'boolean' ) } /** * quick object check - this is primarily used to tell * objects from primitive values when we know the value * is a json-compliant type. */ function isobject (obj) { return obj !== null && typeof obj === 'object' } /** * get the raw type string of a value, e.g., [object object]. */ var _tostring = object.prototype.tostring; function torawtype (value) { return _tostring.call(value).slice(8, -1) } /** * strict object type check. only returns true * for plain javascript objects. */ function isplainobject (obj) { return _tostring.call(obj) === '[object object]' } function isregexp (v) { return _tostring.call(v) === '[object regexp]' } /** * check if val is a valid array index. */ function isvalidarrayindex (val) { var n = parsefloat(string(val)); return n >= 0 && math.floor(n) === n && isfinite(val) } function ispromise (val) { return ( isdef(val) && typeof val.then === 'function' && typeof val.catch === 'function' ) } /** * convert a value to a string that is actually rendered. */ function tostring (val) { return val == null ? '' : array.isarray(val) || (isplainobject(val) && val.tostring === _tostring) ? json.stringify(val, null, 2) : string(val) } /** * convert an input value to a number for persistence. * if the conversion fails, return original string. */ function tonumber (val) { var n = parsefloat(val); return isnan(n) ? val : n } /** * make a map and return a function for checking if a key * is in that map. */ function makemap ( str, expectslowercase ) { var map = object.create(null); var list = str.split(','); for (var i = 0; i < list.length; i++) { map[list[i]] = true; } return expectslowercase ? function (val) { return map[val.tolowercase()]; } : function (val) { return map[val]; } } /** * check if a tag is a built-in tag. */ var isbuiltintag = makemap('slot,component', true); /** * check if an attribute is a reserved attribute. */ var isreservedattribute = makemap('key,ref,slot,slot-scope,is'); /** * remove an item from an array. */ function remove (arr, item) { if (arr.length) { var index = arr.indexof(item); if (index > -1) { return arr.splice(index, 1) } } } /** * check whether an object has the property. */ var hasownproperty = object.prototype.hasownproperty; function hasown (obj, key) { return hasownproperty.call(obj, key) } /** * create a cached version of a pure function. */ function cached (fn) { var cache = object.create(null); return (function cachedfn (str) { var hit = cache[str]; return hit || (cache[str] = fn(str)) }) } /** * camelize a hyphen-delimited string. */ var camelizere = /-(\w)/g; var camelize = cached(function (str) { return str.replace(camelizere, function (_, c) { return c ? c.touppercase() : ''; }) }); /** * capitalize a string. */ var capitalize = cached(function (str) { return str.charat(0).touppercase() + str.slice(1) }); /** * hyphenate a camelcase string. */ var hyphenatere = /\b([a-z])/g; var hyphenate = cached(function (str) { return str.replace(hyphenatere, '-$1').tolowercase() }); /** * 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 performant enough in most browsers. * but removing it would mean breaking code that was able to run in * phantomjs 1.x, so this must be kept for backward compatibility. */ /* istanbul ignore next */ function polyfillbind (fn, ctx) { function boundfn (a) { var l = arguments.length; return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx) } 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. */ function toarray (list, start) { start = start || 0; var i = list.length - start; var ret = new array(i); while (i--) { ret[i] = list[i + start]; } return ret } /** * mix properties into target object. */ function extend (to, _from) { for (var key in _from) { to[key] = _from[key]; } return to } /** * merge an array of objects into a single object. */ function toobject (arr) { var res = {}; for (var i = 0; i < arr.length; i++) { if (arr[i]) { extend(res, arr[i]); } } return res } /* eslint-disable no-unused-vars */ /** * perform no operation. * stubbing args to make flow happy without leaving useless transpiled code */ function noop (a, b, c) {} /** * always return false. */ var no = function (a, b, c) { return false; }; /* eslint-enable no-unused-vars */ /** * return the same value. */ var identity = function (_) { return _; }; /** * generate a string containing static keys from compiler modules. */ function genstatickeys (modules) { return modules.reduce(function (keys, m) { return keys.concat(m.statickeys || []) }, []).join(',') } /** * check if two values are loosely equal - that is, * if they are plain objects, do they have the same shape? */ function looseequal (a, b) { if (a === b) { return true } var isobjecta = isobject(a); var isobjectb = isobject(b); if (isobjecta && isobjectb) { try { var isarraya = array.isarray(a); var isarrayb = array.isarray(b); if (isarraya && isarrayb) { return a.length === b.length && a.every(function (e, i) { return looseequal(e, b[i]) }) } else if (a instanceof date && b instanceof date) { return a.gettime() === b.gettime() } else if (!isarraya && !isarrayb) { var keysa = object.keys(a); var keysb = object.keys(b); return keysa.length === keysb.length && keysa.every(function (key) { return looseequal(a[key], b[key]) }) } else { /* istanbul ignore next */ return false } } catch (e) { /* istanbul ignore next */ return false } } else if (!isobjecta && !isobjectb) { return string(a) === string(b) } else { return false } } /** * return the first index at which a loosely equal value can be * found in the array (if value is a plain object, the array must * contain an object of the same shape), or -1 if it is not present. */ function looseindexof (arr, val) { for (var i = 0; i < arr.length; i++) { if (looseequal(arr[i], val)) { return i } } return -1 } /** * ensure a function is called only once. */ function once (fn) { var called = false; return function () { if (!called) { called = true; fn.apply(this, arguments); } } } var ssr_attr = 'data-server-rendered'; var asset_types = [ 'component', 'directive', 'filter' ]; var lifecycle_hooks = [ 'beforecreate', 'created', 'beforemount', 'mounted', 'beforeupdate', 'updated', 'beforedestroy', 'destroyed', 'activated', 'deactivated', 'errorcaptured', 'serverprefetch' ]; /* */ var config = ({ /** * option merge strategies (used in core/util/options) */ // $flow-disable-line optionmergestrategies: object.create(null), /** * whether to suppress warnings. */ silent: false, /** * show production mode tip message on boot? */ productiontip: "development" !== 'production', /** * whether to enable devtools */ devtools: "development" !== 'production', /** * whether to record perf */ performance: false, /** * error handler for watcher errors */ errorhandler: null, /** * warn handler for watcher warns */ warnhandler: null, /** * ignore certain custom elements */ ignoredelements: [], /** * custom user key aliases for v-on */ // $flow-disable-line keycodes: object.create(null), /** * check if a tag is reserved so that it cannot be registered as a * component. this is platform-dependent and may be overwritten. */ isreservedtag: no, /** * check if an attribute is reserved so that it cannot be used as a component * prop. this is platform-dependent and may be overwritten. */ isreservedattr: no, /** * check if a tag is an unknown element. * platform-dependent. */ isunknownelement: no, /** * get the namespace of an element */ gettagnamespace: noop, /** * parse the real tag name for the specific platform. */ parseplatformtagname: identity, /** * check if an attribute must be bound using property, e.g. value * platform-dependent. */ mustuseprop: no, /** * perform updates asynchronously. intended to be used by vue test utils * this will significantly reduce performance if set to false. */ async: true, /** * exposed for legacy reasons */ _lifecyclehooks: lifecycle_hooks }); /* */ /** * unicode letters used for parsing html tags, component names and property paths. * skipping \u10000-\ueffff due to it freezing up phantomjs */ var unicoderegexp = /a-za-z\u00b7\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u037d\u037f-\u1fff\u200c-\u200d\u203f-\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd/; /** * check if a string starts with $ or _ */ function isreserved (str) { var c = (str + '').charcodeat(0); return c === 0x24 || c === 0x5f } /** * define a property. */ function def (obj, key, val, enumerable) { object.defineproperty(obj, key, { value: val, enumerable: !!enumerable, writable: true, configurable: true }); } /** * parse simple path. */ var bailre = new regexp(("[^" + (unicoderegexp.source) + ".$_\\d]")); function parsepath (path) { if (bailre.test(path)) { return } var segments = path.split('.'); return function (obj) { for (var i = 0; i < segments.length; i++) { if (!obj) { return } obj = obj[segments[i]]; } return obj } } /* */ // can we use __proto__? var hasproto = '__proto__' in {}; // browser environment sniffing var inbrowser = typeof window !== 'undefined'; var inweex = typeof wxenvironment !== 'undefined' && !!wxenvironment.platform; var weexplatform = inweex && wxenvironment.platform.tolowercase(); var ua = inbrowser && window.navigator.useragent.tolowercase(); var isie = ua && /msie|trident/.test(ua); var isie9 = ua && ua.indexof('msie 9.0') > 0; var isedge = ua && ua.indexof('edge/') > 0; var isandroid = (ua && ua.indexof('android') > 0) || (weexplatform === 'android'); var isios = (ua && /iphone|ipad|ipod|ios/.test(ua)) || (weexplatform === 'ios'); var ischrome = ua && /chrome\/\d+/.test(ua) && !isedge; var isphantomjs = ua && /phantomjs/.test(ua); var isff = ua && ua.match(/firefox\/(\d+)/); // firefox has a "watch" function on object.prototype... var nativewatch = ({}).watch; var supportspassive = false; if (inbrowser) { try { var opts = {}; object.defineproperty(opts, 'passive', ({ get: function get () { /* istanbul ignore next */ supportspassive = true; } })); window.addeventlistener('test-passive', null, opts); } catch (e) {} } // this needs to be lazy-evaled because vue may be required before // vue-server-renderer can set vue_env var _isserver; var isserverrendering = function () { if (_isserver === undefined) { /* istanbul ignore if */ if (!inbrowser && !inweex && typeof global !== 'undefined') { // detect presence of vue-server-renderer and avoid // webpack shimming the process _isserver = global['process'] && global['process'].env.vue_env === 'server'; } else { _isserver = false; } } return _isserver }; // detect devtools var devtools = inbrowser && window.__vue_devtools_global_hook__; /* istanbul ignore next */ function isnative (ctor) { return typeof ctor === 'function' && /native code/.test(ctor.tostring()) } var hassymbol = typeof symbol !== 'undefined' && isnative(symbol) && typeof reflect !== 'undefined' && isnative(reflect.ownkeys); var _set; /* istanbul ignore if */ // $flow-disable-line if (typeof set !== 'undefined' && isnative(set)) { // use native set when available. _set = set; } else { // a non-standard set polyfill that only works with primitive keys. _set = /*@__pure__*/(function () { function set () { this.set = object.create(null); } set.prototype.has = function has (key) { return this.set[key] === true }; set.prototype.add = function add (key) { this.set[key] = true; }; set.prototype.clear = function clear () { this.set = object.create(null); }; return set; }()); } /* */ var warn = noop; var tip = noop; var generatecomponenttrace = (noop); // work around flow check var formatcomponentname = (noop); { var hasconsole = typeof console !== 'undefined'; var classifyre = /(?:^|[-_])(\w)/g; var classify = function (str) { return str .replace(classifyre, function (c) { return c.touppercase(); }) .replace(/[-_]/g, ''); }; warn = function (msg, vm) { var trace = vm ? generatecomponenttrace(vm) : ''; if (config.warnhandler) { config.warnhandler.call(null, msg, vm, trace); } else if (hasconsole && (!config.silent)) { console.error(("[vue warn]: " + msg + trace)); } }; tip = function (msg, vm) { if (hasconsole && (!config.silent)) { console.warn("[vue tip]: " + msg + ( vm ? generatecomponenttrace(vm) : '' )); } }; formatcomponentname = function (vm, includefile) { if (vm.$root === vm) { return '' } var options = typeof vm === 'function' && vm.cid != null ? vm.options : vm._isvue ? vm.$options || vm.constructor.options : vm; var name = options.name || options._componenttag; var file = options.__file; if (!name && file) { var match = file.match(/([^/\\]+)\.vue$/); name = match && match[1]; } return ( (name ? ("<" + (classify(name)) + ">") : "") + (file && includefile !== false ? (" at " + file) : '') ) }; var repeat = function (str, n) { var res = ''; while (n) { if (n % 2 === 1) { res += str; } if (n > 1) { str += str; } n >>= 1; } return res }; generatecomponenttrace = function (vm) { if (vm._isvue && vm.$parent) { var tree = []; var currentrecursivesequence = 0; while (vm) { if (tree.length > 0) { var last = tree[tree.length - 1]; if (last.constructor === vm.constructor) { currentrecursivesequence++; vm = vm.$parent; continue } else if (currentrecursivesequence > 0) { tree[tree.length - 1] = [last, currentrecursivesequence]; currentrecursivesequence = 0; } } tree.push(vm); vm = vm.$parent; } return '\n\nfound in\n\n' + tree .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (array.isarray(vm) ? ((formatcomponentname(vm[0])) + "... (" + (vm[1]) + " recursive calls)") : formatcomponentname(vm))); }) .join('\n') } else { return ("\n\n(found in " + (formatcomponentname(vm)) + ")") } }; } /* */ var uid = 0; /** * a dep is an observable that can have multiple * directives subscribing to it. */ var dep = function dep () { this.id = uid++; this.subs = []; }; dep.prototype.addsub = function addsub (sub) { this.subs.push(sub); }; dep.prototype.removesub = function removesub (sub) { remove(this.subs, sub); }; dep.prototype.depend = function depend () { if (dep.target) { dep.target.adddep(this); } }; dep.prototype.notify = function notify () { // stabilize the subscriber list first var subs = this.subs.slice(); if (!config.async) { // subs aren't sorted in scheduler if not running async // we need to sort them now to make sure they fire in correct // order subs.sort(function (a, b) { return a.id - b.id; }); } for (var i = 0, l = subs.length; i < l; i++) { subs[i].update(); } }; // the current target watcher being evaluated. // this is globally unique because only one watcher // can be evaluated at a time. dep.target = null; var targetstack = []; function pushtarget (target) { targetstack.push(target); dep.target = target; } function poptarget () { targetstack.pop(); dep.target = targetstack[targetstack.length - 1]; } /* */ var vnode = function vnode ( tag, data, children, text, elm, context, componentoptions, asyncfactory ) { this.tag = tag; this.data = data; this.children = children; this.text = text; this.elm = elm; this.ns = undefined; this.context = context; this.fncontext = undefined; this.fnoptions = undefined; this.fnscopeid = undefined; this.key = data && data.key; this.componentoptions = componentoptions; this.componentinstance = undefined; this.parent = undefined; this.raw = false; this.isstatic = false; this.isrootinsert = true; this.iscomment = false; this.iscloned = false; this.isonce = false; this.asyncfactory = asyncfactory; this.asyncmeta = undefined; this.isasyncplaceholder = false; }; var prototypeaccessors = { child: { configurable: true } }; // deprecated: alias for componentinstance for backwards compat. /* istanbul ignore next */ prototypeaccessors.child.get = function () { return this.componentinstance }; object.defineproperties( vnode.prototype, prototypeaccessors ); var createemptyvnode = function (text) { if ( text === void 0 ) text = ''; var node = new vnode(); node.text = text; node.iscomment = true; return node }; function createtextvnode (val) { return new vnode(undefined, undefined, undefined, string(val)) } // optimized shallow clone // 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) { var cloned = new vnode( vnode.tag, vnode.data, // #7975 // clone children array to avoid mutating original in case of cloning // a child. vnode.children && vnode.children.slice(), vnode.text, vnode.elm, vnode.context, vnode.componentoptions, vnode.asyncfactory ); cloned.ns = vnode.ns; cloned.isstatic = vnode.isstatic; cloned.key = vnode.key; cloned.iscomment = vnode.iscomment; cloned.fncontext = vnode.fncontext; cloned.fnoptions = vnode.fnoptions; cloned.fnscopeid = vnode.fnscopeid; cloned.asyncmeta = vnode.asyncmeta; cloned.iscloned = true; return cloned } /* * 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 methodstopatch = [ 'push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse' ]; /** * intercept mutating methods and emit events */ methodstopatch.foreach(function (method) { // cache original method var original = arrayproto[method]; def(arraymethods, method, function mutator () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; var result = original.apply(this, args); var ob = this.__ob__; var inserted; switch (method) { case 'push': case 'unshift': inserted = args; break case 'splice': inserted = args.slice(2); break } if (inserted) { ob.observearray(inserted); } // notify change ob.dep.notify(); return result }); }); /* */ var arraykeys = object.getownpropertynames(arraymethods); /** * in some cases we may want to disable observation inside a component's * update computation. */ var shouldobserve = true; function toggleobserving (value) { shouldobserve = value; } /** * 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 dispatch updates. */ var observer = function observer (value) { this.value = value; this.dep = new dep(); this.vmcount = 0; def(value, '__ob__', this); if (array.isarray(value)) { if (hasproto) { protoaugment(value, arraymethods); } else { copyaugment(value, arraymethods, arraykeys); } this.observearray(value); } else { this.walk(value); } }; /** * walk through all properties and convert them into * getter/setters. this method should only be called when * value type is object. */ observer.prototype.walk = function walk (obj) { var keys = object.keys(obj); for (var i = 0; i < keys.length; i++) { definereactive$$1(obj, keys[i]); } }; /** * observe a list of array items. */ observer.prototype.observearray = function observearray (items) { for (var i = 0, l = items.length; i < l; i++) { observe(items[i]); } }; // helpers /** * augment a target object or array by intercepting * the prototype chain using __proto__ */ function protoaugment (target, src) { /* eslint-disable no-proto */ target.__proto__ = src; /* eslint-enable no-proto */ } /** * augment a target object or array by defining * hidden properties. */ /* istanbul ignore next */ function copyaugment (target, src, keys) { for (var i = 0, l = keys.length; i < l; i++) { var key = keys[i]; def(target, key, src[key]); } } /** * attempt to create an observer instance for a value, * returns the new observer if successfully observed, * or the existing observer if the value already has one. */ function observe (value, asrootdata) { if (!isobject(value) || value instanceof vnode) { return } var ob; if (hasown(value, '__ob__') && value.__ob__ instanceof observer) { ob = value.__ob__; } else if ( shouldobserve && !isserverrendering() && (array.isarray(value) || isplainobject(value)) && object.isextensible(value) && !value._isvue ) { ob = new observer(value); } if (asrootdata && ob) { ob.vmcount++; } return ob } /** * define a reactive property on an object. */ function definereactive$$1 ( obj, key, val, customsetter, shallow ) { var dep = new dep(); var property = object.getownpropertydescriptor(obj, key); if (property && property.configurable === false) { return } // cater for pre-defined getter/setters var getter = property && property.get; var setter = property && property.set; if ((!getter || setter) && arguments.length === 2) { val = obj[key]; } var childob = !shallow && observe(val); object.defineproperty(obj, key, { enumerable: true, configurable: true, get: function reactivegetter () { var value = getter ? getter.call(obj) : val; if (dep.target) { dep.depend(); if (childob) { childob.dep.depend(); if (array.isarray(value)) { dependarray(value); } } } return value }, set: function reactivesetter (newval) { var value = getter ? getter.call(obj) : val; /* eslint-disable no-self-compare */ if (newval === value || (newval !== newval && value !== value)) { return } /* eslint-enable no-self-compare */ if (customsetter) { customsetter(); } // #7981: for accessor properties without setter if (getter && !setter) { return } if (setter) { setter.call(obj, newval); } else { val = newval; } childob = !shallow && observe(newval); dep.notify(); } }); } /** * set a property on an object. adds the new property and * triggers change notification if the property doesn't * already exist. */ function set (target, key, val) { if (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); return val } if (key in target && !(key in object.prototype)) { target[key] = val; return val } var ob = (target).__ob__; if (target._isvue || (ob && ob.vmcount)) { warn( 'avoid adding reactive properties to a vue instance or its root $data ' + 'at runtime - declare it upfront in the data option.' ); return val } if (!ob) { target[key] = val; return val } definereactive$$1(ob.value, key, val); ob.dep.notify(); return val } /** * delete a property and trigger change if necessary. */ function del (target, key) { if (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 } var ob = (target).__ob__; if (target._isvue || (ob && ob.vmcount)) { warn( 'avoid deleting properties on a vue instance or its root $data ' + '- just set it to null.' ); return } if (!hasown(target, key)) { return } delete target[key]; if (!ob) { return } ob.dep.notify(); } /** * collect dependencies on array elements when the array is touched, since * we cannot intercept array element access like property getters. */ function dependarray (value) { for (var e = (void 0), i = 0, l = value.length; i < l; i++) { e = value[i]; e && e.__ob__ && e.__ob__.dep.depend(); if (array.isarray(e)) { dependarray(e); } } } /* */ /** * option overwriting strategies are functions that handle * how to merge a parent option value and a child option * value into the final value. */ var strats = config.optionmergestrategies; /** * options with restrictions */ { strats.el = strats.propsdata = function (parent, child, vm, key) { if (!vm) { warn( "option \"" + key + "\" can only be used during instance " + 'creation with the `new` keyword.' ); } return defaultstrat(parent, child) }; } /** * helper that recursively merges two data objects together. */ function mergedata (to, from) { if (!from) { return to } var key, toval, fromval; var keys = hassymbol ? reflect.ownkeys(from) : object.keys(from); for (var i = 0; i < keys.length; i++) { key = keys[i]; // in case the object is already observed... if (key === '__ob__') { continue } toval = to[key]; fromval = from[key]; if (!hasown(to, key)) { set(to, key, fromval); } else if ( toval !== fromval && isplainobject(toval) && isplainobject(fromval) ) { mergedata(toval, fromval); } } return to } /** * data */ function mergedataorfn ( parentval, childval, vm ) { if (!vm) { // in a vue.extend merge, both should be functions if (!childval) { return parentval } if (!parentval) { return childval } // when parentval & childval are both present, // we need to return a function that returns the // merged result of both functions... no need to // check if parentval is a function here because // it has to be a function to pass previous merges. return function mergeddatafn () { return mergedata( typeof childval === 'function' ? childval.call(this, this) : childval, typeof parentval === 'function' ? parentval.call(this, this) : parentval ) } } else { return function mergedinstancedatafn () { // instance merge var instancedata = typeof childval === 'function' ? childval.call(vm, vm) : childval; var defaultdata = typeof parentval === 'function' ? parentval.call(vm, vm) : parentval; if (instancedata) { return mergedata(instancedata, defaultdata) } else { return defaultdata } } } } strats.data = function ( parentval, childval, vm ) { if (!vm) { if (childval && typeof childval !== 'function') { warn( 'the "data" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.', vm ); return parentval } return mergedataorfn(parentval, childval) } return mergedataorfn(parentval, childval, vm) }; /** * hooks and props are merged as arrays. */ function mergehook ( parentval, childval ) { var res = childval ? parentval ? parentval.concat(childval) : array.isarray(childval) ? childval : [childval] : parentval; return res ? dedupehooks(res) : res } function dedupehooks (hooks) { var res = []; for (var i = 0; i < hooks.length; i++) { if (res.indexof(hooks[i]) === -1) { res.push(hooks[i]); } } return res } lifecycle_hooks.foreach(function (hook) { strats[hook] = mergehook; }); /** * assets * * when a vm is present (instance creation), we need to do * a three-way merge between constructor options, instance * options and parent options. */ function mergeassets ( parentval, childval, vm, key ) { var res = object.create(parentval || null); if (childval) { assertobjecttype(key, childval, vm); return extend(res, childval) } else { return res } } asset_types.foreach(function (type) { strats[type + 's'] = mergeassets; }); /** * watchers. * * watchers hashes should not overwrite one * another, so we merge them as arrays. */ strats.watch = function ( parentval, childval, vm, key ) { // work around firefox's object.prototype.watch... if (parentval === nativewatch) { parentval = undefined; } if (childval === nativewatch) { childval = undefined; } /* istanbul ignore if */ if (!childval) { return object.create(parentval || null) } { assertobjecttype(key, childval, vm); } if (!parentval) { return childval } var ret = {}; extend(ret, parentval); for (var key$1 in childval) { var parent = ret[key$1]; var child = childval[key$1]; if (parent && !array.isarray(parent)) { parent = [parent]; } ret[key$1] = parent ? parent.concat(child) : array.isarray(child) ? child : [child]; } return ret }; /** * other object hashes. */ strats.props = strats.methods = strats.inject = strats.computed = function ( parentval, childval, vm, key ) { if (childval && "development" !== 'production') { assertobjecttype(key, childval, vm); } if (!parentval) { return childval } var ret = object.create(null); extend(ret, parentval); if (childval) { extend(ret, childval); } return ret }; strats.provide = mergedataorfn; /** * default strategy. */ var defaultstrat = function (parentval, childval) { return childval === undefined ? parentval : childval }; /** * validate component names */ function checkcomponents (options) { for (var key in options.components) { validatecomponentname(key); } } function validatecomponentname (name) { if (!new regexp(("^[a-za-z][\\-\\.0-9_" + (unicoderegexp.source) + "]*$")).test(name)) { warn( 'invalid component name: "' + name + '". component names ' + 'should conform to valid custom element name in html5 specification.' ); } if (isbuiltintag(name) || config.isreservedtag(name)) { warn( 'do not use built-in or reserved html elements as component ' + 'id: ' + name ); } } /** * ensure all props option syntax are normalized into the * object-based format. */ function normalizeprops (options, vm) { var props = options.props; if (!props) { return } var res = {}; var i, val, name; if (array.isarray(props)) { i = props.length; while (i--) { val = props[i]; if (typeof val === 'string') { name = camelize(val); res[name] = { type: null }; } else { warn('props must be strings when using array syntax.'); } } } else if (isplainobject(props)) { for (var key in props) { val = props[key]; name = camelize(key); res[name] = isplainobject(val) ? val : { type: val }; } } else { warn( "invalid value for option \"props\": expected an array or an object, " + "but got " + (torawtype(props)) + ".", vm ); } options.props = res; } /** * normalize all injections into object-based format */ function normalizeinject (options, vm) { var inject = options.inject; if (!inject) { return } var normalized = options.inject = {}; if (array.isarray(inject)) { for (var i = 0; i < inject.length; i++) { normalized[inject[i]] = { from: inject[i] }; } } else if (isplainobject(inject)) { for (var key in inject) { var val = inject[key]; normalized[key] = isplainobject(val) ? extend({ from: key }, val) : { from: val }; } } else { warn( "invalid value for option \"inject\": expected an array or an object, " + "but got " + (torawtype(inject)) + ".", vm ); } } /** * normalize raw function directives into object format. */ function normalizedirectives (options) { var dirs = options.directives; if (dirs) { for (var key in dirs) { var def$$1 = dirs[key]; if (typeof def$$1 === 'function') { dirs[key] = { bind: def$$1, update: def$$1 }; } } } } function assertobjecttype (name, value, vm) { if (!isplainobject(value)) { warn( "invalid value for option \"" + name + "\": expected an object, " + "but got " + (torawtype(value)) + ".", vm ); } } /** * merge two option objects into a new one. * core utility used in both instantiation and inheritance. */ function mergeoptions ( parent, child, vm ) { { checkcomponents(child); } if (typeof child === 'function') { child = child.options; } normalizeprops(child, vm); normalizeinject(child, vm); normalizedirectives(child); // apply extends and mixins on the child options, // but only if it is a raw options object that isn't // the result of another mergeoptions call. // only merged options has the _base property. if (!child._base) { if (child.extends) { parent = mergeoptions(parent, child.extends, vm); } if (child.mixins) { for (var i = 0, l = child.mixins.length; i < l; i++) { parent = mergeoptions(parent, child.mixins[i], vm); } } } var options = {}; var key; for (key in parent) { mergefield(key); } for (key in child) { if (!hasown(parent, key)) { mergefield(key); } } function mergefield (key) { var strat = strats[key] || defaultstrat; options[key] = strat(parent[key], child[key], vm, key); } return options } /** * resolve an asset. * this function is used because child instances need access * to assets defined in its ancestor chain. */ function resolveasset ( options, type, id, warnmissing ) { /* istanbul ignore if */ if (typeof id !== 'string') { return } var assets = options[type]; // check local registration variations first if (hasown(assets, id)) { return assets[id] } var camelizedid = camelize(id); if (hasown(assets, camelizedid)) { return assets[camelizedid] } var pascalcaseid = capitalize(camelizedid); if (hasown(assets, pascalcaseid)) { return assets[pascalcaseid] } // fallback to prototype chain var res = assets[id] || assets[camelizedid] || assets[pascalcaseid]; if (warnmissing && !res) { warn( 'failed to resolve ' + type.slice(0, -1) + ': ' + id, options ); } return res } /* */ function validateprop ( key, propoptions, propsdata, vm ) { var prop = propoptions[key]; var absent = !hasown(propsdata, key); var value = propsdata[key]; // boolean casting var booleanindex = gettypeindex(boolean, prop.type); if (booleanindex > -1) { if (absent && !hasown(prop, 'default')) { value = false; } 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 prevshouldobserve = shouldobserve; toggleobserving(true); observe(value); toggleobserving(prevshouldobserve); } { assertprop(prop, key, value, vm, absent); } return value } /** * get the default value of a prop. */ function getpropdefaultvalue (vm, prop, key) { // no default, return undefined if (!hasown(prop, 'default')) { return undefined } var def = prop.default; // warn against non-factory defaults for object & array if (isobject(def)) { warn( 'invalid default value for prop "' + key + '": ' + 'props with type object/array must use a factory function ' + 'to return the default value.', vm ); } // the raw prop value was also undefined from previous render, // return previous default value to avoid unnecessary watcher trigger if (vm && vm.$options.propsdata && vm.$options.propsdata[key] === undefined && vm._props[key] !== undefined ) { return vm._props[key] } // call factory function for non-function types // a value is function if its prototype is function even across different execution context return typeof def === 'function' && gettype(prop.type) !== 'function' ? def.call(vm) : def } /** * assert whether a prop is valid. */ function assertprop ( prop, name, value, vm, absent ) { if (prop.required && absent) { warn( 'missing required prop: "' + name + '"', vm ); return } if (value == null && !prop.required) { return } var type = prop.type; var valid = !type || type === true; var expectedtypes = []; if (type) { if (!array.isarray(type)) { type = [type]; } for (var i = 0; i < type.length && !valid; i++) { var assertedtype = asserttype(value, type[i]); expectedtypes.push(assertedtype.expectedtype || ''); valid = assertedtype.valid; } } if (!valid) { warn( getinvalidtypemessage(name, value, expectedtypes), vm ); return } var validator = prop.validator; if (validator) { if (!validator(value)) { warn( 'invalid prop: custom validator check failed for prop "' + name + '".', vm ); } } } var simplecheckre = /^(string|number|boolean|function|symbol)$/; function asserttype (value, type) { var valid; var expectedtype = gettype(type); if (simplecheckre.test(expectedtype)) { var t = typeof value; valid = t === expectedtype.tolowercase(); // for primitive wrapper objects if (!valid && t === 'object') { valid = value instanceof type; } } else if (expectedtype === 'object') { valid = isplainobject(value); } else if (expectedtype === 'array') { valid = array.isarray(value); } else { valid = value instanceof type; } return { valid: valid, expectedtype: expectedtype } } /** * use function string name to check built-in types, * because a simple equality check will fail when running * across different vms / iframes. */ function gettype (fn) { var match = fn && fn.tostring().match(/^\s*function (\w+)/); return match ? match[1] : '' } 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 = expectedtypes.length; i < len; i++) { if (issametype(expectedtypes[i], type)) { return i } } return -1 } function getinvalidtypemessage (name, value, expectedtypes) { var message = "invalid prop: type check failed for prop \"" + name + "\"." + " expected " + (expectedtypes.map(capitalize).join(', ')); var expectedtype = expectedtypes[0]; var receivedtype = torawtype(value); var expectedvalue = stylevalue(value, expectedtype); var receivedvalue = stylevalue(value, receivedtype); // check if we need to specify expected value if (expectedtypes.length === 1 && isexplicable(expectedtype) && !isboolean(expectedtype, receivedtype)) { message += " with value " + expectedvalue; } message += ", got " + receivedtype + " "; // check if we need to specify received value if (isexplicable(receivedtype)) { message += "with value " + receivedvalue + "."; } return message } function stylevalue (value, type) { if (type === 'string') { return ("\"" + value + "\"") } else if (type === 'number') { return ("" + (number(value))) } else { return ("" + value) } } function isexplicable (value) { var explicittypes = ['string', 'number', 'boolean']; return explicittypes.some(function (elem) { return value.tolowercase() === elem; }) } function isboolean () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; return args.some(function (elem) { return elem.tolowercase() === 'boolean'; }) } /* */ function handleerror (err, vm, info) { // deactivate deps tracking while processing error handler to avoid possible infinite rendering. pushtarget(); try { if (vm) { var cur = vm; while ((cur = cur.$parent)) { var hooks = cur.$options.errorcaptured; if (hooks) { for (var i = 0; i < hooks.length; i++) { try { var capture = hooks[i].call(cur, err, vm, info) === false; if (capture) { return } } catch (e) { globalhandleerror(e, cur, 'errorcaptured hook'); } } } } } globalhandleerror(err, vm, info); } finally { poptarget(); } } function invokewitherrorhandling ( handler, context, args, vm, info ) { var res; try { res = args ? handler.apply(context, args) : handler.call(context); if (res && !res._isvue && ispromise(res) && !res._handled) { res.catch(function (e) { return handleerror(e, vm, info + " (promise/async)"); }); // issue #9511 // avoid catch triggering multiple times when nested calls res._handled = true; } } catch (e) { handleerror(e, vm, info); } return res } function globalhandleerror (err, vm, info) { if (config.errorhandler) { try { return config.errorhandler.call(null, err, vm, info) } catch (e) { // if the user intentionally throws the original error in the handler, // do not log it twice if (e !== err) { logerror(e, null, 'config.errorhandler'); } } } logerror(err, vm, info); } function logerror (err, vm, info) { { warn(("error in " + info + ": \"" + (err.tostring()) + "\""), vm); } /* istanbul ignore else */ if ((inbrowser || inweex) && typeof console !== 'undefined') { console.error(err); } else { throw err } } /* */ var isusingmicrotask = false; var callbacks = []; var pending = false; function flushcallbacks () { pending = false; var copies = callbacks.slice(0); callbacks.length = 0; for (var i = 0; i < copies.length; i++) { copies[i](); } } // here we have async deferring wrappers using microtasks. // in 2.5 we used (macro) tasks (in combination with microtasks). // however, it has subtle problems when state is changed right before repaint // (e.g. #6813, out-in transitions). // also, using (macro) tasks in event handler would cause some weird behaviors // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109). // so we now use microtasks everywhere, again. // a major drawback of this tradeoff is that there are some scenarios // where microtasks have too high a priority and fire in between supposedly // sequential events (e.g. #4521, #6690, which have workarounds) // or even between bubbling of the same event (#6566). var timerfunc; // the nexttick behavior leverages the microtask queue, which can be accessed // via either native promise.then or mutationobserver. // mutationobserver has wider support, however it is seriously bugged in // uiwebview in ios >= 9.3.3 when triggered in touch event handlers. it // completely stops working after triggering a few times... so, if native // promise is available, we will use it: /* istanbul ignore next, $flow-disable-line */ if (typeof promise !== 'undefined' && isnative(promise)) { var p = promise.resolve(); timerfunc = function () { p.then(flushcallbacks); // in problematic uiwebviews, promise.then doesn't completely break, but // it can get stuck in a weird state where callbacks are pushed into the // microtask queue but the queue isn't being flushed, until the browser // needs to do some other work, e.g. handle a timer. therefore we can // "force" the microtask queue to be flushed by adding an empty timer. if (isios) { settimeout(noop); } }; isusingmicrotask = true; } else if (!isie && typeof mutationobserver !== 'undefined' && ( isnative(mutationobserver) || // phantomjs and ios 7.x mutationobserver.tostring() === '[object mutationobserverconstructor]' )) { // use mutationobserver where native promise is not available, // e.g. phantomjs, ios7, android 4.4 // (#6466 mutationobserver is unreliable in ie11) var counter = 1; var observer = new mutationobserver(flushcallbacks); var textnode = document.createtextnode(string(counter)); observer.observe(textnode, { characterdata: true }); timerfunc = function () { counter = (counter + 1) % 2; textnode.data = string(counter); }; isusingmicrotask = true; } else if (typeof setimmediate !== 'undefined' && isnative(setimmediate)) { // fallback to setimmediate. // techinically it leverages the (macro) task queue, // but it is still a better choice than settimeout. timerfunc = function () { setimmediate(flushcallbacks); }; } else { // fallback to settimeout. timerfunc = function () { settimeout(flushcallbacks, 0); }; } function nexttick (cb, ctx) { var _resolve; callbacks.push(function () { if (cb) { try { cb.call(ctx); } catch (e) { handleerror(e, ctx, 'nexttick'); } } else if (_resolve) { _resolve(ctx); } }); if (!pending) { pending = true; timerfunc(); } // $flow-disable-line if (!cb && typeof promise !== 'undefined') { return new promise(function (resolve) { _resolve = resolve; }) } } /* */ var mark; var measure; { var perf = inbrowser && window.performance; /* istanbul ignore if */ if ( perf && perf.mark && perf.measure && perf.clearmarks && perf.clearmeasures ) { mark = function (tag) { return perf.mark(tag); }; measure = function (name, starttag, endtag) { perf.measure(name, starttag, endtag); perf.clearmarks(starttag); perf.clearmarks(endtag); // perf.clearmeasures(name) }; } } /* not type checking this file because flow doesn't play well with proxy */ var initproxy; { var allowedglobals = makemap( 'infinity,undefined,nan,isfinite,isnan,' + 'parsefloat,parseint,decodeuri,decodeuricomponent,encodeuri,encodeuricomponent,' + 'math,number,date,array,object,boolean,string,regexp,map,set,json,intl,' + 'require' // for webpack/browserify ); var warnnonpresent = function (target, key) { warn( "property or method \"" + key + "\" is not defined on the instance but " + 'referenced during render. make sure that this property is reactive, ' + 'either in the data option, or for class-based components, by ' + 'initializing the property. ' + 'see: ', target ); }; var warnreservedprefix = function (target, key) { warn( "property \"" + key + "\" must be accessed with \"$data." + key + "\" because " + 'properties starting with "$" or "_" are not proxied in the vue instance to ' + 'prevent conflicts with vue internals' + 'see: ', target ); }; var hasproxy = typeof proxy !== 'undefined' && isnative(proxy); if (hasproxy) { var isbuiltinmodifier = makemap('stop,prevent,self,ctrl,shift,alt,meta,exact'); config.keycodes = new proxy(config.keycodes, { set: function set (target, key, value) { if (isbuiltinmodifier(key)) { warn(("avoid overwriting built-in modifier in config.keycodes: ." + key)); return false } else { target[key] = value; return true } } }); } var hashandler = { has: function has (target, key) { var has = key in target; var isallowed = allowedglobals(key) || (typeof key === 'string' && key.charat(0) === '_' && !(key in target.$data)); if (!has && !isallowed) { if (key in target.$data) { warnreservedprefix(target, key); } else { warnnonpresent(target, key); } } return has || !isallowed } }; var gethandler = { get: function get (target, key) { if (typeof key === 'string' && !(key in target)) { if (key in target.$data) { warnreservedprefix(target, key); } else { warnnonpresent(target, key); } } return target[key] } }; initproxy = function initproxy (vm) { if (hasproxy) { // determine which proxy handler to use var options = vm.$options; var handlers = options.render && options.render._withstripped ? gethandler : hashandler; vm._renderproxy = new proxy(vm, handlers); } else { vm._renderproxy = vm; } }; } /* */ var seenobjects = new _set(); /** * recursively traverse an object to evoke all converted * getters, so that every nested property inside the object * is collected as a "deep" dependency. */ function traverse (val) { _traverse(val, seenobjects); seenobjects.clear(); } function _traverse (val, seen) { var i, keys; var isa = array.isarray(val); if ((!isa && !isobject(val)) || object.isfrozen(val) || val instanceof vnode) { return } if (val.__ob__) { var depid = val.__ob__.dep.id; if (seen.has(depid)) { return } seen.add(depid); } if (isa) { i = val.length; while (i--) { _traverse(val[i], seen); } } else { keys = object.keys(val); i = keys.length; while (i--) { _traverse(val[keys[i]], seen); } } } /* */ var normalizeevent = cached(function (name) { var passive = name.charat(0) === '&'; name = passive ? name.slice(1) : name; var once$$1 = name.charat(0) === '~'; // prefixed last, checked first name = once$$1 ? name.slice(1) : name; var capture = name.charat(0) === '!'; name = capture ? name.slice(1) : name; return { name: name, once: once$$1, capture: capture, passive: passive } }); function createfninvoker (fns, vm) { function invoker () { var arguments$1 = arguments; var fns = invoker.fns; if (array.isarray(fns)) { var cloned = fns.slice(); for (var i = 0; i < cloned.length; i++) { invokewitherrorhandling(cloned[i], null, arguments$1, vm, "v-on handler"); } } else { // return handler return value for single handlers return invokewitherrorhandling(fns, null, arguments, vm, "v-on handler") } } invoker.fns = fns; return invoker } function updatelisteners ( on, oldon, add, remove$$1, createoncehandler, vm ) { var name, def$$1, cur, old, event; for (name in on) { def$$1 = cur = on[name]; old = oldon[name]; event = normalizeevent(name); if (isundef(cur)) { warn( "invalid handler for event \"" + (event.name) + "\": got " + string(cur), vm ); } else if (isundef(old)) { if (isundef(cur.fns)) { cur = on[name] = createfninvoker(cur, vm); } if (istrue(event.once)) { cur = on[name] = createoncehandler(event.name, cur, event.capture); } add(event.name, cur, event.capture, event.passive, event.params); } else if (cur !== old) { old.fns = cur; on[name] = old; } } for (name in oldon) { if (isundef(on[name])) { event = normalizeevent(name); remove$$1(event.name, oldon[name], event.capture); } } } /* */ function mergevnodehook (def, hookkey, hook) { if (def instanceof vnode) { def = def.data.hook || (def.data.hook = {}); } var invoker; var oldhook = def[hookkey]; function wrappedhook () { hook.apply(this, arguments); // important: remove merged hook to ensure it's called only once // and prevent memory leak remove(invoker.fns, wrappedhook); } if (isundef(oldhook)) { // no existing hook invoker = createfninvoker([wrappedhook]); } else { /* istanbul ignore if */ if (isdef(oldhook.fns) && istrue(oldhook.merged)) { // already a merged invoker invoker = oldhook; invoker.fns.push(wrappedhook); } else { // existing plain hook invoker = createfninvoker([oldhook, wrappedhook]); } } invoker.merged = true; def[hookkey] = invoker; } /* */ function extractpropsfromvnodedata ( data, ctor, tag ) { // we are only extracting raw values here. // validation and default values are handled in the child // component itself. var propoptions = ctor.options.props; if (isundef(propoptions)) { return } var res = {}; var attrs = data.attrs; var props = data.props; if (isdef(attrs) || isdef(props)) { for (var key in propoptions) { var altkey = hyphenate(key); { var keyinlowercase = key.tolowercase(); if ( key !== keyinlowercase && attrs && hasown(attrs, keyinlowercase) ) { tip( "prop \"" + keyinlowercase + "\" is passed to component " + (formatcomponentname(tag || ctor)) + ", but the declared prop name is" + " \"" + key + "\". " + "note that html attributes are case-insensitive and camelcased " + "props need to use their kebab-case equivalents when using in-dom " + "templates. you should probably use \"" + altkey + "\" instead of \"" + key + "\"." ); } } checkprop(res, props, key, altkey, true) || checkprop(res, attrs, key, altkey, false); } } return res } function checkprop ( res, hash, key, altkey, preserve ) { if (isdef(hash)) { if (hasown(hash, key)) { res[key] = hash[key]; if (!preserve) { delete hash[key]; } return true } else if (hasown(hash, altkey)) { res[key] = hash[altkey]; if (!preserve) { delete hash[altkey]; } return true } } return false } /* */ // the template compiler attempts to minimize the need for normalization by // statically analyzing the template at compile time. // // for plain html markup, normalization can be completely skipped because the // generated render function is guaranteed to return array. there are // two cases where extra normalization is needed: // 1. when the children contains components - because a functional component // may return an array instead of a single root. in this case, just a simple // normalization is needed - if any child is an array, we flatten the whole // thing with array.prototype.concat. it is guaranteed to be only 1-level deep // because functional components already normalize their own children. function simplenormalizechildren (children) { for (var i = 0; i < children.length; i++) { if (array.isarray(children[i])) { return array.prototype.concat.apply([], children) } } return children } // 2. when the children contains constructs that always generated nested arrays, // e.g.