You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8495 lines
223 KiB

2 months ago
  1. /*!
  2. * Vue.js v2.6.14
  3. * (c) 2014-2021 Evan You
  4. * Released under the MIT License.
  5. */
  6. /* */
  7. var emptyObject = Object.freeze({});
  8. // These helpers produce better VM code in JS engines due to their
  9. // explicitness and function inlining.
  10. function isUndef (v) {
  11. return v === undefined || v === null
  12. }
  13. function isDef (v) {
  14. return v !== undefined && v !== null
  15. }
  16. function isTrue (v) {
  17. return v === true
  18. }
  19. function isFalse (v) {
  20. return v === false
  21. }
  22. /**
  23. * Check if value is primitive.
  24. */
  25. function isPrimitive (value) {
  26. return (
  27. typeof value === 'string' ||
  28. typeof value === 'number' ||
  29. // $flow-disable-line
  30. typeof value === 'symbol' ||
  31. typeof value === 'boolean'
  32. )
  33. }
  34. /**
  35. * Quick object check - this is primarily used to tell
  36. * Objects from primitive values when we know the value
  37. * is a JSON-compliant type.
  38. */
  39. function isObject (obj) {
  40. return obj !== null && typeof obj === 'object'
  41. }
  42. /**
  43. * Get the raw type string of a value, e.g., [object Object].
  44. */
  45. var _toString = Object.prototype.toString;
  46. function toRawType (value) {
  47. return _toString.call(value).slice(8, -1)
  48. }
  49. /**
  50. * Strict object type check. Only returns true
  51. * for plain JavaScript objects.
  52. */
  53. function isPlainObject (obj) {
  54. return _toString.call(obj) === '[object Object]'
  55. }
  56. function isRegExp (v) {
  57. return _toString.call(v) === '[object RegExp]'
  58. }
  59. /**
  60. * Check if val is a valid array index.
  61. */
  62. function isValidArrayIndex (val) {
  63. var n = parseFloat(String(val));
  64. return n >= 0 && Math.floor(n) === n && isFinite(val)
  65. }
  66. function isPromise (val) {
  67. return (
  68. isDef(val) &&
  69. typeof val.then === 'function' &&
  70. typeof val.catch === 'function'
  71. )
  72. }
  73. /**
  74. * Convert a value to a string that is actually rendered.
  75. */
  76. function toString (val) {
  77. return val == null
  78. ? ''
  79. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  80. ? JSON.stringify(val, null, 2)
  81. : String(val)
  82. }
  83. /**
  84. * Convert an input value to a number for persistence.
  85. * If the conversion fails, return original string.
  86. */
  87. function toNumber (val) {
  88. var n = parseFloat(val);
  89. return isNaN(n) ? val : n
  90. }
  91. /**
  92. * Make a map and return a function for checking if a key
  93. * is in that map.
  94. */
  95. function makeMap (
  96. str,
  97. expectsLowerCase
  98. ) {
  99. var map = Object.create(null);
  100. var list = str.split(',');
  101. for (var i = 0; i < list.length; i++) {
  102. map[list[i]] = true;
  103. }
  104. return expectsLowerCase
  105. ? function (val) { return map[val.toLowerCase()]; }
  106. : function (val) { return map[val]; }
  107. }
  108. /**
  109. * Check if a tag is a built-in tag.
  110. */
  111. var isBuiltInTag = makeMap('slot,component', true);
  112. /**
  113. * Check if an attribute is a reserved attribute.
  114. */
  115. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  116. /**
  117. * Remove an item from an array.
  118. */
  119. function remove (arr, item) {
  120. if (arr.length) {
  121. var index = arr.indexOf(item);
  122. if (index > -1) {
  123. return arr.splice(index, 1)
  124. }
  125. }
  126. }
  127. /**
  128. * Check whether an object has the property.
  129. */
  130. var hasOwnProperty = Object.prototype.hasOwnProperty;
  131. function hasOwn (obj, key) {
  132. return hasOwnProperty.call(obj, key)
  133. }
  134. /**
  135. * Create a cached version of a pure function.
  136. */
  137. function cached (fn) {
  138. var cache = Object.create(null);
  139. return (function cachedFn (str) {
  140. var hit = cache[str];
  141. return hit || (cache[str] = fn(str))
  142. })
  143. }
  144. /**
  145. * Camelize a hyphen-delimited string.
  146. */
  147. var camelizeRE = /-(\w)/g;
  148. var camelize = cached(function (str) {
  149. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  150. });
  151. /**
  152. * Capitalize a string.
  153. */
  154. var capitalize = cached(function (str) {
  155. return str.charAt(0).toUpperCase() + str.slice(1)
  156. });
  157. /**
  158. * Hyphenate a camelCase string.
  159. */
  160. var hyphenateRE = /\B([A-Z])/g;
  161. var hyphenate = cached(function (str) {
  162. return str.replace(hyphenateRE, '-$1').toLowerCase()
  163. });
  164. /**
  165. * Simple bind polyfill for environments that do not support it,
  166. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  167. * since native bind is now performant enough in most browsers.
  168. * But removing it would mean breaking code that was able to run in
  169. * PhantomJS 1.x, so this must be kept for backward compatibility.
  170. */
  171. /* istanbul ignore next */
  172. function polyfillBind (fn, ctx) {
  173. function boundFn (a) {
  174. var l = arguments.length;
  175. return l
  176. ? l > 1
  177. ? fn.apply(ctx, arguments)
  178. : fn.call(ctx, a)
  179. : fn.call(ctx)
  180. }
  181. boundFn._length = fn.length;
  182. return boundFn
  183. }
  184. function nativeBind (fn, ctx) {
  185. return fn.bind(ctx)
  186. }
  187. var bind = Function.prototype.bind
  188. ? nativeBind
  189. : polyfillBind;
  190. /**
  191. * Convert an Array-like object to a real Array.
  192. */
  193. function toArray (list, start) {
  194. start = start || 0;
  195. var i = list.length - start;
  196. var ret = new Array(i);
  197. while (i--) {
  198. ret[i] = list[i + start];
  199. }
  200. return ret
  201. }
  202. /**
  203. * Mix properties into target object.
  204. */
  205. function extend (to, _from) {
  206. for (var key in _from) {
  207. to[key] = _from[key];
  208. }
  209. return to
  210. }
  211. /**
  212. * Merge an Array of Objects into a single Object.
  213. */
  214. function toObject (arr) {
  215. var res = {};
  216. for (var i = 0; i < arr.length; i++) {
  217. if (arr[i]) {
  218. extend(res, arr[i]);
  219. }
  220. }
  221. return res
  222. }
  223. /* eslint-disable no-unused-vars */
  224. /**
  225. * Perform no operation.
  226. * Stubbing args to make Flow happy without leaving useless transpiled code
  227. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  228. */
  229. function noop (a, b, c) {}
  230. /**
  231. * Always return false.
  232. */
  233. var no = function (a, b, c) { return false; };
  234. /* eslint-enable no-unused-vars */
  235. /**
  236. * Return the same value.
  237. */
  238. var identity = function (_) { return _; };
  239. /**
  240. * Check if two values are loosely equal - that is,
  241. * if they are plain objects, do they have the same shape?
  242. */
  243. function looseEqual (a, b) {
  244. if (a === b) { return true }
  245. var isObjectA = isObject(a);
  246. var isObjectB = isObject(b);
  247. if (isObjectA && isObjectB) {
  248. try {
  249. var isArrayA = Array.isArray(a);
  250. var isArrayB = Array.isArray(b);
  251. if (isArrayA && isArrayB) {
  252. return a.length === b.length && a.every(function (e, i) {
  253. return looseEqual(e, b[i])
  254. })
  255. } else if (a instanceof Date && b instanceof Date) {
  256. return a.getTime() === b.getTime()
  257. } else if (!isArrayA && !isArrayB) {
  258. var keysA = Object.keys(a);
  259. var keysB = Object.keys(b);
  260. return keysA.length === keysB.length && keysA.every(function (key) {
  261. return looseEqual(a[key], b[key])
  262. })
  263. } else {
  264. /* istanbul ignore next */
  265. return false
  266. }
  267. } catch (e) {
  268. /* istanbul ignore next */
  269. return false
  270. }
  271. } else if (!isObjectA && !isObjectB) {
  272. return String(a) === String(b)
  273. } else {
  274. return false
  275. }
  276. }
  277. /**
  278. * Return the first index at which a loosely equal value can be
  279. * found in the array (if value is a plain object, the array must
  280. * contain an object of the same shape), or -1 if it is not present.
  281. */
  282. function looseIndexOf (arr, val) {
  283. for (var i = 0; i < arr.length; i++) {
  284. if (looseEqual(arr[i], val)) { return i }
  285. }
  286. return -1
  287. }
  288. /**
  289. * Ensure a function is called only once.
  290. */
  291. function once (fn) {
  292. var called = false;
  293. return function () {
  294. if (!called) {
  295. called = true;
  296. fn.apply(this, arguments);
  297. }
  298. }
  299. }
  300. var SSR_ATTR = 'data-server-rendered';
  301. var ASSET_TYPES = [
  302. 'component',
  303. 'directive',
  304. 'filter'
  305. ];
  306. var LIFECYCLE_HOOKS = [
  307. 'beforeCreate',
  308. 'created',
  309. 'beforeMount',
  310. 'mounted',
  311. 'beforeUpdate',
  312. 'updated',
  313. 'beforeDestroy',
  314. 'destroyed',
  315. 'activated',
  316. 'deactivated',
  317. 'errorCaptured',
  318. 'serverPrefetch'
  319. ];
  320. /* */
  321. var config = ({
  322. /**
  323. * Option merge strategies (used in core/util/options)
  324. */
  325. // $flow-disable-line
  326. optionMergeStrategies: Object.create(null),
  327. /**
  328. * Whether to suppress warnings.
  329. */
  330. silent: false,
  331. /**
  332. * Show production mode tip message on boot?
  333. */
  334. productionTip: process.env.NODE_ENV !== 'production',
  335. /**
  336. * Whether to enable devtools
  337. */
  338. devtools: process.env.NODE_ENV !== 'production',
  339. /**
  340. * Whether to record perf
  341. */
  342. performance: false,
  343. /**
  344. * Error handler for watcher errors
  345. */
  346. errorHandler: null,
  347. /**
  348. * Warn handler for watcher warns
  349. */
  350. warnHandler: null,
  351. /**
  352. * Ignore certain custom elements
  353. */
  354. ignoredElements: [],
  355. /**
  356. * Custom user key aliases for v-on
  357. */
  358. // $flow-disable-line
  359. keyCodes: Object.create(null),
  360. /**
  361. * Check if a tag is reserved so that it cannot be registered as a
  362. * component. This is platform-dependent and may be overwritten.
  363. */
  364. isReservedTag: no,
  365. /**
  366. * Check if an attribute is reserved so that it cannot be used as a component
  367. * prop. This is platform-dependent and may be overwritten.
  368. */
  369. isReservedAttr: no,
  370. /**
  371. * Check if a tag is an unknown element.
  372. * Platform-dependent.
  373. */
  374. isUnknownElement: no,
  375. /**
  376. * Get the namespace of an element
  377. */
  378. getTagNamespace: noop,
  379. /**
  380. * Parse the real tag name for the specific platform.
  381. */
  382. parsePlatformTagName: identity,
  383. /**
  384. * Check if an attribute must be bound using property, e.g. value
  385. * Platform-dependent.
  386. */
  387. mustUseProp: no,
  388. /**
  389. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  390. * This will significantly reduce performance if set to false.
  391. */
  392. async: true,
  393. /**
  394. * Exposed for legacy reasons
  395. */
  396. _lifecycleHooks: LIFECYCLE_HOOKS
  397. });
  398. /* */
  399. /**
  400. * unicode letters used for parsing html tags, component names and property paths.
  401. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  402. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  403. */
  404. 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/;
  405. /**
  406. * Check if a string starts with $ or _
  407. */
  408. function isReserved (str) {
  409. var c = (str + '').charCodeAt(0);
  410. return c === 0x24 || c === 0x5F
  411. }
  412. /**
  413. * Define a property.
  414. */
  415. function def (obj, key, val, enumerable) {
  416. Object.defineProperty(obj, key, {
  417. value: val,
  418. enumerable: !!enumerable,
  419. writable: true,
  420. configurable: true
  421. });
  422. }
  423. /**
  424. * Parse simple path.
  425. */
  426. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  427. function parsePath (path) {
  428. if (bailRE.test(path)) {
  429. return
  430. }
  431. var segments = path.split('.');
  432. return function (obj) {
  433. for (var i = 0; i < segments.length; i++) {
  434. if (!obj) { return }
  435. obj = obj[segments[i]];
  436. }
  437. return obj
  438. }
  439. }
  440. /* */
  441. // can we use __proto__?
  442. var hasProto = '__proto__' in {};
  443. // Browser environment sniffing
  444. var inBrowser = typeof window !== 'undefined';
  445. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  446. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  447. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  448. var isIE = UA && /msie|trident/.test(UA);
  449. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  450. var isEdge = UA && UA.indexOf('edge/') > 0;
  451. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  452. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  453. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  454. var isPhantomJS = UA && /phantomjs/.test(UA);
  455. var isFF = UA && UA.match(/firefox\/(\d+)/);
  456. // Firefox has a "watch" function on Object.prototype...
  457. var nativeWatch = ({}).watch;
  458. var supportsPassive = false;
  459. if (inBrowser) {
  460. try {
  461. var opts = {};
  462. Object.defineProperty(opts, 'passive', ({
  463. get: function get () {
  464. /* istanbul ignore next */
  465. supportsPassive = true;
  466. }
  467. })); // https://github.com/facebook/flow/issues/285
  468. window.addEventListener('test-passive', null, opts);
  469. } catch (e) {}
  470. }
  471. // this needs to be lazy-evaled because vue may be required before
  472. // vue-server-renderer can set VUE_ENV
  473. var _isServer;
  474. var isServerRendering = function () {
  475. if (_isServer === undefined) {
  476. /* istanbul ignore if */
  477. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  478. // detect presence of vue-server-renderer and avoid
  479. // Webpack shimming the process
  480. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  481. } else {
  482. _isServer = false;
  483. }
  484. }
  485. return _isServer
  486. };
  487. // detect devtools
  488. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  489. /* istanbul ignore next */
  490. function isNative (Ctor) {
  491. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  492. }
  493. var hasSymbol =
  494. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  495. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  496. var _Set;
  497. /* istanbul ignore if */ // $flow-disable-line
  498. if (typeof Set !== 'undefined' && isNative(Set)) {
  499. // use native Set when available.
  500. _Set = Set;
  501. } else {
  502. // a non-standard Set polyfill that only works with primitive keys.
  503. _Set = /*@__PURE__*/(function () {
  504. function Set () {
  505. this.set = Object.create(null);
  506. }
  507. Set.prototype.has = function has (key) {
  508. return this.set[key] === true
  509. };
  510. Set.prototype.add = function add (key) {
  511. this.set[key] = true;
  512. };
  513. Set.prototype.clear = function clear () {
  514. this.set = Object.create(null);
  515. };
  516. return Set;
  517. }());
  518. }
  519. /* */
  520. var warn = noop;
  521. var tip = noop;
  522. var generateComponentTrace = (noop); // work around flow check
  523. var formatComponentName = (noop);
  524. if (process.env.NODE_ENV !== 'production') {
  525. var hasConsole = typeof console !== 'undefined';
  526. var classifyRE = /(?:^|[-_])(\w)/g;
  527. var classify = function (str) { return str
  528. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  529. .replace(/[-_]/g, ''); };
  530. warn = function (msg, vm) {
  531. var trace = vm ? generateComponentTrace(vm) : '';
  532. if (config.warnHandler) {
  533. config.warnHandler.call(null, msg, vm, trace);
  534. } else if (hasConsole && (!config.silent)) {
  535. console.error(("[Vue warn]: " + msg + trace));
  536. }
  537. };
  538. tip = function (msg, vm) {
  539. if (hasConsole && (!config.silent)) {
  540. console.warn("[Vue tip]: " + msg + (
  541. vm ? generateComponentTrace(vm) : ''
  542. ));
  543. }
  544. };
  545. formatComponentName = function (vm, includeFile) {
  546. if (vm.$root === vm) {
  547. return '<Root>'
  548. }
  549. var options = typeof vm === 'function' && vm.cid != null
  550. ? vm.options
  551. : vm._isVue
  552. ? vm.$options || vm.constructor.options
  553. : vm;
  554. var name = options.name || options._componentTag;
  555. var file = options.__file;
  556. if (!name && file) {
  557. var match = file.match(/([^/\\]+)\.vue$/);
  558. name = match && match[1];
  559. }
  560. return (
  561. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  562. (file && includeFile !== false ? (" at " + file) : '')
  563. )
  564. };
  565. var repeat = function (str, n) {
  566. var res = '';
  567. while (n) {
  568. if (n % 2 === 1) { res += str; }
  569. if (n > 1) { str += str; }
  570. n >>= 1;
  571. }
  572. return res
  573. };
  574. generateComponentTrace = function (vm) {
  575. if (vm._isVue && vm.$parent) {
  576. var tree = [];
  577. var currentRecursiveSequence = 0;
  578. while (vm) {
  579. if (tree.length > 0) {
  580. var last = tree[tree.length - 1];
  581. if (last.constructor === vm.constructor) {
  582. currentRecursiveSequence++;
  583. vm = vm.$parent;
  584. continue
  585. } else if (currentRecursiveSequence > 0) {
  586. tree[tree.length - 1] = [last, currentRecursiveSequence];
  587. currentRecursiveSequence = 0;
  588. }
  589. }
  590. tree.push(vm);
  591. vm = vm.$parent;
  592. }
  593. return '\n\nfound in\n\n' + tree
  594. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  595. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  596. : formatComponentName(vm))); })
  597. .join('\n')
  598. } else {
  599. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  600. }
  601. };
  602. }
  603. /* */
  604. var uid = 0;
  605. /**
  606. * A dep is an observable that can have multiple
  607. * directives subscribing to it.
  608. */
  609. var Dep = function Dep () {
  610. this.id = uid++;
  611. this.subs = [];
  612. };
  613. Dep.prototype.addSub = function addSub (sub) {
  614. this.subs.push(sub);
  615. };
  616. Dep.prototype.removeSub = function removeSub (sub) {
  617. remove(this.subs, sub);
  618. };
  619. Dep.prototype.depend = function depend () {
  620. if (Dep.target) {
  621. Dep.target.addDep(this);
  622. }
  623. };
  624. Dep.prototype.notify = function notify () {
  625. // stabilize the subscriber list first
  626. var subs = this.subs.slice();
  627. if (process.env.NODE_ENV !== 'production' && !config.async) {
  628. // subs aren't sorted in scheduler if not running async
  629. // we need to sort them now to make sure they fire in correct
  630. // order
  631. subs.sort(function (a, b) { return a.id - b.id; });
  632. }
  633. for (var i = 0, l = subs.length; i < l; i++) {
  634. subs[i].update();
  635. }
  636. };
  637. // The current target watcher being evaluated.
  638. // This is globally unique because only one watcher
  639. // can be evaluated at a time.
  640. Dep.target = null;
  641. var targetStack = [];
  642. function pushTarget (target) {
  643. targetStack.push(target);
  644. Dep.target = target;
  645. }
  646. function popTarget () {
  647. targetStack.pop();
  648. Dep.target = targetStack[targetStack.length - 1];
  649. }
  650. /* */
  651. var VNode = function VNode (
  652. tag,
  653. data,
  654. children,
  655. text,
  656. elm,
  657. context,
  658. componentOptions,
  659. asyncFactory
  660. ) {
  661. this.tag = tag;
  662. this.data = data;
  663. this.children = children;
  664. this.text = text;
  665. this.elm = elm;
  666. this.ns = undefined;
  667. this.context = context;
  668. this.fnContext = undefined;
  669. this.fnOptions = undefined;
  670. this.fnScopeId = undefined;
  671. this.key = data && data.key;
  672. this.componentOptions = componentOptions;
  673. this.componentInstance = undefined;
  674. this.parent = undefined;
  675. this.raw = false;
  676. this.isStatic = false;
  677. this.isRootInsert = true;
  678. this.isComment = false;
  679. this.isCloned = false;
  680. this.isOnce = false;
  681. this.asyncFactory = asyncFactory;
  682. this.asyncMeta = undefined;
  683. this.isAsyncPlaceholder = false;
  684. };
  685. var prototypeAccessors = { child: { configurable: true } };
  686. // DEPRECATED: alias for componentInstance for backwards compat.
  687. /* istanbul ignore next */
  688. prototypeAccessors.child.get = function () {
  689. return this.componentInstance
  690. };
  691. Object.defineProperties( VNode.prototype, prototypeAccessors );
  692. var createEmptyVNode = function (text) {
  693. if ( text === void 0 ) text = '';
  694. var node = new VNode();
  695. node.text = text;
  696. node.isComment = true;
  697. return node
  698. };
  699. function createTextVNode (val) {
  700. return new VNode(undefined, undefined, undefined, String(val))
  701. }
  702. // optimized shallow clone
  703. // used for static nodes and slot nodes because they may be reused across
  704. // multiple renders, cloning them avoids errors when DOM manipulations rely
  705. // on their elm reference.
  706. function cloneVNode (vnode) {
  707. var cloned = new VNode(
  708. vnode.tag,
  709. vnode.data,
  710. // #7975
  711. // clone children array to avoid mutating original in case of cloning
  712. // a child.
  713. vnode.children && vnode.children.slice(),
  714. vnode.text,
  715. vnode.elm,
  716. vnode.context,
  717. vnode.componentOptions,
  718. vnode.asyncFactory
  719. );
  720. cloned.ns = vnode.ns;
  721. cloned.isStatic = vnode.isStatic;
  722. cloned.key = vnode.key;
  723. cloned.isComment = vnode.isComment;
  724. cloned.fnContext = vnode.fnContext;
  725. cloned.fnOptions = vnode.fnOptions;
  726. cloned.fnScopeId = vnode.fnScopeId;
  727. cloned.asyncMeta = vnode.asyncMeta;
  728. cloned.isCloned = true;
  729. return cloned
  730. }
  731. /*
  732. * not type checking this file because flow doesn't play well with
  733. * dynamically accessing methods on Array prototype
  734. */
  735. var arrayProto = Array.prototype;
  736. var arrayMethods = Object.create(arrayProto);
  737. var methodsToPatch = [
  738. 'push',
  739. 'pop',
  740. 'shift',
  741. 'unshift',
  742. 'splice',
  743. 'sort',
  744. 'reverse'
  745. ];
  746. /**
  747. * Intercept mutating methods and emit events
  748. */
  749. methodsToPatch.forEach(function (method) {
  750. // cache original method
  751. var original = arrayProto[method];
  752. def(arrayMethods, method, function mutator () {
  753. var args = [], len = arguments.length;
  754. while ( len-- ) args[ len ] = arguments[ len ];
  755. var result = original.apply(this, args);
  756. var ob = this.__ob__;
  757. var inserted;
  758. switch (method) {
  759. case 'push':
  760. case 'unshift':
  761. inserted = args;
  762. break
  763. case 'splice':
  764. inserted = args.slice(2);
  765. break
  766. }
  767. if (inserted) { ob.observeArray(inserted); }
  768. // notify change
  769. ob.dep.notify();
  770. return result
  771. });
  772. });
  773. /* */
  774. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  775. /**
  776. * In some cases we may want to disable observation inside a component's
  777. * update computation.
  778. */
  779. var shouldObserve = true;
  780. function toggleObserving (value) {
  781. shouldObserve = value;
  782. }
  783. /**
  784. * Observer class that is attached to each observed
  785. * object. Once attached, the observer converts the target
  786. * object's property keys into getter/setters that
  787. * collect dependencies and dispatch updates.
  788. */
  789. var Observer = function Observer (value) {
  790. this.value = value;
  791. this.dep = new Dep();
  792. this.vmCount = 0;
  793. def(value, '__ob__', this);
  794. if (Array.isArray(value)) {
  795. if (hasProto) {
  796. protoAugment(value, arrayMethods);
  797. } else {
  798. copyAugment(value, arrayMethods, arrayKeys);
  799. }
  800. this.observeArray(value);
  801. } else {
  802. this.walk(value);
  803. }
  804. };
  805. /**
  806. * Walk through all properties and convert them into
  807. * getter/setters. This method should only be called when
  808. * value type is Object.
  809. */
  810. Observer.prototype.walk = function walk (obj) {
  811. var keys = Object.keys(obj);
  812. for (var i = 0; i < keys.length; i++) {
  813. defineReactive$$1(obj, keys[i]);
  814. }
  815. };
  816. /**
  817. * Observe a list of Array items.
  818. */
  819. Observer.prototype.observeArray = function observeArray (items) {
  820. for (var i = 0, l = items.length; i < l; i++) {
  821. observe(items[i]);
  822. }
  823. };
  824. // helpers
  825. /**
  826. * Augment a target Object or Array by intercepting
  827. * the prototype chain using __proto__
  828. */
  829. function protoAugment (target, src) {
  830. /* eslint-disable no-proto */
  831. target.__proto__ = src;
  832. /* eslint-enable no-proto */
  833. }
  834. /**
  835. * Augment a target Object or Array by defining
  836. * hidden properties.
  837. */
  838. /* istanbul ignore next */
  839. function copyAugment (target, src, keys) {
  840. for (var i = 0, l = keys.length; i < l; i++) {
  841. var key = keys[i];
  842. def(target, key, src[key]);
  843. }
  844. }
  845. /**
  846. * Attempt to create an observer instance for a value,
  847. * returns the new observer if successfully observed,
  848. * or the existing observer if the value already has one.
  849. */
  850. function observe (value, asRootData) {
  851. if (!isObject(value) || value instanceof VNode) {
  852. return
  853. }
  854. var ob;
  855. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  856. ob = value.__ob__;
  857. } else if (
  858. shouldObserve &&
  859. !isServerRendering() &&
  860. (Array.isArray(value) || isPlainObject(value)) &&
  861. Object.isExtensible(value) &&
  862. !value._isVue
  863. ) {
  864. ob = new Observer(value);
  865. }
  866. if (asRootData && ob) {
  867. ob.vmCount++;
  868. }
  869. return ob
  870. }
  871. /**
  872. * Define a reactive property on an Object.
  873. */
  874. function defineReactive$$1 (
  875. obj,
  876. key,
  877. val,
  878. customSetter,
  879. shallow
  880. ) {
  881. var dep = new Dep();
  882. var property = Object.getOwnPropertyDescriptor(obj, key);
  883. if (property && property.configurable === false) {
  884. return
  885. }
  886. // cater for pre-defined getter/setters
  887. var getter = property && property.get;
  888. var setter = property && property.set;
  889. if ((!getter || setter) && arguments.length === 2) {
  890. val = obj[key];
  891. }
  892. var childOb = !shallow && observe(val);
  893. Object.defineProperty(obj, key, {
  894. enumerable: true,
  895. configurable: true,
  896. get: function reactiveGetter () {
  897. var value = getter ? getter.call(obj) : val;
  898. if (Dep.target) {
  899. dep.depend();
  900. if (childOb) {
  901. childOb.dep.depend();
  902. if (Array.isArray(value)) {
  903. dependArray(value);
  904. }
  905. }
  906. }
  907. return value
  908. },
  909. set: function reactiveSetter (newVal) {
  910. var value = getter ? getter.call(obj) : val;
  911. /* eslint-disable no-self-compare */
  912. if (newVal === value || (newVal !== newVal && value !== value)) {
  913. return
  914. }
  915. /* eslint-enable no-self-compare */
  916. if (process.env.NODE_ENV !== 'production' && customSetter) {
  917. customSetter();
  918. }
  919. // #7981: for accessor properties without setter
  920. if (getter && !setter) { return }
  921. if (setter) {
  922. setter.call(obj, newVal);
  923. } else {
  924. val = newVal;
  925. }
  926. childOb = !shallow && observe(newVal);
  927. dep.notify();
  928. }
  929. });
  930. }
  931. /**
  932. * Set a property on an object. Adds the new property and
  933. * triggers change notification if the property doesn't
  934. * already exist.
  935. */
  936. function set (target, key, val) {
  937. if (process.env.NODE_ENV !== 'production' &&
  938. (isUndef(target) || isPrimitive(target))
  939. ) {
  940. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  941. }
  942. if (Array.isArray(target) && isValidArrayIndex(key)) {
  943. target.length = Math.max(target.length, key);
  944. target.splice(key, 1, val);
  945. return val
  946. }
  947. if (key in target && !(key in Object.prototype)) {
  948. target[key] = val;
  949. return val
  950. }
  951. var ob = (target).__ob__;
  952. if (target._isVue || (ob && ob.vmCount)) {
  953. process.env.NODE_ENV !== 'production' && warn(
  954. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  955. 'at runtime - declare it upfront in the data option.'
  956. );
  957. return val
  958. }
  959. if (!ob) {
  960. target[key] = val;
  961. return val
  962. }
  963. defineReactive$$1(ob.value, key, val);
  964. ob.dep.notify();
  965. return val
  966. }
  967. /**
  968. * Delete a property and trigger change if necessary.
  969. */
  970. function del (target, key) {
  971. if (process.env.NODE_ENV !== 'production' &&
  972. (isUndef(target) || isPrimitive(target))
  973. ) {
  974. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  975. }
  976. if (Array.isArray(target) && isValidArrayIndex(key)) {
  977. target.splice(key, 1);
  978. return
  979. }
  980. var ob = (target).__ob__;
  981. if (target._isVue || (ob && ob.vmCount)) {
  982. process.env.NODE_ENV !== 'production' && warn(
  983. 'Avoid deleting properties on a Vue instance or its root $data ' +
  984. '- just set it to null.'
  985. );
  986. return
  987. }
  988. if (!hasOwn(target, key)) {
  989. return
  990. }
  991. delete target[key];
  992. if (!ob) {
  993. return
  994. }
  995. ob.dep.notify();
  996. }
  997. /**
  998. * Collect dependencies on array elements when the array is touched, since
  999. * we cannot intercept array element access like property getters.
  1000. */
  1001. function dependArray (value) {
  1002. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  1003. e = value[i];
  1004. e && e.__ob__ && e.__ob__.dep.depend();
  1005. if (Array.isArray(e)) {
  1006. dependArray(e);
  1007. }
  1008. }
  1009. }
  1010. /* */
  1011. /**
  1012. * Option overwriting strategies are functions that handle
  1013. * how to merge a parent option value and a child option
  1014. * value into the final value.
  1015. */
  1016. var strats = config.optionMergeStrategies;
  1017. /**
  1018. * Options with restrictions
  1019. */
  1020. if (process.env.NODE_ENV !== 'production') {
  1021. strats.el = strats.propsData = function (parent, child, vm, key) {
  1022. if (!vm) {
  1023. warn(
  1024. "option \"" + key + "\" can only be used during instance " +
  1025. 'creation with the `new` keyword.'
  1026. );
  1027. }
  1028. return defaultStrat(parent, child)
  1029. };
  1030. }
  1031. /**
  1032. * Helper that recursively merges two data objects together.
  1033. */
  1034. function mergeData (to, from) {
  1035. if (!from) { return to }
  1036. var key, toVal, fromVal;
  1037. var keys = hasSymbol
  1038. ? Reflect.ownKeys(from)
  1039. : Object.keys(from);
  1040. for (var i = 0; i < keys.length; i++) {
  1041. key = keys[i];
  1042. // in case the object is already observed...
  1043. if (key === '__ob__') { continue }
  1044. toVal = to[key];
  1045. fromVal = from[key];
  1046. if (!hasOwn(to, key)) {
  1047. set(to, key, fromVal);
  1048. } else if (
  1049. toVal !== fromVal &&
  1050. isPlainObject(toVal) &&
  1051. isPlainObject(fromVal)
  1052. ) {
  1053. mergeData(toVal, fromVal);
  1054. }
  1055. }
  1056. return to
  1057. }
  1058. /**
  1059. * Data
  1060. */
  1061. function mergeDataOrFn (
  1062. parentVal,
  1063. childVal,
  1064. vm
  1065. ) {
  1066. if (!vm) {
  1067. // in a Vue.extend merge, both should be functions
  1068. if (!childVal) {
  1069. return parentVal
  1070. }
  1071. if (!parentVal) {
  1072. return childVal
  1073. }
  1074. // when parentVal & childVal are both present,
  1075. // we need to return a function that returns the
  1076. // merged result of both functions... no need to
  1077. // check if parentVal is a function here because
  1078. // it has to be a function to pass previous merges.
  1079. return function mergedDataFn () {
  1080. return mergeData(
  1081. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  1082. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  1083. )
  1084. }
  1085. } else {
  1086. return function mergedInstanceDataFn () {
  1087. // instance merge
  1088. var instanceData = typeof childVal === 'function'
  1089. ? childVal.call(vm, vm)
  1090. : childVal;
  1091. var defaultData = typeof parentVal === 'function'
  1092. ? parentVal.call(vm, vm)
  1093. : parentVal;
  1094. if (instanceData) {
  1095. return mergeData(instanceData, defaultData)
  1096. } else {
  1097. return defaultData
  1098. }
  1099. }
  1100. }
  1101. }
  1102. strats.data = function (
  1103. parentVal,
  1104. childVal,
  1105. vm
  1106. ) {
  1107. if (!vm) {
  1108. if (childVal && typeof childVal !== 'function') {
  1109. process.env.NODE_ENV !== 'production' && warn(
  1110. 'The "data" option should be a function ' +
  1111. 'that returns a per-instance value in component ' +
  1112. 'definitions.',
  1113. vm
  1114. );
  1115. return parentVal
  1116. }
  1117. return mergeDataOrFn(parentVal, childVal)
  1118. }
  1119. return mergeDataOrFn(parentVal, childVal, vm)
  1120. };
  1121. /**
  1122. * Hooks and props are merged as arrays.
  1123. */
  1124. function mergeHook (
  1125. parentVal,
  1126. childVal
  1127. ) {
  1128. var res = childVal
  1129. ? parentVal
  1130. ? parentVal.concat(childVal)
  1131. : Array.isArray(childVal)
  1132. ? childVal
  1133. : [childVal]
  1134. : parentVal;
  1135. return res
  1136. ? dedupeHooks(res)
  1137. : res
  1138. }
  1139. function dedupeHooks (hooks) {
  1140. var res = [];
  1141. for (var i = 0; i < hooks.length; i++) {
  1142. if (res.indexOf(hooks[i]) === -1) {
  1143. res.push(hooks[i]);
  1144. }
  1145. }
  1146. return res
  1147. }
  1148. LIFECYCLE_HOOKS.forEach(function (hook) {
  1149. strats[hook] = mergeHook;
  1150. });
  1151. /**
  1152. * Assets
  1153. *
  1154. * When a vm is present (instance creation), we need to do
  1155. * a three-way merge between constructor options, instance
  1156. * options and parent options.
  1157. */
  1158. function mergeAssets (
  1159. parentVal,
  1160. childVal,
  1161. vm,
  1162. key
  1163. ) {
  1164. var res = Object.create(parentVal || null);
  1165. if (childVal) {
  1166. process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
  1167. return extend(res, childVal)
  1168. } else {
  1169. return res
  1170. }
  1171. }
  1172. ASSET_TYPES.forEach(function (type) {
  1173. strats[type + 's'] = mergeAssets;
  1174. });
  1175. /**
  1176. * Watchers.
  1177. *
  1178. * Watchers hashes should not overwrite one
  1179. * another, so we merge them as arrays.
  1180. */
  1181. strats.watch = function (
  1182. parentVal,
  1183. childVal,
  1184. vm,
  1185. key
  1186. ) {
  1187. // work around Firefox's Object.prototype.watch...
  1188. if (parentVal === nativeWatch) { parentVal = undefined; }
  1189. if (childVal === nativeWatch) { childVal = undefined; }
  1190. /* istanbul ignore if */
  1191. if (!childVal) { return Object.create(parentVal || null) }
  1192. if (process.env.NODE_ENV !== 'production') {
  1193. assertObjectType(key, childVal, vm);
  1194. }
  1195. if (!parentVal) { return childVal }
  1196. var ret = {};
  1197. extend(ret, parentVal);
  1198. for (var key$1 in childVal) {
  1199. var parent = ret[key$1];
  1200. var child = childVal[key$1];
  1201. if (parent && !Array.isArray(parent)) {
  1202. parent = [parent];
  1203. }
  1204. ret[key$1] = parent
  1205. ? parent.concat(child)
  1206. : Array.isArray(child) ? child : [child];
  1207. }
  1208. return ret
  1209. };
  1210. /**
  1211. * Other object hashes.
  1212. */
  1213. strats.props =
  1214. strats.methods =
  1215. strats.inject =
  1216. strats.computed = function (
  1217. parentVal,
  1218. childVal,
  1219. vm,
  1220. key
  1221. ) {
  1222. if (childVal && process.env.NODE_ENV !== 'production') {
  1223. assertObjectType(key, childVal, vm);
  1224. }
  1225. if (!parentVal) { return childVal }
  1226. var ret = Object.create(null);
  1227. extend(ret, parentVal);
  1228. if (childVal) { extend(ret, childVal); }
  1229. return ret
  1230. };
  1231. strats.provide = mergeDataOrFn;
  1232. /**
  1233. * Default strategy.
  1234. */
  1235. var defaultStrat = function (parentVal, childVal) {
  1236. return childVal === undefined
  1237. ? parentVal
  1238. : childVal
  1239. };
  1240. /**
  1241. * Validate component names
  1242. */
  1243. function checkComponents (options) {
  1244. for (var key in options.components) {
  1245. validateComponentName(key);
  1246. }
  1247. }
  1248. function validateComponentName (name) {
  1249. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  1250. warn(
  1251. 'Invalid component name: "' + name + '". Component names ' +
  1252. 'should conform to valid custom element name in html5 specification.'
  1253. );
  1254. }
  1255. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  1256. warn(
  1257. 'Do not use built-in or reserved HTML elements as component ' +
  1258. 'id: ' + name
  1259. );
  1260. }
  1261. }
  1262. /**
  1263. * Ensure all props option syntax are normalized into the
  1264. * Object-based format.
  1265. */
  1266. function normalizeProps (options, vm) {
  1267. var props = options.props;
  1268. if (!props) { return }
  1269. var res = {};
  1270. var i, val, name;
  1271. if (Array.isArray(props)) {
  1272. i = props.length;
  1273. while (i--) {
  1274. val = props[i];
  1275. if (typeof val === 'string') {
  1276. name = camelize(val);
  1277. res[name] = { type: null };
  1278. } else if (process.env.NODE_ENV !== 'production') {
  1279. warn('props must be strings when using array syntax.');
  1280. }
  1281. }
  1282. } else if (isPlainObject(props)) {
  1283. for (var key in props) {
  1284. val = props[key];
  1285. name = camelize(key);
  1286. res[name] = isPlainObject(val)
  1287. ? val
  1288. : { type: val };
  1289. }
  1290. } else if (process.env.NODE_ENV !== 'production') {
  1291. warn(
  1292. "Invalid value for option \"props\": expected an Array or an Object, " +
  1293. "but got " + (toRawType(props)) + ".",
  1294. vm
  1295. );
  1296. }
  1297. options.props = res;
  1298. }
  1299. /**
  1300. * Normalize all injections into Object-based format
  1301. */
  1302. function normalizeInject (options, vm) {
  1303. var inject = options.inject;
  1304. if (!inject) { return }
  1305. var normalized = options.inject = {};
  1306. if (Array.isArray(inject)) {
  1307. for (var i = 0; i < inject.length; i++) {
  1308. normalized[inject[i]] = { from: inject[i] };
  1309. }
  1310. } else if (isPlainObject(inject)) {
  1311. for (var key in inject) {
  1312. var val = inject[key];
  1313. normalized[key] = isPlainObject(val)
  1314. ? extend({ from: key }, val)
  1315. : { from: val };
  1316. }
  1317. } else if (process.env.NODE_ENV !== 'production') {
  1318. warn(
  1319. "Invalid value for option \"inject\": expected an Array or an Object, " +
  1320. "but got " + (toRawType(inject)) + ".",
  1321. vm
  1322. );
  1323. }
  1324. }
  1325. /**
  1326. * Normalize raw function directives into object format.
  1327. */
  1328. function normalizeDirectives (options) {
  1329. var dirs = options.directives;
  1330. if (dirs) {
  1331. for (var key in dirs) {
  1332. var def$$1 = dirs[key];
  1333. if (typeof def$$1 === 'function') {
  1334. dirs[key] = { bind: def$$1, update: def$$1 };
  1335. }
  1336. }
  1337. }
  1338. }
  1339. function assertObjectType (name, value, vm) {
  1340. if (!isPlainObject(value)) {
  1341. warn(
  1342. "Invalid value for option \"" + name + "\": expected an Object, " +
  1343. "but got " + (toRawType(value)) + ".",
  1344. vm
  1345. );
  1346. }
  1347. }
  1348. /**
  1349. * Merge two option objects into a new one.
  1350. * Core utility used in both instantiation and inheritance.
  1351. */
  1352. function mergeOptions (
  1353. parent,
  1354. child,
  1355. vm
  1356. ) {
  1357. if (process.env.NODE_ENV !== 'production') {
  1358. checkComponents(child);
  1359. }
  1360. if (typeof child === 'function') {
  1361. child = child.options;
  1362. }
  1363. normalizeProps(child, vm);
  1364. normalizeInject(child, vm);
  1365. normalizeDirectives(child);
  1366. // Apply extends and mixins on the child options,
  1367. // but only if it is a raw options object that isn't
  1368. // the result of another mergeOptions call.
  1369. // Only merged options has the _base property.
  1370. if (!child._base) {
  1371. if (child.extends) {
  1372. parent = mergeOptions(parent, child.extends, vm);
  1373. }
  1374. if (child.mixins) {
  1375. for (var i = 0, l = child.mixins.length; i < l; i++) {
  1376. parent = mergeOptions(parent, child.mixins[i], vm);
  1377. }
  1378. }
  1379. }
  1380. var options = {};
  1381. var key;
  1382. for (key in parent) {
  1383. mergeField(key);
  1384. }
  1385. for (key in child) {
  1386. if (!hasOwn(parent, key)) {
  1387. mergeField(key);
  1388. }
  1389. }
  1390. function mergeField (key) {
  1391. var strat = strats[key] || defaultStrat;
  1392. options[key] = strat(parent[key], child[key], vm, key);
  1393. }
  1394. return options
  1395. }
  1396. /**
  1397. * Resolve an asset.
  1398. * This function is used because child instances need access
  1399. * to assets defined in its ancestor chain.
  1400. */
  1401. function resolveAsset (
  1402. options,
  1403. type,
  1404. id,
  1405. warnMissing
  1406. ) {
  1407. /* istanbul ignore if */
  1408. if (typeof id !== 'string') {
  1409. return
  1410. }
  1411. var assets = options[type];
  1412. // check local registration variations first
  1413. if (hasOwn(assets, id)) { return assets[id] }
  1414. var camelizedId = camelize(id);
  1415. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  1416. var PascalCaseId = capitalize(camelizedId);
  1417. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  1418. // fallback to prototype chain
  1419. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  1420. if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
  1421. warn(
  1422. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  1423. options
  1424. );
  1425. }
  1426. return res
  1427. }
  1428. /* */
  1429. function validateProp (
  1430. key,
  1431. propOptions,
  1432. propsData,
  1433. vm
  1434. ) {
  1435. var prop = propOptions[key];
  1436. var absent = !hasOwn(propsData, key);
  1437. var value = propsData[key];
  1438. // boolean casting
  1439. var booleanIndex = getTypeIndex(Boolean, prop.type);
  1440. if (booleanIndex > -1) {
  1441. if (absent && !hasOwn(prop, 'default')) {
  1442. value = false;
  1443. } else if (value === '' || value === hyphenate(key)) {
  1444. // only cast empty string / same name to boolean if
  1445. // boolean has higher priority
  1446. var stringIndex = getTypeIndex(String, prop.type);
  1447. if (stringIndex < 0 || booleanIndex < stringIndex) {
  1448. value = true;
  1449. }
  1450. }
  1451. }
  1452. // check default value
  1453. if (value === undefined) {
  1454. value = getPropDefaultValue(vm, prop, key);
  1455. // since the default value is a fresh copy,
  1456. // make sure to observe it.
  1457. var prevShouldObserve = shouldObserve;
  1458. toggleObserving(true);
  1459. observe(value);
  1460. toggleObserving(prevShouldObserve);
  1461. }
  1462. if (
  1463. process.env.NODE_ENV !== 'production' &&
  1464. // skip validation for weex recycle-list child component props
  1465. !(false)
  1466. ) {
  1467. assertProp(prop, key, value, vm, absent);
  1468. }
  1469. return value
  1470. }
  1471. /**
  1472. * Get the default value of a prop.
  1473. */
  1474. function getPropDefaultValue (vm, prop, key) {
  1475. // no default, return undefined
  1476. if (!hasOwn(prop, 'default')) {
  1477. return undefined
  1478. }
  1479. var def = prop.default;
  1480. // warn against non-factory defaults for Object & Array
  1481. if (process.env.NODE_ENV !== 'production' && isObject(def)) {
  1482. warn(
  1483. 'Invalid default value for prop "' + key + '": ' +
  1484. 'Props with type Object/Array must use a factory function ' +
  1485. 'to return the default value.',
  1486. vm
  1487. );
  1488. }
  1489. // the raw prop value was also undefined from previous render,
  1490. // return previous default value to avoid unnecessary watcher trigger
  1491. if (vm && vm.$options.propsData &&
  1492. vm.$options.propsData[key] === undefined &&
  1493. vm._props[key] !== undefined
  1494. ) {
  1495. return vm._props[key]
  1496. }
  1497. // call factory function for non-Function types
  1498. // a value is Function if its prototype is function even across different execution context
  1499. return typeof def === 'function' && getType(prop.type) !== 'Function'
  1500. ? def.call(vm)
  1501. : def
  1502. }
  1503. /**
  1504. * Assert whether a prop is valid.
  1505. */
  1506. function assertProp (
  1507. prop,
  1508. name,
  1509. value,
  1510. vm,
  1511. absent
  1512. ) {
  1513. if (prop.required && absent) {
  1514. warn(
  1515. 'Missing required prop: "' + name + '"',
  1516. vm
  1517. );
  1518. return
  1519. }
  1520. if (value == null && !prop.required) {
  1521. return
  1522. }
  1523. var type = prop.type;
  1524. var valid = !type || type === true;
  1525. var expectedTypes = [];
  1526. if (type) {
  1527. if (!Array.isArray(type)) {
  1528. type = [type];
  1529. }
  1530. for (var i = 0; i < type.length && !valid; i++) {
  1531. var assertedType = assertType(value, type[i], vm);
  1532. expectedTypes.push(assertedType.expectedType || '');
  1533. valid = assertedType.valid;
  1534. }
  1535. }
  1536. var haveExpectedTypes = expectedTypes.some(function (t) { return t; });
  1537. if (!valid && haveExpectedTypes) {
  1538. warn(
  1539. getInvalidTypeMessage(name, value, expectedTypes),
  1540. vm
  1541. );
  1542. return
  1543. }
  1544. var validator = prop.validator;
  1545. if (validator) {
  1546. if (!validator(value)) {
  1547. warn(
  1548. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  1549. vm
  1550. );
  1551. }
  1552. }
  1553. }
  1554. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  1555. function assertType (value, type, vm) {
  1556. var valid;
  1557. var expectedType = getType(type);
  1558. if (simpleCheckRE.test(expectedType)) {
  1559. var t = typeof value;
  1560. valid = t === expectedType.toLowerCase();
  1561. // for primitive wrapper objects
  1562. if (!valid && t === 'object') {
  1563. valid = value instanceof type;
  1564. }
  1565. } else if (expectedType === 'Object') {
  1566. valid = isPlainObject(value);
  1567. } else if (expectedType === 'Array') {
  1568. valid = Array.isArray(value);
  1569. } else {
  1570. try {
  1571. valid = value instanceof type;
  1572. } catch (e) {
  1573. warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  1574. valid = false;
  1575. }
  1576. }
  1577. return {
  1578. valid: valid,
  1579. expectedType: expectedType
  1580. }
  1581. }
  1582. var functionTypeCheckRE = /^\s*function (\w+)/;
  1583. /**
  1584. * Use function string name to check built-in types,
  1585. * because a simple equality check will fail when running
  1586. * across different vms / iframes.
  1587. */
  1588. function getType (fn) {
  1589. var match = fn && fn.toString().match(functionTypeCheckRE);
  1590. return match ? match[1] : ''
  1591. }
  1592. function isSameType (a, b) {
  1593. return getType(a) === getType(b)
  1594. }
  1595. function getTypeIndex (type, expectedTypes) {
  1596. if (!Array.isArray(expectedTypes)) {
  1597. return isSameType(expectedTypes, type) ? 0 : -1
  1598. }
  1599. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  1600. if (isSameType(expectedTypes[i], type)) {
  1601. return i
  1602. }
  1603. }
  1604. return -1
  1605. }
  1606. function getInvalidTypeMessage (name, value, expectedTypes) {
  1607. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  1608. " Expected " + (expectedTypes.map(capitalize).join(', '));
  1609. var expectedType = expectedTypes[0];
  1610. var receivedType = toRawType(value);
  1611. // check if we need to specify expected value
  1612. if (
  1613. expectedTypes.length === 1 &&
  1614. isExplicable(expectedType) &&
  1615. isExplicable(typeof value) &&
  1616. !isBoolean(expectedType, receivedType)
  1617. ) {
  1618. message += " with value " + (styleValue(value, expectedType));
  1619. }
  1620. message += ", got " + receivedType + " ";
  1621. // check if we need to specify received value
  1622. if (isExplicable(receivedType)) {
  1623. message += "with value " + (styleValue(value, receivedType)) + ".";
  1624. }
  1625. return message
  1626. }
  1627. function styleValue (value, type) {
  1628. if (type === 'String') {
  1629. return ("\"" + value + "\"")
  1630. } else if (type === 'Number') {
  1631. return ("" + (Number(value)))
  1632. } else {
  1633. return ("" + value)
  1634. }
  1635. }
  1636. var EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  1637. function isExplicable (value) {
  1638. return EXPLICABLE_TYPES.some(function (elem) { return value.toLowerCase() === elem; })
  1639. }
  1640. function isBoolean () {
  1641. var args = [], len = arguments.length;
  1642. while ( len-- ) args[ len ] = arguments[ len ];
  1643. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  1644. }
  1645. /* */
  1646. function handleError (err, vm, info) {
  1647. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  1648. // See: https://github.com/vuejs/vuex/issues/1505
  1649. pushTarget();
  1650. try {
  1651. if (vm) {
  1652. var cur = vm;
  1653. while ((cur = cur.$parent)) {
  1654. var hooks = cur.$options.errorCaptured;
  1655. if (hooks) {
  1656. for (var i = 0; i < hooks.length; i++) {
  1657. try {
  1658. var capture = hooks[i].call(cur, err, vm, info) === false;
  1659. if (capture) { return }
  1660. } catch (e) {
  1661. globalHandleError(e, cur, 'errorCaptured hook');
  1662. }
  1663. }
  1664. }
  1665. }
  1666. }
  1667. globalHandleError(err, vm, info);
  1668. } finally {
  1669. popTarget();
  1670. }
  1671. }
  1672. function invokeWithErrorHandling (
  1673. handler,
  1674. context,
  1675. args,
  1676. vm,
  1677. info
  1678. ) {
  1679. var res;
  1680. try {
  1681. res = args ? handler.apply(context, args) : handler.call(context);
  1682. if (res && !res._isVue && isPromise(res) && !res._handled) {
  1683. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  1684. // issue #9511
  1685. // avoid catch triggering multiple times when nested calls
  1686. res._handled = true;
  1687. }
  1688. } catch (e) {
  1689. handleError(e, vm, info);
  1690. }
  1691. return res
  1692. }
  1693. function globalHandleError (err, vm, info) {
  1694. if (config.errorHandler) {
  1695. try {
  1696. return config.errorHandler.call(null, err, vm, info)
  1697. } catch (e) {
  1698. // if the user intentionally throws the original error in the handler,
  1699. // do not log it twice
  1700. if (e !== err) {
  1701. logError(e, null, 'config.errorHandler');
  1702. }
  1703. }
  1704. }
  1705. logError(err, vm, info);
  1706. }
  1707. function logError (err, vm, info) {
  1708. if (process.env.NODE_ENV !== 'production') {
  1709. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  1710. }
  1711. /* istanbul ignore else */
  1712. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  1713. console.error(err);
  1714. } else {
  1715. throw err
  1716. }
  1717. }
  1718. /* */
  1719. var isUsingMicroTask = false;
  1720. var callbacks = [];
  1721. var pending = false;
  1722. function flushCallbacks () {
  1723. pending = false;
  1724. var copies = callbacks.slice(0);
  1725. callbacks.length = 0;
  1726. for (var i = 0; i < copies.length; i++) {
  1727. copies[i]();
  1728. }
  1729. }
  1730. // Here we have async deferring wrappers using microtasks.
  1731. // In 2.5 we used (macro) tasks (in combination with microtasks).
  1732. // However, it has subtle problems when state is changed right before repaint
  1733. // (e.g. #6813, out-in transitions).
  1734. // Also, using (macro) tasks in event handler would cause some weird behaviors
  1735. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  1736. // So we now use microtasks everywhere, again.
  1737. // A major drawback of this tradeoff is that there are some scenarios
  1738. // where microtasks have too high a priority and fire in between supposedly
  1739. // sequential events (e.g. #4521, #6690, which have workarounds)
  1740. // or even between bubbling of the same event (#6566).
  1741. var timerFunc;
  1742. // The nextTick behavior leverages the microtask queue, which can be accessed
  1743. // via either native Promise.then or MutationObserver.
  1744. // MutationObserver has wider support, however it is seriously bugged in
  1745. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  1746. // completely stops working after triggering a few times... so, if native
  1747. // Promise is available, we will use it:
  1748. /* istanbul ignore next, $flow-disable-line */
  1749. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  1750. var p = Promise.resolve();
  1751. timerFunc = function () {
  1752. p.then(flushCallbacks);
  1753. // In problematic UIWebViews, Promise.then doesn't completely break, but
  1754. // it can get stuck in a weird state where callbacks are pushed into the
  1755. // microtask queue but the queue isn't being flushed, until the browser
  1756. // needs to do some other work, e.g. handle a timer. Therefore we can
  1757. // "force" the microtask queue to be flushed by adding an empty timer.
  1758. if (isIOS) { setTimeout(noop); }
  1759. };
  1760. isUsingMicroTask = true;
  1761. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  1762. isNative(MutationObserver) ||
  1763. // PhantomJS and iOS 7.x
  1764. MutationObserver.toString() === '[object MutationObserverConstructor]'
  1765. )) {
  1766. // Use MutationObserver where native Promise is not available,
  1767. // e.g. PhantomJS, iOS7, Android 4.4
  1768. // (#6466 MutationObserver is unreliable in IE11)
  1769. var counter = 1;
  1770. var observer = new MutationObserver(flushCallbacks);
  1771. var textNode = document.createTextNode(String(counter));
  1772. observer.observe(textNode, {
  1773. characterData: true
  1774. });
  1775. timerFunc = function () {
  1776. counter = (counter + 1) % 2;
  1777. textNode.data = String(counter);
  1778. };
  1779. isUsingMicroTask = true;
  1780. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  1781. // Fallback to setImmediate.
  1782. // Technically it leverages the (macro) task queue,
  1783. // but it is still a better choice than setTimeout.
  1784. timerFunc = function () {
  1785. setImmediate(flushCallbacks);
  1786. };
  1787. } else {
  1788. // Fallback to setTimeout.
  1789. timerFunc = function () {
  1790. setTimeout(flushCallbacks, 0);
  1791. };
  1792. }
  1793. function nextTick (cb, ctx) {
  1794. var _resolve;
  1795. callbacks.push(function () {
  1796. if (cb) {
  1797. try {
  1798. cb.call(ctx);
  1799. } catch (e) {
  1800. handleError(e, ctx, 'nextTick');
  1801. }
  1802. } else if (_resolve) {
  1803. _resolve(ctx);
  1804. }
  1805. });
  1806. if (!pending) {
  1807. pending = true;
  1808. timerFunc();
  1809. }
  1810. // $flow-disable-line
  1811. if (!cb && typeof Promise !== 'undefined') {
  1812. return new Promise(function (resolve) {
  1813. _resolve = resolve;
  1814. })
  1815. }
  1816. }
  1817. /* */
  1818. /* not type checking this file because flow doesn't play well with Proxy */
  1819. var initProxy;
  1820. if (process.env.NODE_ENV !== 'production') {
  1821. var allowedGlobals = makeMap(
  1822. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  1823. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  1824. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  1825. 'require' // for Webpack/Browserify
  1826. );
  1827. var warnNonPresent = function (target, key) {
  1828. warn(
  1829. "Property or method \"" + key + "\" is not defined on the instance but " +
  1830. 'referenced during render. Make sure that this property is reactive, ' +
  1831. 'either in the data option, or for class-based components, by ' +
  1832. 'initializing the property. ' +
  1833. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  1834. target
  1835. );
  1836. };
  1837. var warnReservedPrefix = function (target, key) {
  1838. warn(
  1839. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  1840. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  1841. 'prevent conflicts with Vue internals. ' +
  1842. 'See: https://vuejs.org/v2/api/#data',
  1843. target
  1844. );
  1845. };
  1846. var hasProxy =
  1847. typeof Proxy !== 'undefined' && isNative(Proxy);
  1848. if (hasProxy) {
  1849. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  1850. config.keyCodes = new Proxy(config.keyCodes, {
  1851. set: function set (target, key, value) {
  1852. if (isBuiltInModifier(key)) {
  1853. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  1854. return false
  1855. } else {
  1856. target[key] = value;
  1857. return true
  1858. }
  1859. }
  1860. });
  1861. }
  1862. var hasHandler = {
  1863. has: function has (target, key) {
  1864. var has = key in target;
  1865. var isAllowed = allowedGlobals(key) ||
  1866. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  1867. if (!has && !isAllowed) {
  1868. if (key in target.$data) { warnReservedPrefix(target, key); }
  1869. else { warnNonPresent(target, key); }
  1870. }
  1871. return has || !isAllowed
  1872. }
  1873. };
  1874. var getHandler = {
  1875. get: function get (target, key) {
  1876. if (typeof key === 'string' && !(key in target)) {
  1877. if (key in target.$data) { warnReservedPrefix(target, key); }
  1878. else { warnNonPresent(target, key); }
  1879. }
  1880. return target[key]
  1881. }
  1882. };
  1883. initProxy = function initProxy (vm) {
  1884. if (hasProxy) {
  1885. // determine which proxy handler to use
  1886. var options = vm.$options;
  1887. var handlers = options.render && options.render._withStripped
  1888. ? getHandler
  1889. : hasHandler;
  1890. vm._renderProxy = new Proxy(vm, handlers);
  1891. } else {
  1892. vm._renderProxy = vm;
  1893. }
  1894. };
  1895. }
  1896. /* */
  1897. var seenObjects = new _Set();
  1898. /**
  1899. * Recursively traverse an object to evoke all converted
  1900. * getters, so that every nested property inside the object
  1901. * is collected as a "deep" dependency.
  1902. */
  1903. function traverse (val) {
  1904. _traverse(val, seenObjects);
  1905. seenObjects.clear();
  1906. }
  1907. function _traverse (val, seen) {
  1908. var i, keys;
  1909. var isA = Array.isArray(val);
  1910. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  1911. return
  1912. }
  1913. if (val.__ob__) {
  1914. var depId = val.__ob__.dep.id;
  1915. if (seen.has(depId)) {
  1916. return
  1917. }
  1918. seen.add(depId);
  1919. }
  1920. if (isA) {
  1921. i = val.length;
  1922. while (i--) { _traverse(val[i], seen); }
  1923. } else {
  1924. keys = Object.keys(val);
  1925. i = keys.length;
  1926. while (i--) { _traverse(val[keys[i]], seen); }
  1927. }
  1928. }
  1929. var mark;
  1930. var measure;
  1931. if (process.env.NODE_ENV !== 'production') {
  1932. var perf = inBrowser && window.performance;
  1933. /* istanbul ignore if */
  1934. if (
  1935. perf &&
  1936. perf.mark &&
  1937. perf.measure &&
  1938. perf.clearMarks &&
  1939. perf.clearMeasures
  1940. ) {
  1941. mark = function (tag) { return perf.mark(tag); };
  1942. measure = function (name, startTag, endTag) {
  1943. perf.measure(name, startTag, endTag);
  1944. perf.clearMarks(startTag);
  1945. perf.clearMarks(endTag);
  1946. // perf.clearMeasures(name)
  1947. };
  1948. }
  1949. }
  1950. /* */
  1951. var normalizeEvent = cached(function (name) {
  1952. var passive = name.charAt(0) === '&';
  1953. name = passive ? name.slice(1) : name;
  1954. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  1955. name = once$$1 ? name.slice(1) : name;
  1956. var capture = name.charAt(0) === '!';
  1957. name = capture ? name.slice(1) : name;
  1958. return {
  1959. name: name,
  1960. once: once$$1,
  1961. capture: capture,
  1962. passive: passive
  1963. }
  1964. });
  1965. function createFnInvoker (fns, vm) {
  1966. function invoker () {
  1967. var arguments$1 = arguments;
  1968. var fns = invoker.fns;
  1969. if (Array.isArray(fns)) {
  1970. var cloned = fns.slice();
  1971. for (var i = 0; i < cloned.length; i++) {
  1972. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  1973. }
  1974. } else {
  1975. // return handler return value for single handlers
  1976. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  1977. }
  1978. }
  1979. invoker.fns = fns;
  1980. return invoker
  1981. }
  1982. function updateListeners (
  1983. on,
  1984. oldOn,
  1985. add,
  1986. remove$$1,
  1987. createOnceHandler,
  1988. vm
  1989. ) {
  1990. var name, def$$1, cur, old, event;
  1991. for (name in on) {
  1992. def$$1 = cur = on[name];
  1993. old = oldOn[name];
  1994. event = normalizeEvent(name);
  1995. if (isUndef(cur)) {
  1996. process.env.NODE_ENV !== 'production' && warn(
  1997. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  1998. vm
  1999. );
  2000. } else if (isUndef(old)) {
  2001. if (isUndef(cur.fns)) {
  2002. cur = on[name] = createFnInvoker(cur, vm);
  2003. }
  2004. if (isTrue(event.once)) {
  2005. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  2006. }
  2007. add(event.name, cur, event.capture, event.passive, event.params);
  2008. } else if (cur !== old) {
  2009. old.fns = cur;
  2010. on[name] = old;
  2011. }
  2012. }
  2013. for (name in oldOn) {
  2014. if (isUndef(on[name])) {
  2015. event = normalizeEvent(name);
  2016. remove$$1(event.name, oldOn[name], event.capture);
  2017. }
  2018. }
  2019. }
  2020. /* */
  2021. function mergeVNodeHook (def, hookKey, hook) {
  2022. if (def instanceof VNode) {
  2023. def = def.data.hook || (def.data.hook = {});
  2024. }
  2025. var invoker;
  2026. var oldHook = def[hookKey];
  2027. function wrappedHook () {
  2028. hook.apply(this, arguments);
  2029. // important: remove merged hook to ensure it's called only once
  2030. // and prevent memory leak
  2031. remove(invoker.fns, wrappedHook);
  2032. }
  2033. if (isUndef(oldHook)) {
  2034. // no existing hook
  2035. invoker = createFnInvoker([wrappedHook]);
  2036. } else {
  2037. /* istanbul ignore if */
  2038. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  2039. // already a merged invoker
  2040. invoker = oldHook;
  2041. invoker.fns.push(wrappedHook);
  2042. } else {
  2043. // existing plain hook
  2044. invoker = createFnInvoker([oldHook, wrappedHook]);
  2045. }
  2046. }
  2047. invoker.merged = true;
  2048. def[hookKey] = invoker;
  2049. }
  2050. /* */
  2051. function extractPropsFromVNodeData (
  2052. data,
  2053. Ctor,
  2054. tag
  2055. ) {
  2056. // we are only extracting raw values here.
  2057. // validation and default values are handled in the child
  2058. // component itself.
  2059. var propOptions = Ctor.options.props;
  2060. if (isUndef(propOptions)) {
  2061. return
  2062. }
  2063. var res = {};
  2064. var attrs = data.attrs;
  2065. var props = data.props;
  2066. if (isDef(attrs) || isDef(props)) {
  2067. for (var key in propOptions) {
  2068. var altKey = hyphenate(key);
  2069. if (process.env.NODE_ENV !== 'production') {
  2070. var keyInLowerCase = key.toLowerCase();
  2071. if (
  2072. key !== keyInLowerCase &&
  2073. attrs && hasOwn(attrs, keyInLowerCase)
  2074. ) {
  2075. tip(
  2076. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  2077. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  2078. " \"" + key + "\". " +
  2079. "Note that HTML attributes are case-insensitive and camelCased " +
  2080. "props need to use their kebab-case equivalents when using in-DOM " +
  2081. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  2082. );
  2083. }
  2084. }
  2085. checkProp(res, props, key, altKey, true) ||
  2086. checkProp(res, attrs, key, altKey, false);
  2087. }
  2088. }
  2089. return res
  2090. }
  2091. function checkProp (
  2092. res,
  2093. hash,
  2094. key,
  2095. altKey,
  2096. preserve
  2097. ) {
  2098. if (isDef(hash)) {
  2099. if (hasOwn(hash, key)) {
  2100. res[key] = hash[key];
  2101. if (!preserve) {
  2102. delete hash[key];
  2103. }
  2104. return true
  2105. } else if (hasOwn(hash, altKey)) {
  2106. res[key] = hash[altKey];
  2107. if (!preserve) {
  2108. delete hash[altKey];
  2109. }
  2110. return true
  2111. }
  2112. }
  2113. return false
  2114. }
  2115. /* */
  2116. // The template compiler attempts to minimize the need for normalization by
  2117. // statically analyzing the template at compile time.
  2118. //
  2119. // For plain HTML markup, normalization can be completely skipped because the
  2120. // generated render function is guaranteed to return Array<VNode>. There are
  2121. // two cases where extra normalization is needed:
  2122. // 1. When the children contains components - because a functional component
  2123. // may return an Array instead of a single root. In this case, just a simple
  2124. // normalization is needed - if any child is an Array, we flatten the whole
  2125. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  2126. // because functional components already normalize their own children.
  2127. function simpleNormalizeChildren (children) {
  2128. for (var i = 0; i < children.length; i++) {
  2129. if (Array.isArray(children[i])) {
  2130. return Array.prototype.concat.apply([], children)
  2131. }
  2132. }
  2133. return children
  2134. }
  2135. // 2. When the children contains constructs that always generated nested Arrays,
  2136. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  2137. // with hand-written render functions / JSX. In such cases a full normalization
  2138. // is needed to cater to all possible types of children values.
  2139. function normalizeChildren (children) {
  2140. return isPrimitive(children)
  2141. ? [createTextVNode(children)]
  2142. : Array.isArray(children)
  2143. ? normalizeArrayChildren(children)
  2144. : undefined
  2145. }
  2146. function isTextNode (node) {
  2147. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  2148. }
  2149. function normalizeArrayChildren (children, nestedIndex) {
  2150. var res = [];
  2151. var i, c, lastIndex, last;
  2152. for (i = 0; i < children.length; i++) {
  2153. c = children[i];
  2154. if (isUndef(c) || typeof c === 'boolean') { continue }
  2155. lastIndex = res.length - 1;
  2156. last = res[lastIndex];
  2157. // nested
  2158. if (Array.isArray(c)) {
  2159. if (c.length > 0) {
  2160. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  2161. // merge adjacent text nodes
  2162. if (isTextNode(c[0]) && isTextNode(last)) {
  2163. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  2164. c.shift();
  2165. }
  2166. res.push.apply(res, c);
  2167. }
  2168. } else if (isPrimitive(c)) {
  2169. if (isTextNode(last)) {
  2170. // merge adjacent text nodes
  2171. // this is necessary for SSR hydration because text nodes are
  2172. // essentially merged when rendered to HTML strings
  2173. res[lastIndex] = createTextVNode(last.text + c);
  2174. } else if (c !== '') {
  2175. // convert primitive to vnode
  2176. res.push(createTextVNode(c));
  2177. }
  2178. } else {
  2179. if (isTextNode(c) && isTextNode(last)) {
  2180. // merge adjacent text nodes
  2181. res[lastIndex] = createTextVNode(last.text + c.text);
  2182. } else {
  2183. // default key for nested array children (likely generated by v-for)
  2184. if (isTrue(children._isVList) &&
  2185. isDef(c.tag) &&
  2186. isUndef(c.key) &&
  2187. isDef(nestedIndex)) {
  2188. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  2189. }
  2190. res.push(c);
  2191. }
  2192. }
  2193. }
  2194. return res
  2195. }
  2196. /* */
  2197. function initProvide (vm) {
  2198. var provide = vm.$options.provide;
  2199. if (provide) {
  2200. vm._provided = typeof provide === 'function'
  2201. ? provide.call(vm)
  2202. : provide;
  2203. }
  2204. }
  2205. function initInjections (vm) {
  2206. var result = resolveInject(vm.$options.inject, vm);
  2207. if (result) {
  2208. toggleObserving(false);
  2209. Object.keys(result).forEach(function (key) {
  2210. /* istanbul ignore else */
  2211. if (process.env.NODE_ENV !== 'production') {
  2212. defineReactive$$1(vm, key, result[key], function () {
  2213. warn(
  2214. "Avoid mutating an injected value directly since the changes will be " +
  2215. "overwritten whenever the provided component re-renders. " +
  2216. "injection being mutated: \"" + key + "\"",
  2217. vm
  2218. );
  2219. });
  2220. } else {
  2221. defineReactive$$1(vm, key, result[key]);
  2222. }
  2223. });
  2224. toggleObserving(true);
  2225. }
  2226. }
  2227. function resolveInject (inject, vm) {
  2228. if (inject) {
  2229. // inject is :any because flow is not smart enough to figure out cached
  2230. var result = Object.create(null);
  2231. var keys = hasSymbol
  2232. ? Reflect.ownKeys(inject)
  2233. : Object.keys(inject);
  2234. for (var i = 0; i < keys.length; i++) {
  2235. var key = keys[i];
  2236. // #6574 in case the inject object is observed...
  2237. if (key === '__ob__') { continue }
  2238. var provideKey = inject[key].from;
  2239. var source = vm;
  2240. while (source) {
  2241. if (source._provided && hasOwn(source._provided, provideKey)) {
  2242. result[key] = source._provided[provideKey];
  2243. break
  2244. }
  2245. source = source.$parent;
  2246. }
  2247. if (!source) {
  2248. if ('default' in inject[key]) {
  2249. var provideDefault = inject[key].default;
  2250. result[key] = typeof provideDefault === 'function'
  2251. ? provideDefault.call(vm)
  2252. : provideDefault;
  2253. } else if (process.env.NODE_ENV !== 'production') {
  2254. warn(("Injection \"" + key + "\" not found"), vm);
  2255. }
  2256. }
  2257. }
  2258. return result
  2259. }
  2260. }
  2261. /* */
  2262. /**
  2263. * Runtime helper for resolving raw children VNodes into a slot object.
  2264. */
  2265. function resolveSlots (
  2266. children,
  2267. context
  2268. ) {
  2269. if (!children || !children.length) {
  2270. return {}
  2271. }
  2272. var slots = {};
  2273. for (var i = 0, l = children.length; i < l; i++) {
  2274. var child = children[i];
  2275. var data = child.data;
  2276. // remove slot attribute if the node is resolved as a Vue slot node
  2277. if (data && data.attrs && data.attrs.slot) {
  2278. delete data.attrs.slot;
  2279. }
  2280. // named slots should only be respected if the vnode was rendered in the
  2281. // same context.
  2282. if ((child.context === context || child.fnContext === context) &&
  2283. data && data.slot != null
  2284. ) {
  2285. var name = data.slot;
  2286. var slot = (slots[name] || (slots[name] = []));
  2287. if (child.tag === 'template') {
  2288. slot.push.apply(slot, child.children || []);
  2289. } else {
  2290. slot.push(child);
  2291. }
  2292. } else {
  2293. (slots.default || (slots.default = [])).push(child);
  2294. }
  2295. }
  2296. // ignore slots that contains only whitespace
  2297. for (var name$1 in slots) {
  2298. if (slots[name$1].every(isWhitespace)) {
  2299. delete slots[name$1];
  2300. }
  2301. }
  2302. return slots
  2303. }
  2304. function isWhitespace (node) {
  2305. return (node.isComment && !node.asyncFactory) || node.text === ' '
  2306. }
  2307. /* */
  2308. function isAsyncPlaceholder (node) {
  2309. return node.isComment && node.asyncFactory
  2310. }
  2311. /* */
  2312. function normalizeScopedSlots (
  2313. slots,
  2314. normalSlots,
  2315. prevSlots
  2316. ) {
  2317. var res;
  2318. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  2319. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  2320. var key = slots && slots.$key;
  2321. if (!slots) {
  2322. res = {};
  2323. } else if (slots._normalized) {
  2324. // fast path 1: child component re-render only, parent did not change
  2325. return slots._normalized
  2326. } else if (
  2327. isStable &&
  2328. prevSlots &&
  2329. prevSlots !== emptyObject &&
  2330. key === prevSlots.$key &&
  2331. !hasNormalSlots &&
  2332. !prevSlots.$hasNormal
  2333. ) {
  2334. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2335. // only need to normalize once
  2336. return prevSlots
  2337. } else {
  2338. res = {};
  2339. for (var key$1 in slots) {
  2340. if (slots[key$1] && key$1[0] !== '$') {
  2341. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  2342. }
  2343. }
  2344. }
  2345. // expose normal slots on scopedSlots
  2346. for (var key$2 in normalSlots) {
  2347. if (!(key$2 in res)) {
  2348. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  2349. }
  2350. }
  2351. // avoriaz seems to mock a non-extensible $scopedSlots object
  2352. // and when that is passed down this would cause an error
  2353. if (slots && Object.isExtensible(slots)) {
  2354. (slots)._normalized = res;
  2355. }
  2356. def(res, '$stable', isStable);
  2357. def(res, '$key', key);
  2358. def(res, '$hasNormal', hasNormalSlots);
  2359. return res
  2360. }
  2361. function normalizeScopedSlot(normalSlots, key, fn) {
  2362. var normalized = function () {
  2363. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  2364. res = res && typeof res === 'object' && !Array.isArray(res)
  2365. ? [res] // single vnode
  2366. : normalizeChildren(res);
  2367. var vnode = res && res[0];
  2368. return res && (
  2369. !vnode ||
  2370. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode)) // #9658, #10391
  2371. ) ? undefined
  2372. : res
  2373. };
  2374. // this is a slot using the new v-slot syntax without scope. although it is
  2375. // compiled as a scoped slot, render fn users would expect it to be present
  2376. // on this.$slots because the usage is semantically a normal slot.
  2377. if (fn.proxy) {
  2378. Object.defineProperty(normalSlots, key, {
  2379. get: normalized,
  2380. enumerable: true,
  2381. configurable: true
  2382. });
  2383. }
  2384. return normalized
  2385. }
  2386. function proxyNormalSlot(slots, key) {
  2387. return function () { return slots[key]; }
  2388. }
  2389. /* */
  2390. /**
  2391. * Runtime helper for rendering v-for lists.
  2392. */
  2393. function renderList (
  2394. val,
  2395. render
  2396. ) {
  2397. var ret, i, l, keys, key;
  2398. if (Array.isArray(val) || typeof val === 'string') {
  2399. ret = new Array(val.length);
  2400. for (i = 0, l = val.length; i < l; i++) {
  2401. ret[i] = render(val[i], i);
  2402. }
  2403. } else if (typeof val === 'number') {
  2404. ret = new Array(val);
  2405. for (i = 0; i < val; i++) {
  2406. ret[i] = render(i + 1, i);
  2407. }
  2408. } else if (isObject(val)) {
  2409. if (hasSymbol && val[Symbol.iterator]) {
  2410. ret = [];
  2411. var iterator = val[Symbol.iterator]();
  2412. var result = iterator.next();
  2413. while (!result.done) {
  2414. ret.push(render(result.value, ret.length));
  2415. result = iterator.next();
  2416. }
  2417. } else {
  2418. keys = Object.keys(val);
  2419. ret = new Array(keys.length);
  2420. for (i = 0, l = keys.length; i < l; i++) {
  2421. key = keys[i];
  2422. ret[i] = render(val[key], key, i);
  2423. }
  2424. }
  2425. }
  2426. if (!isDef(ret)) {
  2427. ret = [];
  2428. }
  2429. (ret)._isVList = true;
  2430. return ret
  2431. }
  2432. /* */
  2433. /**
  2434. * Runtime helper for rendering <slot>
  2435. */
  2436. function renderSlot (
  2437. name,
  2438. fallbackRender,
  2439. props,
  2440. bindObject
  2441. ) {
  2442. var scopedSlotFn = this.$scopedSlots[name];
  2443. var nodes;
  2444. if (scopedSlotFn) {
  2445. // scoped slot
  2446. props = props || {};
  2447. if (bindObject) {
  2448. if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) {
  2449. warn('slot v-bind without argument expects an Object', this);
  2450. }
  2451. props = extend(extend({}, bindObject), props);
  2452. }
  2453. nodes =
  2454. scopedSlotFn(props) ||
  2455. (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
  2456. } else {
  2457. nodes =
  2458. this.$slots[name] ||
  2459. (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
  2460. }
  2461. var target = props && props.slot;
  2462. if (target) {
  2463. return this.$createElement('template', { slot: target }, nodes)
  2464. } else {
  2465. return nodes
  2466. }
  2467. }
  2468. /* */
  2469. /**
  2470. * Runtime helper for resolving filters
  2471. */
  2472. function resolveFilter (id) {
  2473. return resolveAsset(this.$options, 'filters', id, true) || identity
  2474. }
  2475. /* */
  2476. function isKeyNotMatch (expect, actual) {
  2477. if (Array.isArray(expect)) {
  2478. return expect.indexOf(actual) === -1
  2479. } else {
  2480. return expect !== actual
  2481. }
  2482. }
  2483. /**
  2484. * Runtime helper for checking keyCodes from config.
  2485. * exposed as Vue.prototype._k
  2486. * passing in eventKeyName as last argument separately for backwards compat
  2487. */
  2488. function checkKeyCodes (
  2489. eventKeyCode,
  2490. key,
  2491. builtInKeyCode,
  2492. eventKeyName,
  2493. builtInKeyName
  2494. ) {
  2495. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  2496. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  2497. return isKeyNotMatch(builtInKeyName, eventKeyName)
  2498. } else if (mappedKeyCode) {
  2499. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  2500. } else if (eventKeyName) {
  2501. return hyphenate(eventKeyName) !== key
  2502. }
  2503. return eventKeyCode === undefined
  2504. }
  2505. /* */
  2506. /**
  2507. * Runtime helper for merging v-bind="object" into a VNode's data.
  2508. */
  2509. function bindObjectProps (
  2510. data,
  2511. tag,
  2512. value,
  2513. asProp,
  2514. isSync
  2515. ) {
  2516. if (value) {
  2517. if (!isObject(value)) {
  2518. process.env.NODE_ENV !== 'production' && warn(
  2519. 'v-bind without argument expects an Object or Array value',
  2520. this
  2521. );
  2522. } else {
  2523. if (Array.isArray(value)) {
  2524. value = toObject(value);
  2525. }
  2526. var hash;
  2527. var loop = function ( key ) {
  2528. if (
  2529. key === 'class' ||
  2530. key === 'style' ||
  2531. isReservedAttribute(key)
  2532. ) {
  2533. hash = data;
  2534. } else {
  2535. var type = data.attrs && data.attrs.type;
  2536. hash = asProp || config.mustUseProp(tag, type, key)
  2537. ? data.domProps || (data.domProps = {})
  2538. : data.attrs || (data.attrs = {});
  2539. }
  2540. var camelizedKey = camelize(key);
  2541. var hyphenatedKey = hyphenate(key);
  2542. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  2543. hash[key] = value[key];
  2544. if (isSync) {
  2545. var on = data.on || (data.on = {});
  2546. on[("update:" + key)] = function ($event) {
  2547. value[key] = $event;
  2548. };
  2549. }
  2550. }
  2551. };
  2552. for (var key in value) loop( key );
  2553. }
  2554. }
  2555. return data
  2556. }
  2557. /* */
  2558. /**
  2559. * Runtime helper for rendering static trees.
  2560. */
  2561. function renderStatic (
  2562. index,
  2563. isInFor
  2564. ) {
  2565. var cached = this._staticTrees || (this._staticTrees = []);
  2566. var tree = cached[index];
  2567. // if has already-rendered static tree and not inside v-for,
  2568. // we can reuse the same tree.
  2569. if (tree && !isInFor) {
  2570. return tree
  2571. }
  2572. // otherwise, render a fresh tree.
  2573. tree = cached[index] = this.$options.staticRenderFns[index].call(
  2574. this._renderProxy,
  2575. null,
  2576. this // for render fns generated for functional component templates
  2577. );
  2578. markStatic(tree, ("__static__" + index), false);
  2579. return tree
  2580. }
  2581. /**
  2582. * Runtime helper for v-once.
  2583. * Effectively it means marking the node as static with a unique key.
  2584. */
  2585. function markOnce (
  2586. tree,
  2587. index,
  2588. key
  2589. ) {
  2590. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  2591. return tree
  2592. }
  2593. function markStatic (
  2594. tree,
  2595. key,
  2596. isOnce
  2597. ) {
  2598. if (Array.isArray(tree)) {
  2599. for (var i = 0; i < tree.length; i++) {
  2600. if (tree[i] && typeof tree[i] !== 'string') {
  2601. markStaticNode(tree[i], (key + "_" + i), isOnce);
  2602. }
  2603. }
  2604. } else {
  2605. markStaticNode(tree, key, isOnce);
  2606. }
  2607. }
  2608. function markStaticNode (node, key, isOnce) {
  2609. node.isStatic = true;
  2610. node.key = key;
  2611. node.isOnce = isOnce;
  2612. }
  2613. /* */
  2614. function bindObjectListeners (data, value) {
  2615. if (value) {
  2616. if (!isPlainObject(value)) {
  2617. process.env.NODE_ENV !== 'production' && warn(
  2618. 'v-on without argument expects an Object value',
  2619. this
  2620. );
  2621. } else {
  2622. var on = data.on = data.on ? extend({}, data.on) : {};
  2623. for (var key in value) {
  2624. var existing = on[key];
  2625. var ours = value[key];
  2626. on[key] = existing ? [].concat(existing, ours) : ours;
  2627. }
  2628. }
  2629. }
  2630. return data
  2631. }
  2632. /* */
  2633. function resolveScopedSlots (
  2634. fns, // see flow/vnode
  2635. res,
  2636. // the following are added in 2.6
  2637. hasDynamicKeys,
  2638. contentHashKey
  2639. ) {
  2640. res = res || { $stable: !hasDynamicKeys };
  2641. for (var i = 0; i < fns.length; i++) {
  2642. var slot = fns[i];
  2643. if (Array.isArray(slot)) {
  2644. resolveScopedSlots(slot, res, hasDynamicKeys);
  2645. } else if (slot) {
  2646. // marker for reverse proxying v-slot without scope on this.$slots
  2647. if (slot.proxy) {
  2648. slot.fn.proxy = true;
  2649. }
  2650. res[slot.key] = slot.fn;
  2651. }
  2652. }
  2653. if (contentHashKey) {
  2654. (res).$key = contentHashKey;
  2655. }
  2656. return res
  2657. }
  2658. /* */
  2659. function bindDynamicKeys (baseObj, values) {
  2660. for (var i = 0; i < values.length; i += 2) {
  2661. var key = values[i];
  2662. if (typeof key === 'string' && key) {
  2663. baseObj[values[i]] = values[i + 1];
  2664. } else if (process.env.NODE_ENV !== 'production' && key !== '' && key !== null) {
  2665. // null is a special value for explicitly removing a binding
  2666. warn(
  2667. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  2668. this
  2669. );
  2670. }
  2671. }
  2672. return baseObj
  2673. }
  2674. // helper to dynamically append modifier runtime markers to event names.
  2675. // ensure only append when value is already string, otherwise it will be cast
  2676. // to string and cause the type check to miss.
  2677. function prependModifier (value, symbol) {
  2678. return typeof value === 'string' ? symbol + value : value
  2679. }
  2680. /* */
  2681. function installRenderHelpers (target) {
  2682. target._o = markOnce;
  2683. target._n = toNumber;
  2684. target._s = toString;
  2685. target._l = renderList;
  2686. target._t = renderSlot;
  2687. target._q = looseEqual;
  2688. target._i = looseIndexOf;
  2689. target._m = renderStatic;
  2690. target._f = resolveFilter;
  2691. target._k = checkKeyCodes;
  2692. target._b = bindObjectProps;
  2693. target._v = createTextVNode;
  2694. target._e = createEmptyVNode;
  2695. target._u = resolveScopedSlots;
  2696. target._g = bindObjectListeners;
  2697. target._d = bindDynamicKeys;
  2698. target._p = prependModifier;
  2699. }
  2700. /* */
  2701. function FunctionalRenderContext (
  2702. data,
  2703. props,
  2704. children,
  2705. parent,
  2706. Ctor
  2707. ) {
  2708. var this$1 = this;
  2709. var options = Ctor.options;
  2710. // ensure the createElement function in functional components
  2711. // gets a unique context - this is necessary for correct named slot check
  2712. var contextVm;
  2713. if (hasOwn(parent, '_uid')) {
  2714. contextVm = Object.create(parent);
  2715. // $flow-disable-line
  2716. contextVm._original = parent;
  2717. } else {
  2718. // the context vm passed in is a functional context as well.
  2719. // in this case we want to make sure we are able to get a hold to the
  2720. // real context instance.
  2721. contextVm = parent;
  2722. // $flow-disable-line
  2723. parent = parent._original;
  2724. }
  2725. var isCompiled = isTrue(options._compiled);
  2726. var needNormalization = !isCompiled;
  2727. this.data = data;
  2728. this.props = props;
  2729. this.children = children;
  2730. this.parent = parent;
  2731. this.listeners = data.on || emptyObject;
  2732. this.injections = resolveInject(options.inject, parent);
  2733. this.slots = function () {
  2734. if (!this$1.$slots) {
  2735. normalizeScopedSlots(
  2736. data.scopedSlots,
  2737. this$1.$slots = resolveSlots(children, parent)
  2738. );
  2739. }
  2740. return this$1.$slots
  2741. };
  2742. Object.defineProperty(this, 'scopedSlots', ({
  2743. enumerable: true,
  2744. get: function get () {
  2745. return normalizeScopedSlots(data.scopedSlots, this.slots())
  2746. }
  2747. }));
  2748. // support for compiled functional template
  2749. if (isCompiled) {
  2750. // exposing $options for renderStatic()
  2751. this.$options = options;
  2752. // pre-resolve slots for renderSlot()
  2753. this.$slots = this.slots();
  2754. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  2755. }
  2756. if (options._scopeId) {
  2757. this._c = function (a, b, c, d) {
  2758. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  2759. if (vnode && !Array.isArray(vnode)) {
  2760. vnode.fnScopeId = options._scopeId;
  2761. vnode.fnContext = parent;
  2762. }
  2763. return vnode
  2764. };
  2765. } else {
  2766. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  2767. }
  2768. }
  2769. installRenderHelpers(FunctionalRenderContext.prototype);
  2770. function createFunctionalComponent (
  2771. Ctor,
  2772. propsData,
  2773. data,
  2774. contextVm,
  2775. children
  2776. ) {
  2777. var options = Ctor.options;
  2778. var props = {};
  2779. var propOptions = options.props;
  2780. if (isDef(propOptions)) {
  2781. for (var key in propOptions) {
  2782. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  2783. }
  2784. } else {
  2785. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  2786. if (isDef(data.props)) { mergeProps(props, data.props); }
  2787. }
  2788. var renderContext = new FunctionalRenderContext(
  2789. data,
  2790. props,
  2791. children,
  2792. contextVm,
  2793. Ctor
  2794. );
  2795. var vnode = options.render.call(null, renderContext._c, renderContext);
  2796. if (vnode instanceof VNode) {
  2797. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  2798. } else if (Array.isArray(vnode)) {
  2799. var vnodes = normalizeChildren(vnode) || [];
  2800. var res = new Array(vnodes.length);
  2801. for (var i = 0; i < vnodes.length; i++) {
  2802. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  2803. }
  2804. return res
  2805. }
  2806. }
  2807. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  2808. // #7817 clone node before setting fnContext, otherwise if the node is reused
  2809. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  2810. // that should not be matched to match.
  2811. var clone = cloneVNode(vnode);
  2812. clone.fnContext = contextVm;
  2813. clone.fnOptions = options;
  2814. if (process.env.NODE_ENV !== 'production') {
  2815. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  2816. }
  2817. if (data.slot) {
  2818. (clone.data || (clone.data = {})).slot = data.slot;
  2819. }
  2820. return clone
  2821. }
  2822. function mergeProps (to, from) {
  2823. for (var key in from) {
  2824. to[camelize(key)] = from[key];
  2825. }
  2826. }
  2827. /* */
  2828. /* */
  2829. /* */
  2830. /* */
  2831. // inline hooks to be invoked on component VNodes during patch
  2832. var componentVNodeHooks = {
  2833. init: function init (vnode, hydrating) {
  2834. if (
  2835. vnode.componentInstance &&
  2836. !vnode.componentInstance._isDestroyed &&
  2837. vnode.data.keepAlive
  2838. ) {
  2839. // kept-alive components, treat as a patch
  2840. var mountedNode = vnode; // work around flow
  2841. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  2842. } else {
  2843. var child = vnode.componentInstance = createComponentInstanceForVnode(
  2844. vnode,
  2845. activeInstance
  2846. );
  2847. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  2848. }
  2849. },
  2850. prepatch: function prepatch (oldVnode, vnode) {
  2851. var options = vnode.componentOptions;
  2852. var child = vnode.componentInstance = oldVnode.componentInstance;
  2853. updateChildComponent(
  2854. child,
  2855. options.propsData, // updated props
  2856. options.listeners, // updated listeners
  2857. vnode, // new parent vnode
  2858. options.children // new children
  2859. );
  2860. },
  2861. insert: function insert (vnode) {
  2862. var context = vnode.context;
  2863. var componentInstance = vnode.componentInstance;
  2864. if (!componentInstance._isMounted) {
  2865. componentInstance._isMounted = true;
  2866. callHook(componentInstance, 'mounted');
  2867. }
  2868. if (vnode.data.keepAlive) {
  2869. if (context._isMounted) {
  2870. // vue-router#1212
  2871. // During updates, a kept-alive component's child components may
  2872. // change, so directly walking the tree here may call activated hooks
  2873. // on incorrect children. Instead we push them into a queue which will
  2874. // be processed after the whole patch process ended.
  2875. queueActivatedComponent(componentInstance);
  2876. } else {
  2877. activateChildComponent(componentInstance, true /* direct */);
  2878. }
  2879. }
  2880. },
  2881. destroy: function destroy (vnode) {
  2882. var componentInstance = vnode.componentInstance;
  2883. if (!componentInstance._isDestroyed) {
  2884. if (!vnode.data.keepAlive) {
  2885. componentInstance.$destroy();
  2886. } else {
  2887. deactivateChildComponent(componentInstance, true /* direct */);
  2888. }
  2889. }
  2890. }
  2891. };
  2892. var hooksToMerge = Object.keys(componentVNodeHooks);
  2893. function createComponent (
  2894. Ctor,
  2895. data,
  2896. context,
  2897. children,
  2898. tag
  2899. ) {
  2900. if (isUndef(Ctor)) {
  2901. return
  2902. }
  2903. var baseCtor = context.$options._base;
  2904. // plain options object: turn it into a constructor
  2905. if (isObject(Ctor)) {
  2906. Ctor = baseCtor.extend(Ctor);
  2907. }
  2908. // if at this stage it's not a constructor or an async component factory,
  2909. // reject.
  2910. if (typeof Ctor !== 'function') {
  2911. if (process.env.NODE_ENV !== 'production') {
  2912. warn(("Invalid Component definition: " + (String(Ctor))), context);
  2913. }
  2914. return
  2915. }
  2916. // async component
  2917. var asyncFactory;
  2918. if (isUndef(Ctor.cid)) {
  2919. asyncFactory = Ctor;
  2920. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  2921. if (Ctor === undefined) {
  2922. // return a placeholder node for async component, which is rendered
  2923. // as a comment node but preserves all the raw information for the node.
  2924. // the information will be used for async server-rendering and hydration.
  2925. return createAsyncPlaceholder(
  2926. asyncFactory,
  2927. data,
  2928. context,
  2929. children,
  2930. tag
  2931. )
  2932. }
  2933. }
  2934. data = data || {};
  2935. // resolve constructor options in case global mixins are applied after
  2936. // component constructor creation
  2937. resolveConstructorOptions(Ctor);
  2938. // transform component v-model data into props & events
  2939. if (isDef(data.model)) {
  2940. transformModel(Ctor.options, data);
  2941. }
  2942. // extract props
  2943. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  2944. // functional component
  2945. if (isTrue(Ctor.options.functional)) {
  2946. return createFunctionalComponent(Ctor, propsData, data, context, children)
  2947. }
  2948. // extract listeners, since these needs to be treated as
  2949. // child component listeners instead of DOM listeners
  2950. var listeners = data.on;
  2951. // replace with listeners with .native modifier
  2952. // so it gets processed during parent component patch.
  2953. data.on = data.nativeOn;
  2954. if (isTrue(Ctor.options.abstract)) {
  2955. // abstract components do not keep anything
  2956. // other than props & listeners & slot
  2957. // work around flow
  2958. var slot = data.slot;
  2959. data = {};
  2960. if (slot) {
  2961. data.slot = slot;
  2962. }
  2963. }
  2964. // install component management hooks onto the placeholder node
  2965. installComponentHooks(data);
  2966. // return a placeholder vnode
  2967. var name = Ctor.options.name || tag;
  2968. var vnode = new VNode(
  2969. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  2970. data, undefined, undefined, undefined, context,
  2971. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  2972. asyncFactory
  2973. );
  2974. return vnode
  2975. }
  2976. function createComponentInstanceForVnode (
  2977. // we know it's MountedComponentVNode but flow doesn't
  2978. vnode,
  2979. // activeInstance in lifecycle state
  2980. parent
  2981. ) {
  2982. var options = {
  2983. _isComponent: true,
  2984. _parentVnode: vnode,
  2985. parent: parent
  2986. };
  2987. // check inline-template render functions
  2988. var inlineTemplate = vnode.data.inlineTemplate;
  2989. if (isDef(inlineTemplate)) {
  2990. options.render = inlineTemplate.render;
  2991. options.staticRenderFns = inlineTemplate.staticRenderFns;
  2992. }
  2993. return new vnode.componentOptions.Ctor(options)
  2994. }
  2995. function installComponentHooks (data) {
  2996. var hooks = data.hook || (data.hook = {});
  2997. for (var i = 0; i < hooksToMerge.length; i++) {
  2998. var key = hooksToMerge[i];
  2999. var existing = hooks[key];
  3000. var toMerge = componentVNodeHooks[key];
  3001. if (existing !== toMerge && !(existing && existing._merged)) {
  3002. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  3003. }
  3004. }
  3005. }
  3006. function mergeHook$1 (f1, f2) {
  3007. var merged = function (a, b) {
  3008. // flow complains about extra args which is why we use any
  3009. f1(a, b);
  3010. f2(a, b);
  3011. };
  3012. merged._merged = true;
  3013. return merged
  3014. }
  3015. // transform component v-model info (value and callback) into
  3016. // prop and event handler respectively.
  3017. function transformModel (options, data) {
  3018. var prop = (options.model && options.model.prop) || 'value';
  3019. var event = (options.model && options.model.event) || 'input'
  3020. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  3021. var on = data.on || (data.on = {});
  3022. var existing = on[event];
  3023. var callback = data.model.callback;
  3024. if (isDef(existing)) {
  3025. if (
  3026. Array.isArray(existing)
  3027. ? existing.indexOf(callback) === -1
  3028. : existing !== callback
  3029. ) {
  3030. on[event] = [callback].concat(existing);
  3031. }
  3032. } else {
  3033. on[event] = callback;
  3034. }
  3035. }
  3036. /* */
  3037. var SIMPLE_NORMALIZE = 1;
  3038. var ALWAYS_NORMALIZE = 2;
  3039. // wrapper function for providing a more flexible interface
  3040. // without getting yelled at by flow
  3041. function createElement (
  3042. context,
  3043. tag,
  3044. data,
  3045. children,
  3046. normalizationType,
  3047. alwaysNormalize
  3048. ) {
  3049. if (Array.isArray(data) || isPrimitive(data)) {
  3050. normalizationType = children;
  3051. children = data;
  3052. data = undefined;
  3053. }
  3054. if (isTrue(alwaysNormalize)) {
  3055. normalizationType = ALWAYS_NORMALIZE;
  3056. }
  3057. return _createElement(context, tag, data, children, normalizationType)
  3058. }
  3059. function _createElement (
  3060. context,
  3061. tag,
  3062. data,
  3063. children,
  3064. normalizationType
  3065. ) {
  3066. if (isDef(data) && isDef((data).__ob__)) {
  3067. process.env.NODE_ENV !== 'production' && warn(
  3068. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  3069. 'Always create fresh vnode data objects in each render!',
  3070. context
  3071. );
  3072. return createEmptyVNode()
  3073. }
  3074. // object syntax in v-bind
  3075. if (isDef(data) && isDef(data.is)) {
  3076. tag = data.is;
  3077. }
  3078. if (!tag) {
  3079. // in case of component :is set to falsy value
  3080. return createEmptyVNode()
  3081. }
  3082. // warn against non-primitive key
  3083. if (process.env.NODE_ENV !== 'production' &&
  3084. isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  3085. ) {
  3086. {
  3087. warn(
  3088. 'Avoid using non-primitive value as key, ' +
  3089. 'use string/number value instead.',
  3090. context
  3091. );
  3092. }
  3093. }
  3094. // support single function children as default scoped slot
  3095. if (Array.isArray(children) &&
  3096. typeof children[0] === 'function'
  3097. ) {
  3098. data = data || {};
  3099. data.scopedSlots = { default: children[0] };
  3100. children.length = 0;
  3101. }
  3102. if (normalizationType === ALWAYS_NORMALIZE) {
  3103. children = normalizeChildren(children);
  3104. } else if (normalizationType === SIMPLE_NORMALIZE) {
  3105. children = simpleNormalizeChildren(children);
  3106. }
  3107. var vnode, ns;
  3108. if (typeof tag === 'string') {
  3109. var Ctor;
  3110. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  3111. if (config.isReservedTag(tag)) {
  3112. // platform built-in elements
  3113. if (process.env.NODE_ENV !== 'production' && isDef(data) && isDef(data.nativeOn) && data.tag !== 'component') {
  3114. warn(
  3115. ("The .native modifier for v-on is only valid on components but it was used on <" + tag + ">."),
  3116. context
  3117. );
  3118. }
  3119. vnode = new VNode(
  3120. config.parsePlatformTagName(tag), data, children,
  3121. undefined, undefined, context
  3122. );
  3123. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  3124. // component
  3125. vnode = createComponent(Ctor, data, context, children, tag);
  3126. } else {
  3127. // unknown or unlisted namespaced elements
  3128. // check at runtime because it may get assigned a namespace when its
  3129. // parent normalizes children
  3130. vnode = new VNode(
  3131. tag, data, children,
  3132. undefined, undefined, context
  3133. );
  3134. }
  3135. } else {
  3136. // direct component options / constructor
  3137. vnode = createComponent(tag, data, context, children);
  3138. }
  3139. if (Array.isArray(vnode)) {
  3140. return vnode
  3141. } else if (isDef(vnode)) {
  3142. if (isDef(ns)) { applyNS(vnode, ns); }
  3143. if (isDef(data)) { registerDeepBindings(data); }
  3144. return vnode
  3145. } else {
  3146. return createEmptyVNode()
  3147. }
  3148. }
  3149. function applyNS (vnode, ns, force) {
  3150. vnode.ns = ns;
  3151. if (vnode.tag === 'foreignObject') {
  3152. // use default namespace inside foreignObject
  3153. ns = undefined;
  3154. force = true;
  3155. }
  3156. if (isDef(vnode.children)) {
  3157. for (var i = 0, l = vnode.children.length; i < l; i++) {
  3158. var child = vnode.children[i];
  3159. if (isDef(child.tag) && (
  3160. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  3161. applyNS(child, ns, force);
  3162. }
  3163. }
  3164. }
  3165. }
  3166. // ref #5318
  3167. // necessary to ensure parent re-render when deep bindings like :style and
  3168. // :class are used on slot nodes
  3169. function registerDeepBindings (data) {
  3170. if (isObject(data.style)) {
  3171. traverse(data.style);
  3172. }
  3173. if (isObject(data.class)) {
  3174. traverse(data.class);
  3175. }
  3176. }
  3177. /* */
  3178. function initRender (vm) {
  3179. vm._vnode = null; // the root of the child tree
  3180. vm._staticTrees = null; // v-once cached trees
  3181. var options = vm.$options;
  3182. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  3183. var renderContext = parentVnode && parentVnode.context;
  3184. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  3185. vm.$scopedSlots = emptyObject;
  3186. // bind the createElement fn to this instance
  3187. // so that we get proper render context inside it.
  3188. // args order: tag, data, children, normalizationType, alwaysNormalize
  3189. // internal version is used by render functions compiled from templates
  3190. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  3191. // normalization is always applied for the public version, used in
  3192. // user-written render functions.
  3193. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  3194. // $attrs & $listeners are exposed for easier HOC creation.
  3195. // they need to be reactive so that HOCs using them are always updated
  3196. var parentData = parentVnode && parentVnode.data;
  3197. /* istanbul ignore else */
  3198. if (process.env.NODE_ENV !== 'production') {
  3199. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  3200. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  3201. }, true);
  3202. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  3203. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  3204. }, true);
  3205. } else {
  3206. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
  3207. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, null, true);
  3208. }
  3209. }
  3210. var currentRenderingInstance = null;
  3211. function renderMixin (Vue) {
  3212. // install runtime convenience helpers
  3213. installRenderHelpers(Vue.prototype);
  3214. Vue.prototype.$nextTick = function (fn) {
  3215. return nextTick(fn, this)
  3216. };
  3217. Vue.prototype._render = function () {
  3218. var vm = this;
  3219. var ref = vm.$options;
  3220. var render = ref.render;
  3221. var _parentVnode = ref._parentVnode;
  3222. if (_parentVnode) {
  3223. vm.$scopedSlots = normalizeScopedSlots(
  3224. _parentVnode.data.scopedSlots,
  3225. vm.$slots,
  3226. vm.$scopedSlots
  3227. );
  3228. }
  3229. // set parent vnode. this allows render functions to have access
  3230. // to the data on the placeholder node.
  3231. vm.$vnode = _parentVnode;
  3232. // render self
  3233. var vnode;
  3234. try {
  3235. // There's no need to maintain a stack because all render fns are called
  3236. // separately from one another. Nested component's render fns are called
  3237. // when parent component is patched.
  3238. currentRenderingInstance = vm;
  3239. vnode = render.call(vm._renderProxy, vm.$createElement);
  3240. } catch (e) {
  3241. handleError(e, vm, "render");
  3242. // return error render result,
  3243. // or previous vnode to prevent render error causing blank component
  3244. /* istanbul ignore else */
  3245. if (process.env.NODE_ENV !== 'production' && vm.$options.renderError) {
  3246. try {
  3247. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  3248. } catch (e) {
  3249. handleError(e, vm, "renderError");
  3250. vnode = vm._vnode;
  3251. }
  3252. } else {
  3253. vnode = vm._vnode;
  3254. }
  3255. } finally {
  3256. currentRenderingInstance = null;
  3257. }
  3258. // if the returned array contains only a single node, allow it
  3259. if (Array.isArray(vnode) && vnode.length === 1) {
  3260. vnode = vnode[0];
  3261. }
  3262. // return empty vnode in case the render function errored out
  3263. if (!(vnode instanceof VNode)) {
  3264. if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
  3265. warn(
  3266. 'Multiple root nodes returned from render function. Render function ' +
  3267. 'should return a single root node.',
  3268. vm
  3269. );
  3270. }
  3271. vnode = createEmptyVNode();
  3272. }
  3273. // set parent
  3274. vnode.parent = _parentVnode;
  3275. return vnode
  3276. };
  3277. }
  3278. /* */
  3279. function ensureCtor (comp, base) {
  3280. if (
  3281. comp.__esModule ||
  3282. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  3283. ) {
  3284. comp = comp.default;
  3285. }
  3286. return isObject(comp)
  3287. ? base.extend(comp)
  3288. : comp
  3289. }
  3290. function createAsyncPlaceholder (
  3291. factory,
  3292. data,
  3293. context,
  3294. children,
  3295. tag
  3296. ) {
  3297. var node = createEmptyVNode();
  3298. node.asyncFactory = factory;
  3299. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  3300. return node
  3301. }
  3302. function resolveAsyncComponent (
  3303. factory,
  3304. baseCtor
  3305. ) {
  3306. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  3307. return factory.errorComp
  3308. }
  3309. if (isDef(factory.resolved)) {
  3310. return factory.resolved
  3311. }
  3312. var owner = currentRenderingInstance;
  3313. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  3314. // already pending
  3315. factory.owners.push(owner);
  3316. }
  3317. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  3318. return factory.loadingComp
  3319. }
  3320. if (owner && !isDef(factory.owners)) {
  3321. var owners = factory.owners = [owner];
  3322. var sync = true;
  3323. var timerLoading = null;
  3324. var timerTimeout = null
  3325. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  3326. var forceRender = function (renderCompleted) {
  3327. for (var i = 0, l = owners.length; i < l; i++) {
  3328. (owners[i]).$forceUpdate();
  3329. }
  3330. if (renderCompleted) {
  3331. owners.length = 0;
  3332. if (timerLoading !== null) {
  3333. clearTimeout(timerLoading);
  3334. timerLoading = null;
  3335. }
  3336. if (timerTimeout !== null) {
  3337. clearTimeout(timerTimeout);
  3338. timerTimeout = null;
  3339. }
  3340. }
  3341. };
  3342. var resolve = once(function (res) {
  3343. // cache resolved
  3344. factory.resolved = ensureCtor(res, baseCtor);
  3345. // invoke callbacks only if this is not a synchronous resolve
  3346. // (async resolves are shimmed as synchronous during SSR)
  3347. if (!sync) {
  3348. forceRender(true);
  3349. } else {
  3350. owners.length = 0;
  3351. }
  3352. });
  3353. var reject = once(function (reason) {
  3354. process.env.NODE_ENV !== 'production' && warn(
  3355. "Failed to resolve async component: " + (String(factory)) +
  3356. (reason ? ("\nReason: " + reason) : '')
  3357. );
  3358. if (isDef(factory.errorComp)) {
  3359. factory.error = true;
  3360. forceRender(true);
  3361. }
  3362. });
  3363. var res = factory(resolve, reject);
  3364. if (isObject(res)) {
  3365. if (isPromise(res)) {
  3366. // () => Promise
  3367. if (isUndef(factory.resolved)) {
  3368. res.then(resolve, reject);
  3369. }
  3370. } else if (isPromise(res.component)) {
  3371. res.component.then(resolve, reject);
  3372. if (isDef(res.error)) {
  3373. factory.errorComp = ensureCtor(res.error, baseCtor);
  3374. }
  3375. if (isDef(res.loading)) {
  3376. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  3377. if (res.delay === 0) {
  3378. factory.loading = true;
  3379. } else {
  3380. timerLoading = setTimeout(function () {
  3381. timerLoading = null;
  3382. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  3383. factory.loading = true;
  3384. forceRender(false);
  3385. }
  3386. }, res.delay || 200);
  3387. }
  3388. }
  3389. if (isDef(res.timeout)) {
  3390. timerTimeout = setTimeout(function () {
  3391. timerTimeout = null;
  3392. if (isUndef(factory.resolved)) {
  3393. reject(
  3394. process.env.NODE_ENV !== 'production'
  3395. ? ("timeout (" + (res.timeout) + "ms)")
  3396. : null
  3397. );
  3398. }
  3399. }, res.timeout);
  3400. }
  3401. }
  3402. }
  3403. sync = false;
  3404. // return in case resolved synchronously
  3405. return factory.loading
  3406. ? factory.loadingComp
  3407. : factory.resolved
  3408. }
  3409. }
  3410. /* */
  3411. function getFirstComponentChild (children) {
  3412. if (Array.isArray(children)) {
  3413. for (var i = 0; i < children.length; i++) {
  3414. var c = children[i];
  3415. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  3416. return c
  3417. }
  3418. }
  3419. }
  3420. }
  3421. /* */
  3422. /* */
  3423. function initEvents (vm) {
  3424. vm._events = Object.create(null);
  3425. vm._hasHookEvent = false;
  3426. // init parent attached events
  3427. var listeners = vm.$options._parentListeners;
  3428. if (listeners) {
  3429. updateComponentListeners(vm, listeners);
  3430. }
  3431. }
  3432. var target;
  3433. function add (event, fn) {
  3434. target.$on(event, fn);
  3435. }
  3436. function remove$1 (event, fn) {
  3437. target.$off(event, fn);
  3438. }
  3439. function createOnceHandler (event, fn) {
  3440. var _target = target;
  3441. return function onceHandler () {
  3442. var res = fn.apply(null, arguments);
  3443. if (res !== null) {
  3444. _target.$off(event, onceHandler);
  3445. }
  3446. }
  3447. }
  3448. function updateComponentListeners (
  3449. vm,
  3450. listeners,
  3451. oldListeners
  3452. ) {
  3453. target = vm;
  3454. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  3455. target = undefined;
  3456. }
  3457. function eventsMixin (Vue) {
  3458. var hookRE = /^hook:/;
  3459. Vue.prototype.$on = function (event, fn) {
  3460. var vm = this;
  3461. if (Array.isArray(event)) {
  3462. for (var i = 0, l = event.length; i < l; i++) {
  3463. vm.$on(event[i], fn);
  3464. }
  3465. } else {
  3466. (vm._events[event] || (vm._events[event] = [])).push(fn);
  3467. // optimize hook:event cost by using a boolean flag marked at registration
  3468. // instead of a hash lookup
  3469. if (hookRE.test(event)) {
  3470. vm._hasHookEvent = true;
  3471. }
  3472. }
  3473. return vm
  3474. };
  3475. Vue.prototype.$once = function (event, fn) {
  3476. var vm = this;
  3477. function on () {
  3478. vm.$off(event, on);
  3479. fn.apply(vm, arguments);
  3480. }
  3481. on.fn = fn;
  3482. vm.$on(event, on);
  3483. return vm
  3484. };
  3485. Vue.prototype.$off = function (event, fn) {
  3486. var vm = this;
  3487. // all
  3488. if (!arguments.length) {
  3489. vm._events = Object.create(null);
  3490. return vm
  3491. }
  3492. // array of events
  3493. if (Array.isArray(event)) {
  3494. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  3495. vm.$off(event[i$1], fn);
  3496. }
  3497. return vm
  3498. }
  3499. // specific event
  3500. var cbs = vm._events[event];
  3501. if (!cbs) {
  3502. return vm
  3503. }
  3504. if (!fn) {
  3505. vm._events[event] = null;
  3506. return vm
  3507. }
  3508. // specific handler
  3509. var cb;
  3510. var i = cbs.length;
  3511. while (i--) {
  3512. cb = cbs[i];
  3513. if (cb === fn || cb.fn === fn) {
  3514. cbs.splice(i, 1);
  3515. break
  3516. }
  3517. }
  3518. return vm
  3519. };
  3520. Vue.prototype.$emit = function (event) {
  3521. var vm = this;
  3522. if (process.env.NODE_ENV !== 'production') {
  3523. var lowerCaseEvent = event.toLowerCase();
  3524. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  3525. tip(
  3526. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  3527. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  3528. "Note that HTML attributes are case-insensitive and you cannot use " +
  3529. "v-on to listen to camelCase events when using in-DOM templates. " +
  3530. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  3531. );
  3532. }
  3533. }
  3534. var cbs = vm._events[event];
  3535. if (cbs) {
  3536. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  3537. var args = toArray(arguments, 1);
  3538. var info = "event handler for \"" + event + "\"";
  3539. for (var i = 0, l = cbs.length; i < l; i++) {
  3540. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  3541. }
  3542. }
  3543. return vm
  3544. };
  3545. }
  3546. /* */
  3547. var activeInstance = null;
  3548. var isUpdatingChildComponent = false;
  3549. function setActiveInstance(vm) {
  3550. var prevActiveInstance = activeInstance;
  3551. activeInstance = vm;
  3552. return function () {
  3553. activeInstance = prevActiveInstance;
  3554. }
  3555. }
  3556. function initLifecycle (vm) {
  3557. var options = vm.$options;
  3558. // locate first non-abstract parent
  3559. var parent = options.parent;
  3560. if (parent && !options.abstract) {
  3561. while (parent.$options.abstract && parent.$parent) {
  3562. parent = parent.$parent;
  3563. }
  3564. parent.$children.push(vm);
  3565. }
  3566. vm.$parent = parent;
  3567. vm.$root = parent ? parent.$root : vm;
  3568. vm.$children = [];
  3569. vm.$refs = {};
  3570. vm._watcher = null;
  3571. vm._inactive = null;
  3572. vm._directInactive = false;
  3573. vm._isMounted = false;
  3574. vm._isDestroyed = false;
  3575. vm._isBeingDestroyed = false;
  3576. }
  3577. function lifecycleMixin (Vue) {
  3578. Vue.prototype._update = function (vnode, hydrating) {
  3579. var vm = this;
  3580. var prevEl = vm.$el;
  3581. var prevVnode = vm._vnode;
  3582. var restoreActiveInstance = setActiveInstance(vm);
  3583. vm._vnode = vnode;
  3584. // Vue.prototype.__patch__ is injected in entry points
  3585. // based on the rendering backend used.
  3586. if (!prevVnode) {
  3587. // initial render
  3588. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  3589. } else {
  3590. // updates
  3591. vm.$el = vm.__patch__(prevVnode, vnode);
  3592. }
  3593. restoreActiveInstance();
  3594. // update __vue__ reference
  3595. if (prevEl) {
  3596. prevEl.__vue__ = null;
  3597. }
  3598. if (vm.$el) {
  3599. vm.$el.__vue__ = vm;
  3600. }
  3601. // if parent is an HOC, update its $el as well
  3602. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  3603. vm.$parent.$el = vm.$el;
  3604. }
  3605. // updated hook is called by the scheduler to ensure that children are
  3606. // updated in a parent's updated hook.
  3607. };
  3608. Vue.prototype.$forceUpdate = function () {
  3609. var vm = this;
  3610. if (vm._watcher) {
  3611. vm._watcher.update();
  3612. }
  3613. };
  3614. Vue.prototype.$destroy = function () {
  3615. var vm = this;
  3616. if (vm._isBeingDestroyed) {
  3617. return
  3618. }
  3619. callHook(vm, 'beforeDestroy');
  3620. vm._isBeingDestroyed = true;
  3621. // remove self from parent
  3622. var parent = vm.$parent;
  3623. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  3624. remove(parent.$children, vm);
  3625. }
  3626. // teardown watchers
  3627. if (vm._watcher) {
  3628. vm._watcher.teardown();
  3629. }
  3630. var i = vm._watchers.length;
  3631. while (i--) {
  3632. vm._watchers[i].teardown();
  3633. }
  3634. // remove reference from data ob
  3635. // frozen object may not have observer.
  3636. if (vm._data.__ob__) {
  3637. vm._data.__ob__.vmCount--;
  3638. }
  3639. // call the last hook...
  3640. vm._isDestroyed = true;
  3641. // invoke destroy hooks on current rendered tree
  3642. vm.__patch__(vm._vnode, null);
  3643. // fire destroyed hook
  3644. callHook(vm, 'destroyed');
  3645. // turn off all instance listeners.
  3646. vm.$off();
  3647. // remove __vue__ reference
  3648. if (vm.$el) {
  3649. vm.$el.__vue__ = null;
  3650. }
  3651. // release circular reference (#6759)
  3652. if (vm.$vnode) {
  3653. vm.$vnode.parent = null;
  3654. }
  3655. };
  3656. }
  3657. function mountComponent (
  3658. vm,
  3659. el,
  3660. hydrating
  3661. ) {
  3662. vm.$el = el;
  3663. if (!vm.$options.render) {
  3664. vm.$options.render = createEmptyVNode;
  3665. if (process.env.NODE_ENV !== 'production') {
  3666. /* istanbul ignore if */
  3667. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  3668. vm.$options.el || el) {
  3669. warn(
  3670. 'You are using the runtime-only build of Vue where the template ' +
  3671. 'compiler is not available. Either pre-compile the templates into ' +
  3672. 'render functions, or use the compiler-included build.',
  3673. vm
  3674. );
  3675. } else {
  3676. warn(
  3677. 'Failed to mount component: template or render function not defined.',
  3678. vm
  3679. );
  3680. }
  3681. }
  3682. }
  3683. callHook(vm, 'beforeMount');
  3684. var updateComponent;
  3685. /* istanbul ignore if */
  3686. if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
  3687. updateComponent = function () {
  3688. var name = vm._name;
  3689. var id = vm._uid;
  3690. var startTag = "vue-perf-start:" + id;
  3691. var endTag = "vue-perf-end:" + id;
  3692. mark(startTag);
  3693. var vnode = vm._render();
  3694. mark(endTag);
  3695. measure(("vue " + name + " render"), startTag, endTag);
  3696. mark(startTag);
  3697. vm._update(vnode, hydrating);
  3698. mark(endTag);
  3699. measure(("vue " + name + " patch"), startTag, endTag);
  3700. };
  3701. } else {
  3702. updateComponent = function () {
  3703. vm._update(vm._render(), hydrating);
  3704. };
  3705. }
  3706. // we set this to vm._watcher inside the watcher's constructor
  3707. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  3708. // component's mounted hook), which relies on vm._watcher being already defined
  3709. new Watcher(vm, updateComponent, noop, {
  3710. before: function before () {
  3711. if (vm._isMounted && !vm._isDestroyed) {
  3712. callHook(vm, 'beforeUpdate');
  3713. }
  3714. }
  3715. }, true /* isRenderWatcher */);
  3716. hydrating = false;
  3717. // manually mounted instance, call mounted on self
  3718. // mounted is called for render-created child components in its inserted hook
  3719. if (vm.$vnode == null) {
  3720. vm._isMounted = true;
  3721. callHook(vm, 'mounted');
  3722. }
  3723. return vm
  3724. }
  3725. function updateChildComponent (
  3726. vm,
  3727. propsData,
  3728. listeners,
  3729. parentVnode,
  3730. renderChildren
  3731. ) {
  3732. if (process.env.NODE_ENV !== 'production') {
  3733. isUpdatingChildComponent = true;
  3734. }
  3735. // determine whether component has slot children
  3736. // we need to do this before overwriting $options._renderChildren.
  3737. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3738. // dynamic slot names). Static scoped slots compiled from template has the
  3739. // "$stable" marker.
  3740. var newScopedSlots = parentVnode.data.scopedSlots;
  3741. var oldScopedSlots = vm.$scopedSlots;
  3742. var hasDynamicScopedSlot = !!(
  3743. (newScopedSlots && !newScopedSlots.$stable) ||
  3744. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3745. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  3746. (!newScopedSlots && vm.$scopedSlots.$key)
  3747. );
  3748. // Any static slot children from the parent may have changed during parent's
  3749. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3750. // update is necessary to ensure correctness.
  3751. var needsForceUpdate = !!(
  3752. renderChildren || // has new static slots
  3753. vm.$options._renderChildren || // has old static slots
  3754. hasDynamicScopedSlot
  3755. );
  3756. vm.$options._parentVnode = parentVnode;
  3757. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3758. if (vm._vnode) { // update child tree's parent
  3759. vm._vnode.parent = parentVnode;
  3760. }
  3761. vm.$options._renderChildren = renderChildren;
  3762. // update $attrs and $listeners hash
  3763. // these are also reactive so they may trigger child update if the child
  3764. // used them during render
  3765. vm.$attrs = parentVnode.data.attrs || emptyObject;
  3766. vm.$listeners = listeners || emptyObject;
  3767. // update props
  3768. if (propsData && vm.$options.props) {
  3769. toggleObserving(false);
  3770. var props = vm._props;
  3771. var propKeys = vm.$options._propKeys || [];
  3772. for (var i = 0; i < propKeys.length; i++) {
  3773. var key = propKeys[i];
  3774. var propOptions = vm.$options.props; // wtf flow?
  3775. props[key] = validateProp(key, propOptions, propsData, vm);
  3776. }
  3777. toggleObserving(true);
  3778. // keep a copy of raw propsData
  3779. vm.$options.propsData = propsData;
  3780. }
  3781. // update listeners
  3782. listeners = listeners || emptyObject;
  3783. var oldListeners = vm.$options._parentListeners;
  3784. vm.$options._parentListeners = listeners;
  3785. updateComponentListeners(vm, listeners, oldListeners);
  3786. // resolve slots + force update if has children
  3787. if (needsForceUpdate) {
  3788. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3789. vm.$forceUpdate();
  3790. }
  3791. if (process.env.NODE_ENV !== 'production') {
  3792. isUpdatingChildComponent = false;
  3793. }
  3794. }
  3795. function isInInactiveTree (vm) {
  3796. while (vm && (vm = vm.$parent)) {
  3797. if (vm._inactive) { return true }
  3798. }
  3799. return false
  3800. }
  3801. function activateChildComponent (vm, direct) {
  3802. if (direct) {
  3803. vm._directInactive = false;
  3804. if (isInInactiveTree(vm)) {
  3805. return
  3806. }
  3807. } else if (vm._directInactive) {
  3808. return
  3809. }
  3810. if (vm._inactive || vm._inactive === null) {
  3811. vm._inactive = false;
  3812. for (var i = 0; i < vm.$children.length; i++) {
  3813. activateChildComponent(vm.$children[i]);
  3814. }
  3815. callHook(vm, 'activated');
  3816. }
  3817. }
  3818. function deactivateChildComponent (vm, direct) {
  3819. if (direct) {
  3820. vm._directInactive = true;
  3821. if (isInInactiveTree(vm)) {
  3822. return
  3823. }
  3824. }
  3825. if (!vm._inactive) {
  3826. vm._inactive = true;
  3827. for (var i = 0; i < vm.$children.length; i++) {
  3828. deactivateChildComponent(vm.$children[i]);
  3829. }
  3830. callHook(vm, 'deactivated');
  3831. }
  3832. }
  3833. function callHook (vm, hook) {
  3834. // #7573 disable dep collection when invoking lifecycle hooks
  3835. pushTarget();
  3836. var handlers = vm.$options[hook];
  3837. var info = hook + " hook";
  3838. if (handlers) {
  3839. for (var i = 0, j = handlers.length; i < j; i++) {
  3840. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  3841. }
  3842. }
  3843. if (vm._hasHookEvent) {
  3844. vm.$emit('hook:' + hook);
  3845. }
  3846. popTarget();
  3847. }
  3848. /* */
  3849. var MAX_UPDATE_COUNT = 100;
  3850. var queue = [];
  3851. var activatedChildren = [];
  3852. var has = {};
  3853. var circular = {};
  3854. var waiting = false;
  3855. var flushing = false;
  3856. var index = 0;
  3857. /**
  3858. * Reset the scheduler's state.
  3859. */
  3860. function resetSchedulerState () {
  3861. index = queue.length = activatedChildren.length = 0;
  3862. has = {};
  3863. if (process.env.NODE_ENV !== 'production') {
  3864. circular = {};
  3865. }
  3866. waiting = flushing = false;
  3867. }
  3868. // Async edge case #6566 requires saving the timestamp when event listeners are
  3869. // attached. However, calling performance.now() has a perf overhead especially
  3870. // if the page has thousands of event listeners. Instead, we take a timestamp
  3871. // every time the scheduler flushes and use that for all event listeners
  3872. // attached during that flush.
  3873. var currentFlushTimestamp = 0;
  3874. // Async edge case fix requires storing an event listener's attach timestamp.
  3875. var getNow = Date.now;
  3876. // Determine what event timestamp the browser is using. Annoyingly, the
  3877. // timestamp can either be hi-res (relative to page load) or low-res
  3878. // (relative to UNIX epoch), so in order to compare time we have to use the
  3879. // same timestamp type when saving the flush timestamp.
  3880. // All IE versions use low-res event timestamps, and have problematic clock
  3881. // implementations (#9632)
  3882. if (inBrowser && !isIE) {
  3883. var performance = window.performance;
  3884. if (
  3885. performance &&
  3886. typeof performance.now === 'function' &&
  3887. getNow() > document.createEvent('Event').timeStamp
  3888. ) {
  3889. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3890. // smaller than it, it means the event is using a hi-res timestamp,
  3891. // and we need to use the hi-res version for event listener timestamps as
  3892. // well.
  3893. getNow = function () { return performance.now(); };
  3894. }
  3895. }
  3896. /**
  3897. * Flush both queues and run the watchers.
  3898. */
  3899. function flushSchedulerQueue () {
  3900. currentFlushTimestamp = getNow();
  3901. flushing = true;
  3902. var watcher, id;
  3903. // Sort queue before flush.
  3904. // This ensures that:
  3905. // 1. Components are updated from parent to child. (because parent is always
  3906. // created before the child)
  3907. // 2. A component's user watchers are run before its render watcher (because
  3908. // user watchers are created before the render watcher)
  3909. // 3. If a component is destroyed during a parent component's watcher run,
  3910. // its watchers can be skipped.
  3911. queue.sort(function (a, b) { return a.id - b.id; });
  3912. // do not cache length because more watchers might be pushed
  3913. // as we run existing watchers
  3914. for (index = 0; index < queue.length; index++) {
  3915. watcher = queue[index];
  3916. if (watcher.before) {
  3917. watcher.before();
  3918. }
  3919. id = watcher.id;
  3920. has[id] = null;
  3921. watcher.run();
  3922. // in dev build, check and stop circular updates.
  3923. if (process.env.NODE_ENV !== 'production' && has[id] != null) {
  3924. circular[id] = (circular[id] || 0) + 1;
  3925. if (circular[id] > MAX_UPDATE_COUNT) {
  3926. warn(
  3927. 'You may have an infinite update loop ' + (
  3928. watcher.user
  3929. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  3930. : "in a component render function."
  3931. ),
  3932. watcher.vm
  3933. );
  3934. break
  3935. }
  3936. }
  3937. }
  3938. // keep copies of post queues before resetting state
  3939. var activatedQueue = activatedChildren.slice();
  3940. var updatedQueue = queue.slice();
  3941. resetSchedulerState();
  3942. // call component updated and activated hooks
  3943. callActivatedHooks(activatedQueue);
  3944. callUpdatedHooks(updatedQueue);
  3945. // devtool hook
  3946. /* istanbul ignore if */
  3947. if (devtools && config.devtools) {
  3948. devtools.emit('flush');
  3949. }
  3950. }
  3951. function callUpdatedHooks (queue) {
  3952. var i = queue.length;
  3953. while (i--) {
  3954. var watcher = queue[i];
  3955. var vm = watcher.vm;
  3956. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3957. callHook(vm, 'updated');
  3958. }
  3959. }
  3960. }
  3961. /**
  3962. * Queue a kept-alive component that was activated during patch.
  3963. * The queue will be processed after the entire tree has been patched.
  3964. */
  3965. function queueActivatedComponent (vm) {
  3966. // setting _inactive to false here so that a render function can
  3967. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3968. vm._inactive = false;
  3969. activatedChildren.push(vm);
  3970. }
  3971. function callActivatedHooks (queue) {
  3972. for (var i = 0; i < queue.length; i++) {
  3973. queue[i]._inactive = true;
  3974. activateChildComponent(queue[i], true /* true */);
  3975. }
  3976. }
  3977. /**
  3978. * Push a watcher into the watcher queue.
  3979. * Jobs with duplicate IDs will be skipped unless it's
  3980. * pushed when the queue is being flushed.
  3981. */
  3982. function queueWatcher (watcher) {
  3983. var id = watcher.id;
  3984. if (has[id] == null) {
  3985. has[id] = true;
  3986. if (!flushing) {
  3987. queue.push(watcher);
  3988. } else {
  3989. // if already flushing, splice the watcher based on its id
  3990. // if already past its id, it will be run next immediately.
  3991. var i = queue.length - 1;
  3992. while (i > index && queue[i].id > watcher.id) {
  3993. i--;
  3994. }
  3995. queue.splice(i + 1, 0, watcher);
  3996. }
  3997. // queue the flush
  3998. if (!waiting) {
  3999. waiting = true;
  4000. if (process.env.NODE_ENV !== 'production' && !config.async) {
  4001. flushSchedulerQueue();
  4002. return
  4003. }
  4004. nextTick(flushSchedulerQueue);
  4005. }
  4006. }
  4007. }
  4008. /* */
  4009. var uid$2 = 0;
  4010. /**
  4011. * A watcher parses an expression, collects dependencies,
  4012. * and fires callback when the expression value changes.
  4013. * This is used for both the $watch() api and directives.
  4014. */
  4015. var Watcher = function Watcher (
  4016. vm,
  4017. expOrFn,
  4018. cb,
  4019. options,
  4020. isRenderWatcher
  4021. ) {
  4022. this.vm = vm;
  4023. if (isRenderWatcher) {
  4024. vm._watcher = this;
  4025. }
  4026. vm._watchers.push(this);
  4027. // options
  4028. if (options) {
  4029. this.deep = !!options.deep;
  4030. this.user = !!options.user;
  4031. this.lazy = !!options.lazy;
  4032. this.sync = !!options.sync;
  4033. this.before = options.before;
  4034. } else {
  4035. this.deep = this.user = this.lazy = this.sync = false;
  4036. }
  4037. this.cb = cb;
  4038. this.id = ++uid$2; // uid for batching
  4039. this.active = true;
  4040. this.dirty = this.lazy; // for lazy watchers
  4041. this.deps = [];
  4042. this.newDeps = [];
  4043. this.depIds = new _Set();
  4044. this.newDepIds = new _Set();
  4045. this.expression = process.env.NODE_ENV !== 'production'
  4046. ? expOrFn.toString()
  4047. : '';
  4048. // parse expression for getter
  4049. if (typeof expOrFn === 'function') {
  4050. this.getter = expOrFn;
  4051. } else {
  4052. this.getter = parsePath(expOrFn);
  4053. if (!this.getter) {
  4054. this.getter = noop;
  4055. process.env.NODE_ENV !== 'production' && warn(
  4056. "Failed watching path: \"" + expOrFn + "\" " +
  4057. 'Watcher only accepts simple dot-delimited paths. ' +
  4058. 'For full control, use a function instead.',
  4059. vm
  4060. );
  4061. }
  4062. }
  4063. this.value = this.lazy
  4064. ? undefined
  4065. : this.get();
  4066. };
  4067. /**
  4068. * Evaluate the getter, and re-collect dependencies.
  4069. */
  4070. Watcher.prototype.get = function get () {
  4071. pushTarget(this);
  4072. var value;
  4073. var vm = this.vm;
  4074. try {
  4075. value = this.getter.call(vm, vm);
  4076. } catch (e) {
  4077. if (this.user) {
  4078. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  4079. } else {
  4080. throw e
  4081. }
  4082. } finally {
  4083. // "touch" every property so they are all tracked as
  4084. // dependencies for deep watching
  4085. if (this.deep) {
  4086. traverse(value);
  4087. }
  4088. popTarget();
  4089. this.cleanupDeps();
  4090. }
  4091. return value
  4092. };
  4093. /**
  4094. * Add a dependency to this directive.
  4095. */
  4096. Watcher.prototype.addDep = function addDep (dep) {
  4097. var id = dep.id;
  4098. if (!this.newDepIds.has(id)) {
  4099. this.newDepIds.add(id);
  4100. this.newDeps.push(dep);
  4101. if (!this.depIds.has(id)) {
  4102. dep.addSub(this);
  4103. }
  4104. }
  4105. };
  4106. /**
  4107. * Clean up for dependency collection.
  4108. */
  4109. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  4110. var i = this.deps.length;
  4111. while (i--) {
  4112. var dep = this.deps[i];
  4113. if (!this.newDepIds.has(dep.id)) {
  4114. dep.removeSub(this);
  4115. }
  4116. }
  4117. var tmp = this.depIds;
  4118. this.depIds = this.newDepIds;
  4119. this.newDepIds = tmp;
  4120. this.newDepIds.clear();
  4121. tmp = this.deps;
  4122. this.deps = this.newDeps;
  4123. this.newDeps = tmp;
  4124. this.newDeps.length = 0;
  4125. };
  4126. /**
  4127. * Subscriber interface.
  4128. * Will be called when a dependency changes.
  4129. */
  4130. Watcher.prototype.update = function update () {
  4131. /* istanbul ignore else */
  4132. if (this.lazy) {
  4133. this.dirty = true;
  4134. } else if (this.sync) {
  4135. this.run();
  4136. } else {
  4137. queueWatcher(this);
  4138. }
  4139. };
  4140. /**
  4141. * Scheduler job interface.
  4142. * Will be called by the scheduler.
  4143. */
  4144. Watcher.prototype.run = function run () {
  4145. if (this.active) {
  4146. var value = this.get();
  4147. if (
  4148. value !== this.value ||
  4149. // Deep watchers and watchers on Object/Arrays should fire even
  4150. // when the value is the same, because the value may
  4151. // have mutated.
  4152. isObject(value) ||
  4153. this.deep
  4154. ) {
  4155. // set new value
  4156. var oldValue = this.value;
  4157. this.value = value;
  4158. if (this.user) {
  4159. var info = "callback for watcher \"" + (this.expression) + "\"";
  4160. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4161. } else {
  4162. this.cb.call(this.vm, value, oldValue);
  4163. }
  4164. }
  4165. }
  4166. };
  4167. /**
  4168. * Evaluate the value of the watcher.
  4169. * This only gets called for lazy watchers.
  4170. */
  4171. Watcher.prototype.evaluate = function evaluate () {
  4172. this.value = this.get();
  4173. this.dirty = false;
  4174. };
  4175. /**
  4176. * Depend on all deps collected by this watcher.
  4177. */
  4178. Watcher.prototype.depend = function depend () {
  4179. var i = this.deps.length;
  4180. while (i--) {
  4181. this.deps[i].depend();
  4182. }
  4183. };
  4184. /**
  4185. * Remove self from all dependencies' subscriber list.
  4186. */
  4187. Watcher.prototype.teardown = function teardown () {
  4188. if (this.active) {
  4189. // remove self from vm's watcher list
  4190. // this is a somewhat expensive operation so we skip it
  4191. // if the vm is being destroyed.
  4192. if (!this.vm._isBeingDestroyed) {
  4193. remove(this.vm._watchers, this);
  4194. }
  4195. var i = this.deps.length;
  4196. while (i--) {
  4197. this.deps[i].removeSub(this);
  4198. }
  4199. this.active = false;
  4200. }
  4201. };
  4202. /* */
  4203. var sharedPropertyDefinition = {
  4204. enumerable: true,
  4205. configurable: true,
  4206. get: noop,
  4207. set: noop
  4208. };
  4209. function proxy (target, sourceKey, key) {
  4210. sharedPropertyDefinition.get = function proxyGetter () {
  4211. return this[sourceKey][key]
  4212. };
  4213. sharedPropertyDefinition.set = function proxySetter (val) {
  4214. this[sourceKey][key] = val;
  4215. };
  4216. Object.defineProperty(target, key, sharedPropertyDefinition);
  4217. }
  4218. function initState (vm) {
  4219. vm._watchers = [];
  4220. var opts = vm.$options;
  4221. if (opts.props) { initProps(vm, opts.props); }
  4222. if (opts.methods) { initMethods(vm, opts.methods); }
  4223. if (opts.data) {
  4224. initData(vm);
  4225. } else {
  4226. observe(vm._data = {}, true /* asRootData */);
  4227. }
  4228. if (opts.computed) { initComputed(vm, opts.computed); }
  4229. if (opts.watch && opts.watch !== nativeWatch) {
  4230. initWatch(vm, opts.watch);
  4231. }
  4232. }
  4233. function initProps (vm, propsOptions) {
  4234. var propsData = vm.$options.propsData || {};
  4235. var props = vm._props = {};
  4236. // cache prop keys so that future props updates can iterate using Array
  4237. // instead of dynamic object key enumeration.
  4238. var keys = vm.$options._propKeys = [];
  4239. var isRoot = !vm.$parent;
  4240. // root instance props should be converted
  4241. if (!isRoot) {
  4242. toggleObserving(false);
  4243. }
  4244. var loop = function ( key ) {
  4245. keys.push(key);
  4246. var value = validateProp(key, propsOptions, propsData, vm);
  4247. /* istanbul ignore else */
  4248. if (process.env.NODE_ENV !== 'production') {
  4249. var hyphenatedKey = hyphenate(key);
  4250. if (isReservedAttribute(hyphenatedKey) ||
  4251. config.isReservedAttr(hyphenatedKey)) {
  4252. warn(
  4253. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  4254. vm
  4255. );
  4256. }
  4257. defineReactive$$1(props, key, value, function () {
  4258. if (!isRoot && !isUpdatingChildComponent) {
  4259. warn(
  4260. "Avoid mutating a prop directly since the value will be " +
  4261. "overwritten whenever the parent component re-renders. " +
  4262. "Instead, use a data or computed property based on the prop's " +
  4263. "value. Prop being mutated: \"" + key + "\"",
  4264. vm
  4265. );
  4266. }
  4267. });
  4268. } else {
  4269. defineReactive$$1(props, key, value);
  4270. }
  4271. // static props are already proxied on the component's prototype
  4272. // during Vue.extend(). We only need to proxy props defined at
  4273. // instantiation here.
  4274. if (!(key in vm)) {
  4275. proxy(vm, "_props", key);
  4276. }
  4277. };
  4278. for (var key in propsOptions) loop( key );
  4279. toggleObserving(true);
  4280. }
  4281. function initData (vm) {
  4282. var data = vm.$options.data;
  4283. data = vm._data = typeof data === 'function'
  4284. ? getData(data, vm)
  4285. : data || {};
  4286. if (!isPlainObject(data)) {
  4287. data = {};
  4288. process.env.NODE_ENV !== 'production' && warn(
  4289. 'data functions should return an object:\n' +
  4290. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  4291. vm
  4292. );
  4293. }
  4294. // proxy data on instance
  4295. var keys = Object.keys(data);
  4296. var props = vm.$options.props;
  4297. var methods = vm.$options.methods;
  4298. var i = keys.length;
  4299. while (i--) {
  4300. var key = keys[i];
  4301. if (process.env.NODE_ENV !== 'production') {
  4302. if (methods && hasOwn(methods, key)) {
  4303. warn(
  4304. ("Method \"" + key + "\" has already been defined as a data property."),
  4305. vm
  4306. );
  4307. }
  4308. }
  4309. if (props && hasOwn(props, key)) {
  4310. process.env.NODE_ENV !== 'production' && warn(
  4311. "The data property \"" + key + "\" is already declared as a prop. " +
  4312. "Use prop default value instead.",
  4313. vm
  4314. );
  4315. } else if (!isReserved(key)) {
  4316. proxy(vm, "_data", key);
  4317. }
  4318. }
  4319. // observe data
  4320. observe(data, true /* asRootData */);
  4321. }
  4322. function getData (data, vm) {
  4323. // #7573 disable dep collection when invoking data getters
  4324. pushTarget();
  4325. try {
  4326. return data.call(vm, vm)
  4327. } catch (e) {
  4328. handleError(e, vm, "data()");
  4329. return {}
  4330. } finally {
  4331. popTarget();
  4332. }
  4333. }
  4334. var computedWatcherOptions = { lazy: true };
  4335. function initComputed (vm, computed) {
  4336. // $flow-disable-line
  4337. var watchers = vm._computedWatchers = Object.create(null);
  4338. // computed properties are just getters during SSR
  4339. var isSSR = isServerRendering();
  4340. for (var key in computed) {
  4341. var userDef = computed[key];
  4342. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  4343. if (process.env.NODE_ENV !== 'production' && getter == null) {
  4344. warn(
  4345. ("Getter is missing for computed property \"" + key + "\"."),
  4346. vm
  4347. );
  4348. }
  4349. if (!isSSR) {
  4350. // create internal watcher for the computed property.
  4351. watchers[key] = new Watcher(
  4352. vm,
  4353. getter || noop,
  4354. noop,
  4355. computedWatcherOptions
  4356. );
  4357. }
  4358. // component-defined computed properties are already defined on the
  4359. // component prototype. We only need to define computed properties defined
  4360. // at instantiation here.
  4361. if (!(key in vm)) {
  4362. defineComputed(vm, key, userDef);
  4363. } else if (process.env.NODE_ENV !== 'production') {
  4364. if (key in vm.$data) {
  4365. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  4366. } else if (vm.$options.props && key in vm.$options.props) {
  4367. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  4368. } else if (vm.$options.methods && key in vm.$options.methods) {
  4369. warn(("The computed property \"" + key + "\" is already defined as a method."), vm);
  4370. }
  4371. }
  4372. }
  4373. }
  4374. function defineComputed (
  4375. target,
  4376. key,
  4377. userDef
  4378. ) {
  4379. var shouldCache = !isServerRendering();
  4380. if (typeof userDef === 'function') {
  4381. sharedPropertyDefinition.get = shouldCache
  4382. ? createComputedGetter(key)
  4383. : createGetterInvoker(userDef);
  4384. sharedPropertyDefinition.set = noop;
  4385. } else {
  4386. sharedPropertyDefinition.get = userDef.get
  4387. ? shouldCache && userDef.cache !== false
  4388. ? createComputedGetter(key)
  4389. : createGetterInvoker(userDef.get)
  4390. : noop;
  4391. sharedPropertyDefinition.set = userDef.set || noop;
  4392. }
  4393. if (process.env.NODE_ENV !== 'production' &&
  4394. sharedPropertyDefinition.set === noop) {
  4395. sharedPropertyDefinition.set = function () {
  4396. warn(
  4397. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  4398. this
  4399. );
  4400. };
  4401. }
  4402. Object.defineProperty(target, key, sharedPropertyDefinition);
  4403. }
  4404. function createComputedGetter (key) {
  4405. return function computedGetter () {
  4406. var watcher = this._computedWatchers && this._computedWatchers[key];
  4407. if (watcher) {
  4408. if (watcher.dirty) {
  4409. watcher.evaluate();
  4410. }
  4411. if (Dep.target) {
  4412. watcher.depend();
  4413. }
  4414. return watcher.value
  4415. }
  4416. }
  4417. }
  4418. function createGetterInvoker(fn) {
  4419. return function computedGetter () {
  4420. return fn.call(this, this)
  4421. }
  4422. }
  4423. function initMethods (vm, methods) {
  4424. var props = vm.$options.props;
  4425. for (var key in methods) {
  4426. if (process.env.NODE_ENV !== 'production') {
  4427. if (typeof methods[key] !== 'function') {
  4428. warn(
  4429. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  4430. "Did you reference the function correctly?",
  4431. vm
  4432. );
  4433. }
  4434. if (props && hasOwn(props, key)) {
  4435. warn(
  4436. ("Method \"" + key + "\" has already been defined as a prop."),
  4437. vm
  4438. );
  4439. }
  4440. if ((key in vm) && isReserved(key)) {
  4441. warn(
  4442. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  4443. "Avoid defining component methods that start with _ or $."
  4444. );
  4445. }
  4446. }
  4447. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  4448. }
  4449. }
  4450. function initWatch (vm, watch) {
  4451. for (var key in watch) {
  4452. var handler = watch[key];
  4453. if (Array.isArray(handler)) {
  4454. for (var i = 0; i < handler.length; i++) {
  4455. createWatcher(vm, key, handler[i]);
  4456. }
  4457. } else {
  4458. createWatcher(vm, key, handler);
  4459. }
  4460. }
  4461. }
  4462. function createWatcher (
  4463. vm,
  4464. expOrFn,
  4465. handler,
  4466. options
  4467. ) {
  4468. if (isPlainObject(handler)) {
  4469. options = handler;
  4470. handler = handler.handler;
  4471. }
  4472. if (typeof handler === 'string') {
  4473. handler = vm[handler];
  4474. }
  4475. return vm.$watch(expOrFn, handler, options)
  4476. }
  4477. function stateMixin (Vue) {
  4478. // flow somehow has problems with directly declared definition object
  4479. // when using Object.defineProperty, so we have to procedurally build up
  4480. // the object here.
  4481. var dataDef = {};
  4482. dataDef.get = function () { return this._data };
  4483. var propsDef = {};
  4484. propsDef.get = function () { return this._props };
  4485. if (process.env.NODE_ENV !== 'production') {
  4486. dataDef.set = function () {
  4487. warn(
  4488. 'Avoid replacing instance root $data. ' +
  4489. 'Use nested data properties instead.',
  4490. this
  4491. );
  4492. };
  4493. propsDef.set = function () {
  4494. warn("$props is readonly.", this);
  4495. };
  4496. }
  4497. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4498. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4499. Vue.prototype.$set = set;
  4500. Vue.prototype.$delete = del;
  4501. Vue.prototype.$watch = function (
  4502. expOrFn,
  4503. cb,
  4504. options
  4505. ) {
  4506. var vm = this;
  4507. if (isPlainObject(cb)) {
  4508. return createWatcher(vm, expOrFn, cb, options)
  4509. }
  4510. options = options || {};
  4511. options.user = true;
  4512. var watcher = new Watcher(vm, expOrFn, cb, options);
  4513. if (options.immediate) {
  4514. var info = "callback for immediate watcher \"" + (watcher.expression) + "\"";
  4515. pushTarget();
  4516. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4517. popTarget();
  4518. }
  4519. return function unwatchFn () {
  4520. watcher.teardown();
  4521. }
  4522. };
  4523. }
  4524. /* */
  4525. var uid$3 = 0;
  4526. function initMixin (Vue) {
  4527. Vue.prototype._init = function (options) {
  4528. var vm = this;
  4529. // a uid
  4530. vm._uid = uid$3++;
  4531. var startTag, endTag;
  4532. /* istanbul ignore if */
  4533. if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
  4534. startTag = "vue-perf-start:" + (vm._uid);
  4535. endTag = "vue-perf-end:" + (vm._uid);
  4536. mark(startTag);
  4537. }
  4538. // a flag to avoid this being observed
  4539. vm._isVue = true;
  4540. // merge options
  4541. if (options && options._isComponent) {
  4542. // optimize internal component instantiation
  4543. // since dynamic options merging is pretty slow, and none of the
  4544. // internal component options needs special treatment.
  4545. initInternalComponent(vm, options);
  4546. } else {
  4547. vm.$options = mergeOptions(
  4548. resolveConstructorOptions(vm.constructor),
  4549. options || {},
  4550. vm
  4551. );
  4552. }
  4553. /* istanbul ignore else */
  4554. if (process.env.NODE_ENV !== 'production') {
  4555. initProxy(vm);
  4556. } else {
  4557. vm._renderProxy = vm;
  4558. }
  4559. // expose real self
  4560. vm._self = vm;
  4561. initLifecycle(vm);
  4562. initEvents(vm);
  4563. initRender(vm);
  4564. callHook(vm, 'beforeCreate');
  4565. initInjections(vm); // resolve injections before data/props
  4566. initState(vm);
  4567. initProvide(vm); // resolve provide after data/props
  4568. callHook(vm, 'created');
  4569. /* istanbul ignore if */
  4570. if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
  4571. vm._name = formatComponentName(vm, false);
  4572. mark(endTag);
  4573. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  4574. }
  4575. if (vm.$options.el) {
  4576. vm.$mount(vm.$options.el);
  4577. }
  4578. };
  4579. }
  4580. function initInternalComponent (vm, options) {
  4581. var opts = vm.$options = Object.create(vm.constructor.options);
  4582. // doing this because it's faster than dynamic enumeration.
  4583. var parentVnode = options._parentVnode;
  4584. opts.parent = options.parent;
  4585. opts._parentVnode = parentVnode;
  4586. var vnodeComponentOptions = parentVnode.componentOptions;
  4587. opts.propsData = vnodeComponentOptions.propsData;
  4588. opts._parentListeners = vnodeComponentOptions.listeners;
  4589. opts._renderChildren = vnodeComponentOptions.children;
  4590. opts._componentTag = vnodeComponentOptions.tag;
  4591. if (options.render) {
  4592. opts.render = options.render;
  4593. opts.staticRenderFns = options.staticRenderFns;
  4594. }
  4595. }
  4596. function resolveConstructorOptions (Ctor) {
  4597. var options = Ctor.options;
  4598. if (Ctor.super) {
  4599. var superOptions = resolveConstructorOptions(Ctor.super);
  4600. var cachedSuperOptions = Ctor.superOptions;
  4601. if (superOptions !== cachedSuperOptions) {
  4602. // super option changed,
  4603. // need to resolve new options.
  4604. Ctor.superOptions = superOptions;
  4605. // check if there are any late-modified/attached options (#4976)
  4606. var modifiedOptions = resolveModifiedOptions(Ctor);
  4607. // update base extend options
  4608. if (modifiedOptions) {
  4609. extend(Ctor.extendOptions, modifiedOptions);
  4610. }
  4611. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4612. if (options.name) {
  4613. options.components[options.name] = Ctor;
  4614. }
  4615. }
  4616. }
  4617. return options
  4618. }
  4619. function resolveModifiedOptions (Ctor) {
  4620. var modified;
  4621. var latest = Ctor.options;
  4622. var sealed = Ctor.sealedOptions;
  4623. for (var key in latest) {
  4624. if (latest[key] !== sealed[key]) {
  4625. if (!modified) { modified = {}; }
  4626. modified[key] = latest[key];
  4627. }
  4628. }
  4629. return modified
  4630. }
  4631. function Vue (options) {
  4632. if (process.env.NODE_ENV !== 'production' &&
  4633. !(this instanceof Vue)
  4634. ) {
  4635. warn('Vue is a constructor and should be called with the `new` keyword');
  4636. }
  4637. this._init(options);
  4638. }
  4639. initMixin(Vue);
  4640. stateMixin(Vue);
  4641. eventsMixin(Vue);
  4642. lifecycleMixin(Vue);
  4643. renderMixin(Vue);
  4644. /* */
  4645. function initUse (Vue) {
  4646. Vue.use = function (plugin) {
  4647. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  4648. if (installedPlugins.indexOf(plugin) > -1) {
  4649. return this
  4650. }
  4651. // additional parameters
  4652. var args = toArray(arguments, 1);
  4653. args.unshift(this);
  4654. if (typeof plugin.install === 'function') {
  4655. plugin.install.apply(plugin, args);
  4656. } else if (typeof plugin === 'function') {
  4657. plugin.apply(null, args);
  4658. }
  4659. installedPlugins.push(plugin);
  4660. return this
  4661. };
  4662. }
  4663. /* */
  4664. function initMixin$1 (Vue) {
  4665. Vue.mixin = function (mixin) {
  4666. this.options = mergeOptions(this.options, mixin);
  4667. return this
  4668. };
  4669. }
  4670. /* */
  4671. function initExtend (Vue) {
  4672. /**
  4673. * Each instance constructor, including Vue, has a unique
  4674. * cid. This enables us to create wrapped "child
  4675. * constructors" for prototypal inheritance and cache them.
  4676. */
  4677. Vue.cid = 0;
  4678. var cid = 1;
  4679. /**
  4680. * Class inheritance
  4681. */
  4682. Vue.extend = function (extendOptions) {
  4683. extendOptions = extendOptions || {};
  4684. var Super = this;
  4685. var SuperId = Super.cid;
  4686. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  4687. if (cachedCtors[SuperId]) {
  4688. return cachedCtors[SuperId]
  4689. }
  4690. var name = extendOptions.name || Super.options.name;
  4691. if (process.env.NODE_ENV !== 'production' && name) {
  4692. validateComponentName(name);
  4693. }
  4694. var Sub = function VueComponent (options) {
  4695. this._init(options);
  4696. };
  4697. Sub.prototype = Object.create(Super.prototype);
  4698. Sub.prototype.constructor = Sub;
  4699. Sub.cid = cid++;
  4700. Sub.options = mergeOptions(
  4701. Super.options,
  4702. extendOptions
  4703. );
  4704. Sub['super'] = Super;
  4705. // For props and computed properties, we define the proxy getters on
  4706. // the Vue instances at extension time, on the extended prototype. This
  4707. // avoids Object.defineProperty calls for each instance created.
  4708. if (Sub.options.props) {
  4709. initProps$1(Sub);
  4710. }
  4711. if (Sub.options.computed) {
  4712. initComputed$1(Sub);
  4713. }
  4714. // allow further extension/mixin/plugin usage
  4715. Sub.extend = Super.extend;
  4716. Sub.mixin = Super.mixin;
  4717. Sub.use = Super.use;
  4718. // create asset registers, so extended classes
  4719. // can have their private assets too.
  4720. ASSET_TYPES.forEach(function (type) {
  4721. Sub[type] = Super[type];
  4722. });
  4723. // enable recursive self-lookup
  4724. if (name) {
  4725. Sub.options.components[name] = Sub;
  4726. }
  4727. // keep a reference to the super options at extension time.
  4728. // later at instantiation we can check if Super's options have
  4729. // been updated.
  4730. Sub.superOptions = Super.options;
  4731. Sub.extendOptions = extendOptions;
  4732. Sub.sealedOptions = extend({}, Sub.options);
  4733. // cache constructor
  4734. cachedCtors[SuperId] = Sub;
  4735. return Sub
  4736. };
  4737. }
  4738. function initProps$1 (Comp) {
  4739. var props = Comp.options.props;
  4740. for (var key in props) {
  4741. proxy(Comp.prototype, "_props", key);
  4742. }
  4743. }
  4744. function initComputed$1 (Comp) {
  4745. var computed = Comp.options.computed;
  4746. for (var key in computed) {
  4747. defineComputed(Comp.prototype, key, computed[key]);
  4748. }
  4749. }
  4750. /* */
  4751. function initAssetRegisters (Vue) {
  4752. /**
  4753. * Create asset registration methods.
  4754. */
  4755. ASSET_TYPES.forEach(function (type) {
  4756. Vue[type] = function (
  4757. id,
  4758. definition
  4759. ) {
  4760. if (!definition) {
  4761. return this.options[type + 's'][id]
  4762. } else {
  4763. /* istanbul ignore if */
  4764. if (process.env.NODE_ENV !== 'production' && type === 'component') {
  4765. validateComponentName(id);
  4766. }
  4767. if (type === 'component' && isPlainObject(definition)) {
  4768. definition.name = definition.name || id;
  4769. definition = this.options._base.extend(definition);
  4770. }
  4771. if (type === 'directive' && typeof definition === 'function') {
  4772. definition = { bind: definition, update: definition };
  4773. }
  4774. this.options[type + 's'][id] = definition;
  4775. return definition
  4776. }
  4777. };
  4778. });
  4779. }
  4780. /* */
  4781. function getComponentName (opts) {
  4782. return opts && (opts.Ctor.options.name || opts.tag)
  4783. }
  4784. function matches (pattern, name) {
  4785. if (Array.isArray(pattern)) {
  4786. return pattern.indexOf(name) > -1
  4787. } else if (typeof pattern === 'string') {
  4788. return pattern.split(',').indexOf(name) > -1
  4789. } else if (isRegExp(pattern)) {
  4790. return pattern.test(name)
  4791. }
  4792. /* istanbul ignore next */
  4793. return false
  4794. }
  4795. function pruneCache (keepAliveInstance, filter) {
  4796. var cache = keepAliveInstance.cache;
  4797. var keys = keepAliveInstance.keys;
  4798. var _vnode = keepAliveInstance._vnode;
  4799. for (var key in cache) {
  4800. var entry = cache[key];
  4801. if (entry) {
  4802. var name = entry.name;
  4803. if (name && !filter(name)) {
  4804. pruneCacheEntry(cache, key, keys, _vnode);
  4805. }
  4806. }
  4807. }
  4808. }
  4809. function pruneCacheEntry (
  4810. cache,
  4811. key,
  4812. keys,
  4813. current
  4814. ) {
  4815. var entry = cache[key];
  4816. if (entry && (!current || entry.tag !== current.tag)) {
  4817. entry.componentInstance.$destroy();
  4818. }
  4819. cache[key] = null;
  4820. remove(keys, key);
  4821. }
  4822. var patternTypes = [String, RegExp, Array];
  4823. var KeepAlive = {
  4824. name: 'keep-alive',
  4825. abstract: true,
  4826. props: {
  4827. include: patternTypes,
  4828. exclude: patternTypes,
  4829. max: [String, Number]
  4830. },
  4831. methods: {
  4832. cacheVNode: function cacheVNode() {
  4833. var ref = this;
  4834. var cache = ref.cache;
  4835. var keys = ref.keys;
  4836. var vnodeToCache = ref.vnodeToCache;
  4837. var keyToCache = ref.keyToCache;
  4838. if (vnodeToCache) {
  4839. var tag = vnodeToCache.tag;
  4840. var componentInstance = vnodeToCache.componentInstance;
  4841. var componentOptions = vnodeToCache.componentOptions;
  4842. cache[keyToCache] = {
  4843. name: getComponentName(componentOptions),
  4844. tag: tag,
  4845. componentInstance: componentInstance,
  4846. };
  4847. keys.push(keyToCache);
  4848. // prune oldest entry
  4849. if (this.max && keys.length > parseInt(this.max)) {
  4850. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  4851. }
  4852. this.vnodeToCache = null;
  4853. }
  4854. }
  4855. },
  4856. created: function created () {
  4857. this.cache = Object.create(null);
  4858. this.keys = [];
  4859. },
  4860. destroyed: function destroyed () {
  4861. for (var key in this.cache) {
  4862. pruneCacheEntry(this.cache, key, this.keys);
  4863. }
  4864. },
  4865. mounted: function mounted () {
  4866. var this$1 = this;
  4867. this.cacheVNode();
  4868. this.$watch('include', function (val) {
  4869. pruneCache(this$1, function (name) { return matches(val, name); });
  4870. });
  4871. this.$watch('exclude', function (val) {
  4872. pruneCache(this$1, function (name) { return !matches(val, name); });
  4873. });
  4874. },
  4875. updated: function updated () {
  4876. this.cacheVNode();
  4877. },
  4878. render: function render () {
  4879. var slot = this.$slots.default;
  4880. var vnode = getFirstComponentChild(slot);
  4881. var componentOptions = vnode && vnode.componentOptions;
  4882. if (componentOptions) {
  4883. // check pattern
  4884. var name = getComponentName(componentOptions);
  4885. var ref = this;
  4886. var include = ref.include;
  4887. var exclude = ref.exclude;
  4888. if (
  4889. // not included
  4890. (include && (!name || !matches(include, name))) ||
  4891. // excluded
  4892. (exclude && name && matches(exclude, name))
  4893. ) {
  4894. return vnode
  4895. }
  4896. var ref$1 = this;
  4897. var cache = ref$1.cache;
  4898. var keys = ref$1.keys;
  4899. var key = vnode.key == null
  4900. // same constructor may get registered as different local components
  4901. // so cid alone is not enough (#3269)
  4902. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  4903. : vnode.key;
  4904. if (cache[key]) {
  4905. vnode.componentInstance = cache[key].componentInstance;
  4906. // make current key freshest
  4907. remove(keys, key);
  4908. keys.push(key);
  4909. } else {
  4910. // delay setting the cache until update
  4911. this.vnodeToCache = vnode;
  4912. this.keyToCache = key;
  4913. }
  4914. vnode.data.keepAlive = true;
  4915. }
  4916. return vnode || (slot && slot[0])
  4917. }
  4918. };
  4919. var builtInComponents = {
  4920. KeepAlive: KeepAlive
  4921. };
  4922. /* */
  4923. function initGlobalAPI (Vue) {
  4924. // config
  4925. var configDef = {};
  4926. configDef.get = function () { return config; };
  4927. if (process.env.NODE_ENV !== 'production') {
  4928. configDef.set = function () {
  4929. warn(
  4930. 'Do not replace the Vue.config object, set individual fields instead.'
  4931. );
  4932. };
  4933. }
  4934. Object.defineProperty(Vue, 'config', configDef);
  4935. // exposed util methods.
  4936. // NOTE: these are not considered part of the public API - avoid relying on
  4937. // them unless you are aware of the risk.
  4938. Vue.util = {
  4939. warn: warn,
  4940. extend: extend,
  4941. mergeOptions: mergeOptions,
  4942. defineReactive: defineReactive$$1
  4943. };
  4944. Vue.set = set;
  4945. Vue.delete = del;
  4946. Vue.nextTick = nextTick;
  4947. // 2.6 explicit observable API
  4948. Vue.observable = function (obj) {
  4949. observe(obj);
  4950. return obj
  4951. };
  4952. Vue.options = Object.create(null);
  4953. ASSET_TYPES.forEach(function (type) {
  4954. Vue.options[type + 's'] = Object.create(null);
  4955. });
  4956. // this is used to identify the "base" constructor to extend all plain-object
  4957. // components with in Weex's multi-instance scenarios.
  4958. Vue.options._base = Vue;
  4959. extend(Vue.options.components, builtInComponents);
  4960. initUse(Vue);
  4961. initMixin$1(Vue);
  4962. initExtend(Vue);
  4963. initAssetRegisters(Vue);
  4964. }
  4965. initGlobalAPI(Vue);
  4966. Object.defineProperty(Vue.prototype, '$isServer', {
  4967. get: isServerRendering
  4968. });
  4969. Object.defineProperty(Vue.prototype, '$ssrContext', {
  4970. get: function get () {
  4971. /* istanbul ignore next */
  4972. return this.$vnode && this.$vnode.ssrContext
  4973. }
  4974. });
  4975. // expose FunctionalRenderContext for ssr runtime helper installation
  4976. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  4977. value: FunctionalRenderContext
  4978. });
  4979. Vue.version = '2.6.14';
  4980. /* */
  4981. // these are reserved for web because they are directly compiled away
  4982. // during template compilation
  4983. var isReservedAttr = makeMap('style,class');
  4984. // attributes that should be using props for binding
  4985. var acceptValue = makeMap('input,textarea,option,select,progress');
  4986. var mustUseProp = function (tag, type, attr) {
  4987. return (
  4988. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  4989. (attr === 'selected' && tag === 'option') ||
  4990. (attr === 'checked' && tag === 'input') ||
  4991. (attr === 'muted' && tag === 'video')
  4992. )
  4993. };
  4994. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  4995. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  4996. var convertEnumeratedValue = function (key, value) {
  4997. return isFalsyAttrValue(value) || value === 'false'
  4998. ? 'false'
  4999. // allow arbitrary string value for contenteditable
  5000. : key === 'contenteditable' && isValidContentEditableValue(value)
  5001. ? value
  5002. : 'true'
  5003. };
  5004. var isBooleanAttr = makeMap(
  5005. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  5006. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  5007. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  5008. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  5009. 'required,reversed,scoped,seamless,selected,sortable,' +
  5010. 'truespeed,typemustmatch,visible'
  5011. );
  5012. var xlinkNS = 'http://www.w3.org/1999/xlink';
  5013. var isXlink = function (name) {
  5014. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  5015. };
  5016. var getXlinkProp = function (name) {
  5017. return isXlink(name) ? name.slice(6, name.length) : ''
  5018. };
  5019. var isFalsyAttrValue = function (val) {
  5020. return val == null || val === false
  5021. };
  5022. /* */
  5023. function genClassForVnode (vnode) {
  5024. var data = vnode.data;
  5025. var parentNode = vnode;
  5026. var childNode = vnode;
  5027. while (isDef(childNode.componentInstance)) {
  5028. childNode = childNode.componentInstance._vnode;
  5029. if (childNode && childNode.data) {
  5030. data = mergeClassData(childNode.data, data);
  5031. }
  5032. }
  5033. while (isDef(parentNode = parentNode.parent)) {
  5034. if (parentNode && parentNode.data) {
  5035. data = mergeClassData(data, parentNode.data);
  5036. }
  5037. }
  5038. return renderClass(data.staticClass, data.class)
  5039. }
  5040. function mergeClassData (child, parent) {
  5041. return {
  5042. staticClass: concat(child.staticClass, parent.staticClass),
  5043. class: isDef(child.class)
  5044. ? [child.class, parent.class]
  5045. : parent.class
  5046. }
  5047. }
  5048. function renderClass (
  5049. staticClass,
  5050. dynamicClass
  5051. ) {
  5052. if (isDef(staticClass) || isDef(dynamicClass)) {
  5053. return concat(staticClass, stringifyClass(dynamicClass))
  5054. }
  5055. /* istanbul ignore next */
  5056. return ''
  5057. }
  5058. function concat (a, b) {
  5059. return a ? b ? (a + ' ' + b) : a : (b || '')
  5060. }
  5061. function stringifyClass (value) {
  5062. if (Array.isArray(value)) {
  5063. return stringifyArray(value)
  5064. }
  5065. if (isObject(value)) {
  5066. return stringifyObject(value)
  5067. }
  5068. if (typeof value === 'string') {
  5069. return value
  5070. }
  5071. /* istanbul ignore next */
  5072. return ''
  5073. }
  5074. function stringifyArray (value) {
  5075. var res = '';
  5076. var stringified;
  5077. for (var i = 0, l = value.length; i < l; i++) {
  5078. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  5079. if (res) { res += ' '; }
  5080. res += stringified;
  5081. }
  5082. }
  5083. return res
  5084. }
  5085. function stringifyObject (value) {
  5086. var res = '';
  5087. for (var key in value) {
  5088. if (value[key]) {
  5089. if (res) { res += ' '; }
  5090. res += key;
  5091. }
  5092. }
  5093. return res
  5094. }
  5095. /* */
  5096. var namespaceMap = {
  5097. svg: 'http://www.w3.org/2000/svg',
  5098. math: 'http://www.w3.org/1998/Math/MathML'
  5099. };
  5100. var isHTMLTag = makeMap(
  5101. 'html,body,base,head,link,meta,style,title,' +
  5102. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  5103. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  5104. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  5105. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  5106. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  5107. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  5108. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  5109. 'output,progress,select,textarea,' +
  5110. 'details,dialog,menu,menuitem,summary,' +
  5111. 'content,element,shadow,template,blockquote,iframe,tfoot'
  5112. );
  5113. // this map is intentionally selective, only covering SVG elements that may
  5114. // contain child elements.
  5115. var isSVG = makeMap(
  5116. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  5117. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  5118. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  5119. true
  5120. );
  5121. var isReservedTag = function (tag) {
  5122. return isHTMLTag(tag) || isSVG(tag)
  5123. };
  5124. function getTagNamespace (tag) {
  5125. if (isSVG(tag)) {
  5126. return 'svg'
  5127. }
  5128. // basic support for MathML
  5129. // note it doesn't support other MathML elements being component roots
  5130. if (tag === 'math') {
  5131. return 'math'
  5132. }
  5133. }
  5134. var unknownElementCache = Object.create(null);
  5135. function isUnknownElement (tag) {
  5136. /* istanbul ignore if */
  5137. if (!inBrowser) {
  5138. return true
  5139. }
  5140. if (isReservedTag(tag)) {
  5141. return false
  5142. }
  5143. tag = tag.toLowerCase();
  5144. /* istanbul ignore if */
  5145. if (unknownElementCache[tag] != null) {
  5146. return unknownElementCache[tag]
  5147. }
  5148. var el = document.createElement(tag);
  5149. if (tag.indexOf('-') > -1) {
  5150. // http://stackoverflow.com/a/28210364/1070244
  5151. return (unknownElementCache[tag] = (
  5152. el.constructor === window.HTMLUnknownElement ||
  5153. el.constructor === window.HTMLElement
  5154. ))
  5155. } else {
  5156. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  5157. }
  5158. }
  5159. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  5160. /* */
  5161. /**
  5162. * Query an element selector if it's not an element already.
  5163. */
  5164. function query (el) {
  5165. if (typeof el === 'string') {
  5166. var selected = document.querySelector(el);
  5167. if (!selected) {
  5168. process.env.NODE_ENV !== 'production' && warn(
  5169. 'Cannot find element: ' + el
  5170. );
  5171. return document.createElement('div')
  5172. }
  5173. return selected
  5174. } else {
  5175. return el
  5176. }
  5177. }
  5178. /* */
  5179. function createElement$1 (tagName, vnode) {
  5180. var elm = document.createElement(tagName);
  5181. if (tagName !== 'select') {
  5182. return elm
  5183. }
  5184. // false or null will remove the attribute but undefined will not
  5185. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  5186. elm.setAttribute('multiple', 'multiple');
  5187. }
  5188. return elm
  5189. }
  5190. function createElementNS (namespace, tagName) {
  5191. return document.createElementNS(namespaceMap[namespace], tagName)
  5192. }
  5193. function createTextNode (text) {
  5194. return document.createTextNode(text)
  5195. }
  5196. function createComment (text) {
  5197. return document.createComment(text)
  5198. }
  5199. function insertBefore (parentNode, newNode, referenceNode) {
  5200. parentNode.insertBefore(newNode, referenceNode);
  5201. }
  5202. function removeChild (node, child) {
  5203. node.removeChild(child);
  5204. }
  5205. function appendChild (node, child) {
  5206. node.appendChild(child);
  5207. }
  5208. function parentNode (node) {
  5209. return node.parentNode
  5210. }
  5211. function nextSibling (node) {
  5212. return node.nextSibling
  5213. }
  5214. function tagName (node) {
  5215. return node.tagName
  5216. }
  5217. function setTextContent (node, text) {
  5218. node.textContent = text;
  5219. }
  5220. function setStyleScope (node, scopeId) {
  5221. node.setAttribute(scopeId, '');
  5222. }
  5223. var nodeOps = /*#__PURE__*/Object.freeze({
  5224. createElement: createElement$1,
  5225. createElementNS: createElementNS,
  5226. createTextNode: createTextNode,
  5227. createComment: createComment,
  5228. insertBefore: insertBefore,
  5229. removeChild: removeChild,
  5230. appendChild: appendChild,
  5231. parentNode: parentNode,
  5232. nextSibling: nextSibling,
  5233. tagName: tagName,
  5234. setTextContent: setTextContent,
  5235. setStyleScope: setStyleScope
  5236. });
  5237. /* */
  5238. var ref = {
  5239. create: function create (_, vnode) {
  5240. registerRef(vnode);
  5241. },
  5242. update: function update (oldVnode, vnode) {
  5243. if (oldVnode.data.ref !== vnode.data.ref) {
  5244. registerRef(oldVnode, true);
  5245. registerRef(vnode);
  5246. }
  5247. },
  5248. destroy: function destroy (vnode) {
  5249. registerRef(vnode, true);
  5250. }
  5251. };
  5252. function registerRef (vnode, isRemoval) {
  5253. var key = vnode.data.ref;
  5254. if (!isDef(key)) { return }
  5255. var vm = vnode.context;
  5256. var ref = vnode.componentInstance || vnode.elm;
  5257. var refs = vm.$refs;
  5258. if (isRemoval) {
  5259. if (Array.isArray(refs[key])) {
  5260. remove(refs[key], ref);
  5261. } else if (refs[key] === ref) {
  5262. refs[key] = undefined;
  5263. }
  5264. } else {
  5265. if (vnode.data.refInFor) {
  5266. if (!Array.isArray(refs[key])) {
  5267. refs[key] = [ref];
  5268. } else if (refs[key].indexOf(ref) < 0) {
  5269. // $flow-disable-line
  5270. refs[key].push(ref);
  5271. }
  5272. } else {
  5273. refs[key] = ref;
  5274. }
  5275. }
  5276. }
  5277. /**
  5278. * Virtual DOM patching algorithm based on Snabbdom by
  5279. * Simon Friis Vindum (@paldepind)
  5280. * Licensed under the MIT License
  5281. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  5282. *
  5283. * modified by Evan You (@yyx990803)
  5284. *
  5285. * Not type-checking this because this file is perf-critical and the cost
  5286. * of making flow understand it is not worth it.
  5287. */
  5288. var emptyNode = new VNode('', {}, []);
  5289. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  5290. function sameVnode (a, b) {
  5291. return (
  5292. a.key === b.key &&
  5293. a.asyncFactory === b.asyncFactory && (
  5294. (
  5295. a.tag === b.tag &&
  5296. a.isComment === b.isComment &&
  5297. isDef(a.data) === isDef(b.data) &&
  5298. sameInputType(a, b)
  5299. ) || (
  5300. isTrue(a.isAsyncPlaceholder) &&
  5301. isUndef(b.asyncFactory.error)
  5302. )
  5303. )
  5304. )
  5305. }
  5306. function sameInputType (a, b) {
  5307. if (a.tag !== 'input') { return true }
  5308. var i;
  5309. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  5310. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  5311. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  5312. }
  5313. function createKeyToOldIdx (children, beginIdx, endIdx) {
  5314. var i, key;
  5315. var map = {};
  5316. for (i = beginIdx; i <= endIdx; ++i) {
  5317. key = children[i].key;
  5318. if (isDef(key)) { map[key] = i; }
  5319. }
  5320. return map
  5321. }
  5322. function createPatchFunction (backend) {
  5323. var i, j;
  5324. var cbs = {};
  5325. var modules = backend.modules;
  5326. var nodeOps = backend.nodeOps;
  5327. for (i = 0; i < hooks.length; ++i) {
  5328. cbs[hooks[i]] = [];
  5329. for (j = 0; j < modules.length; ++j) {
  5330. if (isDef(modules[j][hooks[i]])) {
  5331. cbs[hooks[i]].push(modules[j][hooks[i]]);
  5332. }
  5333. }
  5334. }
  5335. function emptyNodeAt (elm) {
  5336. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  5337. }
  5338. function createRmCb (childElm, listeners) {
  5339. function remove$$1 () {
  5340. if (--remove$$1.listeners === 0) {
  5341. removeNode(childElm);
  5342. }
  5343. }
  5344. remove$$1.listeners = listeners;
  5345. return remove$$1
  5346. }
  5347. function removeNode (el) {
  5348. var parent = nodeOps.parentNode(el);
  5349. // element may have already been removed due to v-html / v-text
  5350. if (isDef(parent)) {
  5351. nodeOps.removeChild(parent, el);
  5352. }
  5353. }
  5354. function isUnknownElement$$1 (vnode, inVPre) {
  5355. return (
  5356. !inVPre &&
  5357. !vnode.ns &&
  5358. !(
  5359. config.ignoredElements.length &&
  5360. config.ignoredElements.some(function (ignore) {
  5361. return isRegExp(ignore)
  5362. ? ignore.test(vnode.tag)
  5363. : ignore === vnode.tag
  5364. })
  5365. ) &&
  5366. config.isUnknownElement(vnode.tag)
  5367. )
  5368. }
  5369. var creatingElmInVPre = 0;
  5370. function createElm (
  5371. vnode,
  5372. insertedVnodeQueue,
  5373. parentElm,
  5374. refElm,
  5375. nested,
  5376. ownerArray,
  5377. index
  5378. ) {
  5379. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5380. // This vnode was used in a previous render!
  5381. // now it's used as a new node, overwriting its elm would cause
  5382. // potential patch errors down the road when it's used as an insertion
  5383. // reference node. Instead, we clone the node on-demand before creating
  5384. // associated DOM element for it.
  5385. vnode = ownerArray[index] = cloneVNode(vnode);
  5386. }
  5387. vnode.isRootInsert = !nested; // for transition enter check
  5388. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  5389. return
  5390. }
  5391. var data = vnode.data;
  5392. var children = vnode.children;
  5393. var tag = vnode.tag;
  5394. if (isDef(tag)) {
  5395. if (process.env.NODE_ENV !== 'production') {
  5396. if (data && data.pre) {
  5397. creatingElmInVPre++;
  5398. }
  5399. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  5400. warn(
  5401. 'Unknown custom element: <' + tag + '> - did you ' +
  5402. 'register the component correctly? For recursive components, ' +
  5403. 'make sure to provide the "name" option.',
  5404. vnode.context
  5405. );
  5406. }
  5407. }
  5408. vnode.elm = vnode.ns
  5409. ? nodeOps.createElementNS(vnode.ns, tag)
  5410. : nodeOps.createElement(tag, vnode);
  5411. setScope(vnode);
  5412. /* istanbul ignore if */
  5413. {
  5414. createChildren(vnode, children, insertedVnodeQueue);
  5415. if (isDef(data)) {
  5416. invokeCreateHooks(vnode, insertedVnodeQueue);
  5417. }
  5418. insert(parentElm, vnode.elm, refElm);
  5419. }
  5420. if (process.env.NODE_ENV !== 'production' && data && data.pre) {
  5421. creatingElmInVPre--;
  5422. }
  5423. } else if (isTrue(vnode.isComment)) {
  5424. vnode.elm = nodeOps.createComment(vnode.text);
  5425. insert(parentElm, vnode.elm, refElm);
  5426. } else {
  5427. vnode.elm = nodeOps.createTextNode(vnode.text);
  5428. insert(parentElm, vnode.elm, refElm);
  5429. }
  5430. }
  5431. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5432. var i = vnode.data;
  5433. if (isDef(i)) {
  5434. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  5435. if (isDef(i = i.hook) && isDef(i = i.init)) {
  5436. i(vnode, false /* hydrating */);
  5437. }
  5438. // after calling the init hook, if the vnode is a child component
  5439. // it should've created a child instance and mounted it. the child
  5440. // component also has set the placeholder vnode's elm.
  5441. // in that case we can just return the element and be done.
  5442. if (isDef(vnode.componentInstance)) {
  5443. initComponent(vnode, insertedVnodeQueue);
  5444. insert(parentElm, vnode.elm, refElm);
  5445. if (isTrue(isReactivated)) {
  5446. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  5447. }
  5448. return true
  5449. }
  5450. }
  5451. }
  5452. function initComponent (vnode, insertedVnodeQueue) {
  5453. if (isDef(vnode.data.pendingInsert)) {
  5454. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  5455. vnode.data.pendingInsert = null;
  5456. }
  5457. vnode.elm = vnode.componentInstance.$el;
  5458. if (isPatchable(vnode)) {
  5459. invokeCreateHooks(vnode, insertedVnodeQueue);
  5460. setScope(vnode);
  5461. } else {
  5462. // empty component root.
  5463. // skip all element-related modules except for ref (#3455)
  5464. registerRef(vnode);
  5465. // make sure to invoke the insert hook
  5466. insertedVnodeQueue.push(vnode);
  5467. }
  5468. }
  5469. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5470. var i;
  5471. // hack for #4339: a reactivated component with inner transition
  5472. // does not trigger because the inner node's created hooks are not called
  5473. // again. It's not ideal to involve module-specific logic in here but
  5474. // there doesn't seem to be a better way to do it.
  5475. var innerNode = vnode;
  5476. while (innerNode.componentInstance) {
  5477. innerNode = innerNode.componentInstance._vnode;
  5478. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  5479. for (i = 0; i < cbs.activate.length; ++i) {
  5480. cbs.activate[i](emptyNode, innerNode);
  5481. }
  5482. insertedVnodeQueue.push(innerNode);
  5483. break
  5484. }
  5485. }
  5486. // unlike a newly created component,
  5487. // a reactivated keep-alive component doesn't insert itself
  5488. insert(parentElm, vnode.elm, refElm);
  5489. }
  5490. function insert (parent, elm, ref$$1) {
  5491. if (isDef(parent)) {
  5492. if (isDef(ref$$1)) {
  5493. if (nodeOps.parentNode(ref$$1) === parent) {
  5494. nodeOps.insertBefore(parent, elm, ref$$1);
  5495. }
  5496. } else {
  5497. nodeOps.appendChild(parent, elm);
  5498. }
  5499. }
  5500. }
  5501. function createChildren (vnode, children, insertedVnodeQueue) {
  5502. if (Array.isArray(children)) {
  5503. if (process.env.NODE_ENV !== 'production') {
  5504. checkDuplicateKeys(children);
  5505. }
  5506. for (var i = 0; i < children.length; ++i) {
  5507. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  5508. }
  5509. } else if (isPrimitive(vnode.text)) {
  5510. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  5511. }
  5512. }
  5513. function isPatchable (vnode) {
  5514. while (vnode.componentInstance) {
  5515. vnode = vnode.componentInstance._vnode;
  5516. }
  5517. return isDef(vnode.tag)
  5518. }
  5519. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  5520. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  5521. cbs.create[i$1](emptyNode, vnode);
  5522. }
  5523. i = vnode.data.hook; // Reuse variable
  5524. if (isDef(i)) {
  5525. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  5526. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  5527. }
  5528. }
  5529. // set scope id attribute for scoped CSS.
  5530. // this is implemented as a special case to avoid the overhead
  5531. // of going through the normal attribute patching process.
  5532. function setScope (vnode) {
  5533. var i;
  5534. if (isDef(i = vnode.fnScopeId)) {
  5535. nodeOps.setStyleScope(vnode.elm, i);
  5536. } else {
  5537. var ancestor = vnode;
  5538. while (ancestor) {
  5539. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  5540. nodeOps.setStyleScope(vnode.elm, i);
  5541. }
  5542. ancestor = ancestor.parent;
  5543. }
  5544. }
  5545. // for slot content they should also get the scopeId from the host instance.
  5546. if (isDef(i = activeInstance) &&
  5547. i !== vnode.context &&
  5548. i !== vnode.fnContext &&
  5549. isDef(i = i.$options._scopeId)
  5550. ) {
  5551. nodeOps.setStyleScope(vnode.elm, i);
  5552. }
  5553. }
  5554. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  5555. for (; startIdx <= endIdx; ++startIdx) {
  5556. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  5557. }
  5558. }
  5559. function invokeDestroyHook (vnode) {
  5560. var i, j;
  5561. var data = vnode.data;
  5562. if (isDef(data)) {
  5563. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  5564. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  5565. }
  5566. if (isDef(i = vnode.children)) {
  5567. for (j = 0; j < vnode.children.length; ++j) {
  5568. invokeDestroyHook(vnode.children[j]);
  5569. }
  5570. }
  5571. }
  5572. function removeVnodes (vnodes, startIdx, endIdx) {
  5573. for (; startIdx <= endIdx; ++startIdx) {
  5574. var ch = vnodes[startIdx];
  5575. if (isDef(ch)) {
  5576. if (isDef(ch.tag)) {
  5577. removeAndInvokeRemoveHook(ch);
  5578. invokeDestroyHook(ch);
  5579. } else { // Text node
  5580. removeNode(ch.elm);
  5581. }
  5582. }
  5583. }
  5584. }
  5585. function removeAndInvokeRemoveHook (vnode, rm) {
  5586. if (isDef(rm) || isDef(vnode.data)) {
  5587. var i;
  5588. var listeners = cbs.remove.length + 1;
  5589. if (isDef(rm)) {
  5590. // we have a recursively passed down rm callback
  5591. // increase the listeners count
  5592. rm.listeners += listeners;
  5593. } else {
  5594. // directly removing
  5595. rm = createRmCb(vnode.elm, listeners);
  5596. }
  5597. // recursively invoke hooks on child component root node
  5598. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  5599. removeAndInvokeRemoveHook(i, rm);
  5600. }
  5601. for (i = 0; i < cbs.remove.length; ++i) {
  5602. cbs.remove[i](vnode, rm);
  5603. }
  5604. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  5605. i(vnode, rm);
  5606. } else {
  5607. rm();
  5608. }
  5609. } else {
  5610. removeNode(vnode.elm);
  5611. }
  5612. }
  5613. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  5614. var oldStartIdx = 0;
  5615. var newStartIdx = 0;
  5616. var oldEndIdx = oldCh.length - 1;
  5617. var oldStartVnode = oldCh[0];
  5618. var oldEndVnode = oldCh[oldEndIdx];
  5619. var newEndIdx = newCh.length - 1;
  5620. var newStartVnode = newCh[0];
  5621. var newEndVnode = newCh[newEndIdx];
  5622. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  5623. // removeOnly is a special flag used only by <transition-group>
  5624. // to ensure removed elements stay in correct relative positions
  5625. // during leaving transitions
  5626. var canMove = !removeOnly;
  5627. if (process.env.NODE_ENV !== 'production') {
  5628. checkDuplicateKeys(newCh);
  5629. }
  5630. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  5631. if (isUndef(oldStartVnode)) {
  5632. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  5633. } else if (isUndef(oldEndVnode)) {
  5634. oldEndVnode = oldCh[--oldEndIdx];
  5635. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  5636. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5637. oldStartVnode = oldCh[++oldStartIdx];
  5638. newStartVnode = newCh[++newStartIdx];
  5639. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  5640. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5641. oldEndVnode = oldCh[--oldEndIdx];
  5642. newEndVnode = newCh[--newEndIdx];
  5643. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  5644. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5645. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  5646. oldStartVnode = oldCh[++oldStartIdx];
  5647. newEndVnode = newCh[--newEndIdx];
  5648. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  5649. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5650. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  5651. oldEndVnode = oldCh[--oldEndIdx];
  5652. newStartVnode = newCh[++newStartIdx];
  5653. } else {
  5654. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  5655. idxInOld = isDef(newStartVnode.key)
  5656. ? oldKeyToIdx[newStartVnode.key]
  5657. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  5658. if (isUndef(idxInOld)) { // New element
  5659. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5660. } else {
  5661. vnodeToMove = oldCh[idxInOld];
  5662. if (sameVnode(vnodeToMove, newStartVnode)) {
  5663. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5664. oldCh[idxInOld] = undefined;
  5665. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  5666. } else {
  5667. // same key but different element. treat as new element
  5668. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5669. }
  5670. }
  5671. newStartVnode = newCh[++newStartIdx];
  5672. }
  5673. }
  5674. if (oldStartIdx > oldEndIdx) {
  5675. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  5676. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  5677. } else if (newStartIdx > newEndIdx) {
  5678. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  5679. }
  5680. }
  5681. function checkDuplicateKeys (children) {
  5682. var seenKeys = {};
  5683. for (var i = 0; i < children.length; i++) {
  5684. var vnode = children[i];
  5685. var key = vnode.key;
  5686. if (isDef(key)) {
  5687. if (seenKeys[key]) {
  5688. warn(
  5689. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  5690. vnode.context
  5691. );
  5692. } else {
  5693. seenKeys[key] = true;
  5694. }
  5695. }
  5696. }
  5697. }
  5698. function findIdxInOld (node, oldCh, start, end) {
  5699. for (var i = start; i < end; i++) {
  5700. var c = oldCh[i];
  5701. if (isDef(c) && sameVnode(node, c)) { return i }
  5702. }
  5703. }
  5704. function patchVnode (
  5705. oldVnode,
  5706. vnode,
  5707. insertedVnodeQueue,
  5708. ownerArray,
  5709. index,
  5710. removeOnly
  5711. ) {
  5712. if (oldVnode === vnode) {
  5713. return
  5714. }
  5715. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5716. // clone reused vnode
  5717. vnode = ownerArray[index] = cloneVNode(vnode);
  5718. }
  5719. var elm = vnode.elm = oldVnode.elm;
  5720. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  5721. if (isDef(vnode.asyncFactory.resolved)) {
  5722. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  5723. } else {
  5724. vnode.isAsyncPlaceholder = true;
  5725. }
  5726. return
  5727. }
  5728. // reuse element for static trees.
  5729. // note we only do this if the vnode is cloned -
  5730. // if the new node is not cloned it means the render functions have been
  5731. // reset by the hot-reload-api and we need to do a proper re-render.
  5732. if (isTrue(vnode.isStatic) &&
  5733. isTrue(oldVnode.isStatic) &&
  5734. vnode.key === oldVnode.key &&
  5735. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  5736. ) {
  5737. vnode.componentInstance = oldVnode.componentInstance;
  5738. return
  5739. }
  5740. var i;
  5741. var data = vnode.data;
  5742. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  5743. i(oldVnode, vnode);
  5744. }
  5745. var oldCh = oldVnode.children;
  5746. var ch = vnode.children;
  5747. if (isDef(data) && isPatchable(vnode)) {
  5748. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  5749. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  5750. }
  5751. if (isUndef(vnode.text)) {
  5752. if (isDef(oldCh) && isDef(ch)) {
  5753. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  5754. } else if (isDef(ch)) {
  5755. if (process.env.NODE_ENV !== 'production') {
  5756. checkDuplicateKeys(ch);
  5757. }
  5758. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  5759. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  5760. } else if (isDef(oldCh)) {
  5761. removeVnodes(oldCh, 0, oldCh.length - 1);
  5762. } else if (isDef(oldVnode.text)) {
  5763. nodeOps.setTextContent(elm, '');
  5764. }
  5765. } else if (oldVnode.text !== vnode.text) {
  5766. nodeOps.setTextContent(elm, vnode.text);
  5767. }
  5768. if (isDef(data)) {
  5769. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  5770. }
  5771. }
  5772. function invokeInsertHook (vnode, queue, initial) {
  5773. // delay insert hooks for component root nodes, invoke them after the
  5774. // element is really inserted
  5775. if (isTrue(initial) && isDef(vnode.parent)) {
  5776. vnode.parent.data.pendingInsert = queue;
  5777. } else {
  5778. for (var i = 0; i < queue.length; ++i) {
  5779. queue[i].data.hook.insert(queue[i]);
  5780. }
  5781. }
  5782. }
  5783. var hydrationBailed = false;
  5784. // list of modules that can skip create hook during hydration because they
  5785. // are already rendered on the client or has no need for initialization
  5786. // Note: style is excluded because it relies on initial clone for future
  5787. // deep updates (#7063).
  5788. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  5789. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  5790. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  5791. var i;
  5792. var tag = vnode.tag;
  5793. var data = vnode.data;
  5794. var children = vnode.children;
  5795. inVPre = inVPre || (data && data.pre);
  5796. vnode.elm = elm;
  5797. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  5798. vnode.isAsyncPlaceholder = true;
  5799. return true
  5800. }
  5801. // assert node match
  5802. if (process.env.NODE_ENV !== 'production') {
  5803. if (!assertNodeMatch(elm, vnode, inVPre)) {
  5804. return false
  5805. }
  5806. }
  5807. if (isDef(data)) {
  5808. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  5809. if (isDef(i = vnode.componentInstance)) {
  5810. // child component. it should have hydrated its own tree.
  5811. initComponent(vnode, insertedVnodeQueue);
  5812. return true
  5813. }
  5814. }
  5815. if (isDef(tag)) {
  5816. if (isDef(children)) {
  5817. // empty element, allow client to pick up and populate children
  5818. if (!elm.hasChildNodes()) {
  5819. createChildren(vnode, children, insertedVnodeQueue);
  5820. } else {
  5821. // v-html and domProps: innerHTML
  5822. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  5823. if (i !== elm.innerHTML) {
  5824. /* istanbul ignore if */
  5825. if (process.env.NODE_ENV !== 'production' &&
  5826. typeof console !== 'undefined' &&
  5827. !hydrationBailed
  5828. ) {
  5829. hydrationBailed = true;
  5830. console.warn('Parent: ', elm);
  5831. console.warn('server innerHTML: ', i);
  5832. console.warn('client innerHTML: ', elm.innerHTML);
  5833. }
  5834. return false
  5835. }
  5836. } else {
  5837. // iterate and compare children lists
  5838. var childrenMatch = true;
  5839. var childNode = elm.firstChild;
  5840. for (var i$1 = 0; i$1 < children.length; i$1++) {
  5841. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  5842. childrenMatch = false;
  5843. break
  5844. }
  5845. childNode = childNode.nextSibling;
  5846. }
  5847. // if childNode is not null, it means the actual childNodes list is
  5848. // longer than the virtual children list.
  5849. if (!childrenMatch || childNode) {
  5850. /* istanbul ignore if */
  5851. if (process.env.NODE_ENV !== 'production' &&
  5852. typeof console !== 'undefined' &&
  5853. !hydrationBailed
  5854. ) {
  5855. hydrationBailed = true;
  5856. console.warn('Parent: ', elm);
  5857. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  5858. }
  5859. return false
  5860. }
  5861. }
  5862. }
  5863. }
  5864. if (isDef(data)) {
  5865. var fullInvoke = false;
  5866. for (var key in data) {
  5867. if (!isRenderedModule(key)) {
  5868. fullInvoke = true;
  5869. invokeCreateHooks(vnode, insertedVnodeQueue);
  5870. break
  5871. }
  5872. }
  5873. if (!fullInvoke && data['class']) {
  5874. // ensure collecting deps for deep class bindings for future updates
  5875. traverse(data['class']);
  5876. }
  5877. }
  5878. } else if (elm.data !== vnode.text) {
  5879. elm.data = vnode.text;
  5880. }
  5881. return true
  5882. }
  5883. function assertNodeMatch (node, vnode, inVPre) {
  5884. if (isDef(vnode.tag)) {
  5885. return vnode.tag.indexOf('vue-component') === 0 || (
  5886. !isUnknownElement$$1(vnode, inVPre) &&
  5887. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  5888. )
  5889. } else {
  5890. return node.nodeType === (vnode.isComment ? 8 : 3)
  5891. }
  5892. }
  5893. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  5894. if (isUndef(vnode)) {
  5895. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  5896. return
  5897. }
  5898. var isInitialPatch = false;
  5899. var insertedVnodeQueue = [];
  5900. if (isUndef(oldVnode)) {
  5901. // empty mount (likely as component), create new root element
  5902. isInitialPatch = true;
  5903. createElm(vnode, insertedVnodeQueue);
  5904. } else {
  5905. var isRealElement = isDef(oldVnode.nodeType);
  5906. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  5907. // patch existing root node
  5908. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  5909. } else {
  5910. if (isRealElement) {
  5911. // mounting to a real element
  5912. // check if this is server-rendered content and if we can perform
  5913. // a successful hydration.
  5914. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  5915. oldVnode.removeAttribute(SSR_ATTR);
  5916. hydrating = true;
  5917. }
  5918. if (isTrue(hydrating)) {
  5919. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  5920. invokeInsertHook(vnode, insertedVnodeQueue, true);
  5921. return oldVnode
  5922. } else if (process.env.NODE_ENV !== 'production') {
  5923. warn(
  5924. 'The client-side rendered virtual DOM tree is not matching ' +
  5925. 'server-rendered content. This is likely caused by incorrect ' +
  5926. 'HTML markup, for example nesting block-level elements inside ' +
  5927. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  5928. 'full client-side render.'
  5929. );
  5930. }
  5931. }
  5932. // either not server-rendered, or hydration failed.
  5933. // create an empty node and replace it
  5934. oldVnode = emptyNodeAt(oldVnode);
  5935. }
  5936. // replacing existing element
  5937. var oldElm = oldVnode.elm;
  5938. var parentElm = nodeOps.parentNode(oldElm);
  5939. // create new node
  5940. createElm(
  5941. vnode,
  5942. insertedVnodeQueue,
  5943. // extremely rare edge case: do not insert if old element is in a
  5944. // leaving transition. Only happens when combining transition +
  5945. // keep-alive + HOCs. (#4590)
  5946. oldElm._leaveCb ? null : parentElm,
  5947. nodeOps.nextSibling(oldElm)
  5948. );
  5949. // update parent placeholder node element, recursively
  5950. if (isDef(vnode.parent)) {
  5951. var ancestor = vnode.parent;
  5952. var patchable = isPatchable(vnode);
  5953. while (ancestor) {
  5954. for (var i = 0; i < cbs.destroy.length; ++i) {
  5955. cbs.destroy[i](ancestor);
  5956. }
  5957. ancestor.elm = vnode.elm;
  5958. if (patchable) {
  5959. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  5960. cbs.create[i$1](emptyNode, ancestor);
  5961. }
  5962. // #6513
  5963. // invoke insert hooks that may have been merged by create hooks.
  5964. // e.g. for directives that uses the "inserted" hook.
  5965. var insert = ancestor.data.hook.insert;
  5966. if (insert.merged) {
  5967. // start at index 1 to avoid re-invoking component mounted hook
  5968. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  5969. insert.fns[i$2]();
  5970. }
  5971. }
  5972. } else {
  5973. registerRef(ancestor);
  5974. }
  5975. ancestor = ancestor.parent;
  5976. }
  5977. }
  5978. // destroy old node
  5979. if (isDef(parentElm)) {
  5980. removeVnodes([oldVnode], 0, 0);
  5981. } else if (isDef(oldVnode.tag)) {
  5982. invokeDestroyHook(oldVnode);
  5983. }
  5984. }
  5985. }
  5986. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  5987. return vnode.elm
  5988. }
  5989. }
  5990. /* */
  5991. var directives = {
  5992. create: updateDirectives,
  5993. update: updateDirectives,
  5994. destroy: function unbindDirectives (vnode) {
  5995. updateDirectives(vnode, emptyNode);
  5996. }
  5997. };
  5998. function updateDirectives (oldVnode, vnode) {
  5999. if (oldVnode.data.directives || vnode.data.directives) {
  6000. _update(oldVnode, vnode);
  6001. }
  6002. }
  6003. function _update (oldVnode, vnode) {
  6004. var isCreate = oldVnode === emptyNode;
  6005. var isDestroy = vnode === emptyNode;
  6006. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  6007. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  6008. var dirsWithInsert = [];
  6009. var dirsWithPostpatch = [];
  6010. var key, oldDir, dir;
  6011. for (key in newDirs) {
  6012. oldDir = oldDirs[key];
  6013. dir = newDirs[key];
  6014. if (!oldDir) {
  6015. // new directive, bind
  6016. callHook$1(dir, 'bind', vnode, oldVnode);
  6017. if (dir.def && dir.def.inserted) {
  6018. dirsWithInsert.push(dir);
  6019. }
  6020. } else {
  6021. // existing directive, update
  6022. dir.oldValue = oldDir.value;
  6023. dir.oldArg = oldDir.arg;
  6024. callHook$1(dir, 'update', vnode, oldVnode);
  6025. if (dir.def && dir.def.componentUpdated) {
  6026. dirsWithPostpatch.push(dir);
  6027. }
  6028. }
  6029. }
  6030. if (dirsWithInsert.length) {
  6031. var callInsert = function () {
  6032. for (var i = 0; i < dirsWithInsert.length; i++) {
  6033. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  6034. }
  6035. };
  6036. if (isCreate) {
  6037. mergeVNodeHook(vnode, 'insert', callInsert);
  6038. } else {
  6039. callInsert();
  6040. }
  6041. }
  6042. if (dirsWithPostpatch.length) {
  6043. mergeVNodeHook(vnode, 'postpatch', function () {
  6044. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  6045. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  6046. }
  6047. });
  6048. }
  6049. if (!isCreate) {
  6050. for (key in oldDirs) {
  6051. if (!newDirs[key]) {
  6052. // no longer present, unbind
  6053. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  6054. }
  6055. }
  6056. }
  6057. }
  6058. var emptyModifiers = Object.create(null);
  6059. function normalizeDirectives$1 (
  6060. dirs,
  6061. vm
  6062. ) {
  6063. var res = Object.create(null);
  6064. if (!dirs) {
  6065. // $flow-disable-line
  6066. return res
  6067. }
  6068. var i, dir;
  6069. for (i = 0; i < dirs.length; i++) {
  6070. dir = dirs[i];
  6071. if (!dir.modifiers) {
  6072. // $flow-disable-line
  6073. dir.modifiers = emptyModifiers;
  6074. }
  6075. res[getRawDirName(dir)] = dir;
  6076. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  6077. }
  6078. // $flow-disable-line
  6079. return res
  6080. }
  6081. function getRawDirName (dir) {
  6082. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  6083. }
  6084. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  6085. var fn = dir.def && dir.def[hook];
  6086. if (fn) {
  6087. try {
  6088. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  6089. } catch (e) {
  6090. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  6091. }
  6092. }
  6093. }
  6094. var baseModules = [
  6095. ref,
  6096. directives
  6097. ];
  6098. /* */
  6099. function updateAttrs (oldVnode, vnode) {
  6100. var opts = vnode.componentOptions;
  6101. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  6102. return
  6103. }
  6104. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  6105. return
  6106. }
  6107. var key, cur, old;
  6108. var elm = vnode.elm;
  6109. var oldAttrs = oldVnode.data.attrs || {};
  6110. var attrs = vnode.data.attrs || {};
  6111. // clone observed objects, as the user probably wants to mutate it
  6112. if (isDef(attrs.__ob__)) {
  6113. attrs = vnode.data.attrs = extend({}, attrs);
  6114. }
  6115. for (key in attrs) {
  6116. cur = attrs[key];
  6117. old = oldAttrs[key];
  6118. if (old !== cur) {
  6119. setAttr(elm, key, cur, vnode.data.pre);
  6120. }
  6121. }
  6122. // #4391: in IE9, setting type can reset value for input[type=radio]
  6123. // #6666: IE/Edge forces progress value down to 1 before setting a max
  6124. /* istanbul ignore if */
  6125. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  6126. setAttr(elm, 'value', attrs.value);
  6127. }
  6128. for (key in oldAttrs) {
  6129. if (isUndef(attrs[key])) {
  6130. if (isXlink(key)) {
  6131. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6132. } else if (!isEnumeratedAttr(key)) {
  6133. elm.removeAttribute(key);
  6134. }
  6135. }
  6136. }
  6137. }
  6138. function setAttr (el, key, value, isInPre) {
  6139. if (isInPre || el.tagName.indexOf('-') > -1) {
  6140. baseSetAttr(el, key, value);
  6141. } else if (isBooleanAttr(key)) {
  6142. // set attribute for blank value
  6143. // e.g. <option disabled>Select one</option>
  6144. if (isFalsyAttrValue(value)) {
  6145. el.removeAttribute(key);
  6146. } else {
  6147. // technically allowfullscreen is a boolean attribute for <iframe>,
  6148. // but Flash expects a value of "true" when used on <embed> tag
  6149. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  6150. ? 'true'
  6151. : key;
  6152. el.setAttribute(key, value);
  6153. }
  6154. } else if (isEnumeratedAttr(key)) {
  6155. el.setAttribute(key, convertEnumeratedValue(key, value));
  6156. } else if (isXlink(key)) {
  6157. if (isFalsyAttrValue(value)) {
  6158. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6159. } else {
  6160. el.setAttributeNS(xlinkNS, key, value);
  6161. }
  6162. } else {
  6163. baseSetAttr(el, key, value);
  6164. }
  6165. }
  6166. function baseSetAttr (el, key, value) {
  6167. if (isFalsyAttrValue(value)) {
  6168. el.removeAttribute(key);
  6169. } else {
  6170. // #7138: IE10 & 11 fires input event when setting placeholder on
  6171. // <textarea>... block the first input event and remove the blocker
  6172. // immediately.
  6173. /* istanbul ignore if */
  6174. if (
  6175. isIE && !isIE9 &&
  6176. el.tagName === 'TEXTAREA' &&
  6177. key === 'placeholder' && value !== '' && !el.__ieph
  6178. ) {
  6179. var blocker = function (e) {
  6180. e.stopImmediatePropagation();
  6181. el.removeEventListener('input', blocker);
  6182. };
  6183. el.addEventListener('input', blocker);
  6184. // $flow-disable-line
  6185. el.__ieph = true; /* IE placeholder patched */
  6186. }
  6187. el.setAttribute(key, value);
  6188. }
  6189. }
  6190. var attrs = {
  6191. create: updateAttrs,
  6192. update: updateAttrs
  6193. };
  6194. /* */
  6195. function updateClass (oldVnode, vnode) {
  6196. var el = vnode.elm;
  6197. var data = vnode.data;
  6198. var oldData = oldVnode.data;
  6199. if (
  6200. isUndef(data.staticClass) &&
  6201. isUndef(data.class) && (
  6202. isUndef(oldData) || (
  6203. isUndef(oldData.staticClass) &&
  6204. isUndef(oldData.class)
  6205. )
  6206. )
  6207. ) {
  6208. return
  6209. }
  6210. var cls = genClassForVnode(vnode);
  6211. // handle transition classes
  6212. var transitionClass = el._transitionClasses;
  6213. if (isDef(transitionClass)) {
  6214. cls = concat(cls, stringifyClass(transitionClass));
  6215. }
  6216. // set the class
  6217. if (cls !== el._prevClass) {
  6218. el.setAttribute('class', cls);
  6219. el._prevClass = cls;
  6220. }
  6221. }
  6222. var klass = {
  6223. create: updateClass,
  6224. update: updateClass
  6225. };
  6226. /* */
  6227. /* */
  6228. /* */
  6229. /* */
  6230. // in some cases, the event used has to be determined at runtime
  6231. // so we used some reserved tokens during compile.
  6232. var RANGE_TOKEN = '__r';
  6233. var CHECKBOX_RADIO_TOKEN = '__c';
  6234. /* */
  6235. // normalize v-model event tokens that can only be determined at runtime.
  6236. // it's important to place the event as the first in the array because
  6237. // the whole point is ensuring the v-model callback gets called before
  6238. // user-attached handlers.
  6239. function normalizeEvents (on) {
  6240. /* istanbul ignore if */
  6241. if (isDef(on[RANGE_TOKEN])) {
  6242. // IE input[type=range] only supports `change` event
  6243. var event = isIE ? 'change' : 'input';
  6244. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  6245. delete on[RANGE_TOKEN];
  6246. }
  6247. // This was originally intended to fix #4521 but no longer necessary
  6248. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  6249. /* istanbul ignore if */
  6250. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  6251. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  6252. delete on[CHECKBOX_RADIO_TOKEN];
  6253. }
  6254. }
  6255. var target$1;
  6256. function createOnceHandler$1 (event, handler, capture) {
  6257. var _target = target$1; // save current target element in closure
  6258. return function onceHandler () {
  6259. var res = handler.apply(null, arguments);
  6260. if (res !== null) {
  6261. remove$2(event, onceHandler, capture, _target);
  6262. }
  6263. }
  6264. }
  6265. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  6266. // implementation and does not fire microtasks in between event propagation, so
  6267. // safe to exclude.
  6268. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  6269. function add$1 (
  6270. name,
  6271. handler,
  6272. capture,
  6273. passive
  6274. ) {
  6275. // async edge case #6566: inner click event triggers patch, event handler
  6276. // attached to outer element during patch, and triggered again. This
  6277. // happens because browsers fire microtask ticks between event propagation.
  6278. // the solution is simple: we save the timestamp when a handler is attached,
  6279. // and the handler would only fire if the event passed to it was fired
  6280. // AFTER it was attached.
  6281. if (useMicrotaskFix) {
  6282. var attachedTimestamp = currentFlushTimestamp;
  6283. var original = handler;
  6284. handler = original._wrapper = function (e) {
  6285. if (
  6286. // no bubbling, should always fire.
  6287. // this is just a safety net in case event.timeStamp is unreliable in
  6288. // certain weird environments...
  6289. e.target === e.currentTarget ||
  6290. // event is fired after handler attachment
  6291. e.timeStamp >= attachedTimestamp ||
  6292. // bail for environments that have buggy event.timeStamp implementations
  6293. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  6294. // #9681 QtWebEngine event.timeStamp is negative value
  6295. e.timeStamp <= 0 ||
  6296. // #9448 bail if event is fired in another document in a multi-page
  6297. // electron/nw.js app, since event.timeStamp will be using a different
  6298. // starting reference
  6299. e.target.ownerDocument !== document
  6300. ) {
  6301. return original.apply(this, arguments)
  6302. }
  6303. };
  6304. }
  6305. target$1.addEventListener(
  6306. name,
  6307. handler,
  6308. supportsPassive
  6309. ? { capture: capture, passive: passive }
  6310. : capture
  6311. );
  6312. }
  6313. function remove$2 (
  6314. name,
  6315. handler,
  6316. capture,
  6317. _target
  6318. ) {
  6319. (_target || target$1).removeEventListener(
  6320. name,
  6321. handler._wrapper || handler,
  6322. capture
  6323. );
  6324. }
  6325. function updateDOMListeners (oldVnode, vnode) {
  6326. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  6327. return
  6328. }
  6329. var on = vnode.data.on || {};
  6330. var oldOn = oldVnode.data.on || {};
  6331. target$1 = vnode.elm;
  6332. normalizeEvents(on);
  6333. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  6334. target$1 = undefined;
  6335. }
  6336. var events = {
  6337. create: updateDOMListeners,
  6338. update: updateDOMListeners
  6339. };
  6340. /* */
  6341. var svgContainer;
  6342. function updateDOMProps (oldVnode, vnode) {
  6343. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  6344. return
  6345. }
  6346. var key, cur;
  6347. var elm = vnode.elm;
  6348. var oldProps = oldVnode.data.domProps || {};
  6349. var props = vnode.data.domProps || {};
  6350. // clone observed objects, as the user probably wants to mutate it
  6351. if (isDef(props.__ob__)) {
  6352. props = vnode.data.domProps = extend({}, props);
  6353. }
  6354. for (key in oldProps) {
  6355. if (!(key in props)) {
  6356. elm[key] = '';
  6357. }
  6358. }
  6359. for (key in props) {
  6360. cur = props[key];
  6361. // ignore children if the node has textContent or innerHTML,
  6362. // as these will throw away existing DOM nodes and cause removal errors
  6363. // on subsequent patches (#3360)
  6364. if (key === 'textContent' || key === 'innerHTML') {
  6365. if (vnode.children) { vnode.children.length = 0; }
  6366. if (cur === oldProps[key]) { continue }
  6367. // #6601 work around Chrome version <= 55 bug where single textNode
  6368. // replaced by innerHTML/textContent retains its parentNode property
  6369. if (elm.childNodes.length === 1) {
  6370. elm.removeChild(elm.childNodes[0]);
  6371. }
  6372. }
  6373. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  6374. // store value as _value as well since
  6375. // non-string values will be stringified
  6376. elm._value = cur;
  6377. // avoid resetting cursor position when value is the same
  6378. var strCur = isUndef(cur) ? '' : String(cur);
  6379. if (shouldUpdateValue(elm, strCur)) {
  6380. elm.value = strCur;
  6381. }
  6382. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  6383. // IE doesn't support innerHTML for SVG elements
  6384. svgContainer = svgContainer || document.createElement('div');
  6385. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  6386. var svg = svgContainer.firstChild;
  6387. while (elm.firstChild) {
  6388. elm.removeChild(elm.firstChild);
  6389. }
  6390. while (svg.firstChild) {
  6391. elm.appendChild(svg.firstChild);
  6392. }
  6393. } else if (
  6394. // skip the update if old and new VDOM state is the same.
  6395. // `value` is handled separately because the DOM value may be temporarily
  6396. // out of sync with VDOM state due to focus, composition and modifiers.
  6397. // This #4521 by skipping the unnecessary `checked` update.
  6398. cur !== oldProps[key]
  6399. ) {
  6400. // some property updates can throw
  6401. // e.g. `value` on <progress> w/ non-finite value
  6402. try {
  6403. elm[key] = cur;
  6404. } catch (e) {}
  6405. }
  6406. }
  6407. }
  6408. // check platforms/web/util/attrs.js acceptValue
  6409. function shouldUpdateValue (elm, checkVal) {
  6410. return (!elm.composing && (
  6411. elm.tagName === 'OPTION' ||
  6412. isNotInFocusAndDirty(elm, checkVal) ||
  6413. isDirtyWithModifiers(elm, checkVal)
  6414. ))
  6415. }
  6416. function isNotInFocusAndDirty (elm, checkVal) {
  6417. // return true when textbox (.number and .trim) loses focus and its value is
  6418. // not equal to the updated value
  6419. var notInFocus = true;
  6420. // #6157
  6421. // work around IE bug when accessing document.activeElement in an iframe
  6422. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  6423. return notInFocus && elm.value !== checkVal
  6424. }
  6425. function isDirtyWithModifiers (elm, newVal) {
  6426. var value = elm.value;
  6427. var modifiers = elm._vModifiers; // injected by v-model runtime
  6428. if (isDef(modifiers)) {
  6429. if (modifiers.number) {
  6430. return toNumber(value) !== toNumber(newVal)
  6431. }
  6432. if (modifiers.trim) {
  6433. return value.trim() !== newVal.trim()
  6434. }
  6435. }
  6436. return value !== newVal
  6437. }
  6438. var domProps = {
  6439. create: updateDOMProps,
  6440. update: updateDOMProps
  6441. };
  6442. /* */
  6443. var parseStyleText = cached(function (cssText) {
  6444. var res = {};
  6445. var listDelimiter = /;(?![^(]*\))/g;
  6446. var propertyDelimiter = /:(.+)/;
  6447. cssText.split(listDelimiter).forEach(function (item) {
  6448. if (item) {
  6449. var tmp = item.split(propertyDelimiter);
  6450. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  6451. }
  6452. });
  6453. return res
  6454. });
  6455. // merge static and dynamic style data on the same vnode
  6456. function normalizeStyleData (data) {
  6457. var style = normalizeStyleBinding(data.style);
  6458. // static style is pre-processed into an object during compilation
  6459. // and is always a fresh object, so it's safe to merge into it
  6460. return data.staticStyle
  6461. ? extend(data.staticStyle, style)
  6462. : style
  6463. }
  6464. // normalize possible array / string values into Object
  6465. function normalizeStyleBinding (bindingStyle) {
  6466. if (Array.isArray(bindingStyle)) {
  6467. return toObject(bindingStyle)
  6468. }
  6469. if (typeof bindingStyle === 'string') {
  6470. return parseStyleText(bindingStyle)
  6471. }
  6472. return bindingStyle
  6473. }
  6474. /**
  6475. * parent component style should be after child's
  6476. * so that parent component's style could override it
  6477. */
  6478. function getStyle (vnode, checkChild) {
  6479. var res = {};
  6480. var styleData;
  6481. if (checkChild) {
  6482. var childNode = vnode;
  6483. while (childNode.componentInstance) {
  6484. childNode = childNode.componentInstance._vnode;
  6485. if (
  6486. childNode && childNode.data &&
  6487. (styleData = normalizeStyleData(childNode.data))
  6488. ) {
  6489. extend(res, styleData);
  6490. }
  6491. }
  6492. }
  6493. if ((styleData = normalizeStyleData(vnode.data))) {
  6494. extend(res, styleData);
  6495. }
  6496. var parentNode = vnode;
  6497. while ((parentNode = parentNode.parent)) {
  6498. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  6499. extend(res, styleData);
  6500. }
  6501. }
  6502. return res
  6503. }
  6504. /* */
  6505. var cssVarRE = /^--/;
  6506. var importantRE = /\s*!important$/;
  6507. var setProp = function (el, name, val) {
  6508. /* istanbul ignore if */
  6509. if (cssVarRE.test(name)) {
  6510. el.style.setProperty(name, val);
  6511. } else if (importantRE.test(val)) {
  6512. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  6513. } else {
  6514. var normalizedName = normalize(name);
  6515. if (Array.isArray(val)) {
  6516. // Support values array created by autoprefixer, e.g.
  6517. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  6518. // Set them one by one, and the browser will only set those it can recognize
  6519. for (var i = 0, len = val.length; i < len; i++) {
  6520. el.style[normalizedName] = val[i];
  6521. }
  6522. } else {
  6523. el.style[normalizedName] = val;
  6524. }
  6525. }
  6526. };
  6527. var vendorNames = ['Webkit', 'Moz', 'ms'];
  6528. var emptyStyle;
  6529. var normalize = cached(function (prop) {
  6530. emptyStyle = emptyStyle || document.createElement('div').style;
  6531. prop = camelize(prop);
  6532. if (prop !== 'filter' && (prop in emptyStyle)) {
  6533. return prop
  6534. }
  6535. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  6536. for (var i = 0; i < vendorNames.length; i++) {
  6537. var name = vendorNames[i] + capName;
  6538. if (name in emptyStyle) {
  6539. return name
  6540. }
  6541. }
  6542. });
  6543. function updateStyle (oldVnode, vnode) {
  6544. var data = vnode.data;
  6545. var oldData = oldVnode.data;
  6546. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  6547. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  6548. ) {
  6549. return
  6550. }
  6551. var cur, name;
  6552. var el = vnode.elm;
  6553. var oldStaticStyle = oldData.staticStyle;
  6554. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  6555. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  6556. var oldStyle = oldStaticStyle || oldStyleBinding;
  6557. var style = normalizeStyleBinding(vnode.data.style) || {};
  6558. // store normalized style under a different key for next diff
  6559. // make sure to clone it if it's reactive, since the user likely wants
  6560. // to mutate it.
  6561. vnode.data.normalizedStyle = isDef(style.__ob__)
  6562. ? extend({}, style)
  6563. : style;
  6564. var newStyle = getStyle(vnode, true);
  6565. for (name in oldStyle) {
  6566. if (isUndef(newStyle[name])) {
  6567. setProp(el, name, '');
  6568. }
  6569. }
  6570. for (name in newStyle) {
  6571. cur = newStyle[name];
  6572. if (cur !== oldStyle[name]) {
  6573. // ie9 setting to null has no effect, must use empty string
  6574. setProp(el, name, cur == null ? '' : cur);
  6575. }
  6576. }
  6577. }
  6578. var style = {
  6579. create: updateStyle,
  6580. update: updateStyle
  6581. };
  6582. /* */
  6583. var whitespaceRE = /\s+/;
  6584. /**
  6585. * Add class with compatibility for SVG since classList is not supported on
  6586. * SVG elements in IE
  6587. */
  6588. function addClass (el, cls) {
  6589. /* istanbul ignore if */
  6590. if (!cls || !(cls = cls.trim())) {
  6591. return
  6592. }
  6593. /* istanbul ignore else */
  6594. if (el.classList) {
  6595. if (cls.indexOf(' ') > -1) {
  6596. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  6597. } else {
  6598. el.classList.add(cls);
  6599. }
  6600. } else {
  6601. var cur = " " + (el.getAttribute('class') || '') + " ";
  6602. if (cur.indexOf(' ' + cls + ' ') < 0) {
  6603. el.setAttribute('class', (cur + cls).trim());
  6604. }
  6605. }
  6606. }
  6607. /**
  6608. * Remove class with compatibility for SVG since classList is not supported on
  6609. * SVG elements in IE
  6610. */
  6611. function removeClass (el, cls) {
  6612. /* istanbul ignore if */
  6613. if (!cls || !(cls = cls.trim())) {
  6614. return
  6615. }
  6616. /* istanbul ignore else */
  6617. if (el.classList) {
  6618. if (cls.indexOf(' ') > -1) {
  6619. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  6620. } else {
  6621. el.classList.remove(cls);
  6622. }
  6623. if (!el.classList.length) {
  6624. el.removeAttribute('class');
  6625. }
  6626. } else {
  6627. var cur = " " + (el.getAttribute('class') || '') + " ";
  6628. var tar = ' ' + cls + ' ';
  6629. while (cur.indexOf(tar) >= 0) {
  6630. cur = cur.replace(tar, ' ');
  6631. }
  6632. cur = cur.trim();
  6633. if (cur) {
  6634. el.setAttribute('class', cur);
  6635. } else {
  6636. el.removeAttribute('class');
  6637. }
  6638. }
  6639. }
  6640. /* */
  6641. function resolveTransition (def$$1) {
  6642. if (!def$$1) {
  6643. return
  6644. }
  6645. /* istanbul ignore else */
  6646. if (typeof def$$1 === 'object') {
  6647. var res = {};
  6648. if (def$$1.css !== false) {
  6649. extend(res, autoCssTransition(def$$1.name || 'v'));
  6650. }
  6651. extend(res, def$$1);
  6652. return res
  6653. } else if (typeof def$$1 === 'string') {
  6654. return autoCssTransition(def$$1)
  6655. }
  6656. }
  6657. var autoCssTransition = cached(function (name) {
  6658. return {
  6659. enterClass: (name + "-enter"),
  6660. enterToClass: (name + "-enter-to"),
  6661. enterActiveClass: (name + "-enter-active"),
  6662. leaveClass: (name + "-leave"),
  6663. leaveToClass: (name + "-leave-to"),
  6664. leaveActiveClass: (name + "-leave-active")
  6665. }
  6666. });
  6667. var hasTransition = inBrowser && !isIE9;
  6668. var TRANSITION = 'transition';
  6669. var ANIMATION = 'animation';
  6670. // Transition property/event sniffing
  6671. var transitionProp = 'transition';
  6672. var transitionEndEvent = 'transitionend';
  6673. var animationProp = 'animation';
  6674. var animationEndEvent = 'animationend';
  6675. if (hasTransition) {
  6676. /* istanbul ignore if */
  6677. if (window.ontransitionend === undefined &&
  6678. window.onwebkittransitionend !== undefined
  6679. ) {
  6680. transitionProp = 'WebkitTransition';
  6681. transitionEndEvent = 'webkitTransitionEnd';
  6682. }
  6683. if (window.onanimationend === undefined &&
  6684. window.onwebkitanimationend !== undefined
  6685. ) {
  6686. animationProp = 'WebkitAnimation';
  6687. animationEndEvent = 'webkitAnimationEnd';
  6688. }
  6689. }
  6690. // binding to window is necessary to make hot reload work in IE in strict mode
  6691. var raf = inBrowser
  6692. ? window.requestAnimationFrame
  6693. ? window.requestAnimationFrame.bind(window)
  6694. : setTimeout
  6695. : /* istanbul ignore next */ function (fn) { return fn(); };
  6696. function nextFrame (fn) {
  6697. raf(function () {
  6698. raf(fn);
  6699. });
  6700. }
  6701. function addTransitionClass (el, cls) {
  6702. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  6703. if (transitionClasses.indexOf(cls) < 0) {
  6704. transitionClasses.push(cls);
  6705. addClass(el, cls);
  6706. }
  6707. }
  6708. function removeTransitionClass (el, cls) {
  6709. if (el._transitionClasses) {
  6710. remove(el._transitionClasses, cls);
  6711. }
  6712. removeClass(el, cls);
  6713. }
  6714. function whenTransitionEnds (
  6715. el,
  6716. expectedType,
  6717. cb
  6718. ) {
  6719. var ref = getTransitionInfo(el, expectedType);
  6720. var type = ref.type;
  6721. var timeout = ref.timeout;
  6722. var propCount = ref.propCount;
  6723. if (!type) { return cb() }
  6724. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  6725. var ended = 0;
  6726. var end = function () {
  6727. el.removeEventListener(event, onEnd);
  6728. cb();
  6729. };
  6730. var onEnd = function (e) {
  6731. if (e.target === el) {
  6732. if (++ended >= propCount) {
  6733. end();
  6734. }
  6735. }
  6736. };
  6737. setTimeout(function () {
  6738. if (ended < propCount) {
  6739. end();
  6740. }
  6741. }, timeout + 1);
  6742. el.addEventListener(event, onEnd);
  6743. }
  6744. var transformRE = /\b(transform|all)(,|$)/;
  6745. function getTransitionInfo (el, expectedType) {
  6746. var styles = window.getComputedStyle(el);
  6747. // JSDOM may return undefined for transition properties
  6748. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  6749. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  6750. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  6751. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  6752. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  6753. var animationTimeout = getTimeout(animationDelays, animationDurations);
  6754. var type;
  6755. var timeout = 0;
  6756. var propCount = 0;
  6757. /* istanbul ignore if */
  6758. if (expectedType === TRANSITION) {
  6759. if (transitionTimeout > 0) {
  6760. type = TRANSITION;
  6761. timeout = transitionTimeout;
  6762. propCount = transitionDurations.length;
  6763. }
  6764. } else if (expectedType === ANIMATION) {
  6765. if (animationTimeout > 0) {
  6766. type = ANIMATION;
  6767. timeout = animationTimeout;
  6768. propCount = animationDurations.length;
  6769. }
  6770. } else {
  6771. timeout = Math.max(transitionTimeout, animationTimeout);
  6772. type = timeout > 0
  6773. ? transitionTimeout > animationTimeout
  6774. ? TRANSITION
  6775. : ANIMATION
  6776. : null;
  6777. propCount = type
  6778. ? type === TRANSITION
  6779. ? transitionDurations.length
  6780. : animationDurations.length
  6781. : 0;
  6782. }
  6783. var hasTransform =
  6784. type === TRANSITION &&
  6785. transformRE.test(styles[transitionProp + 'Property']);
  6786. return {
  6787. type: type,
  6788. timeout: timeout,
  6789. propCount: propCount,
  6790. hasTransform: hasTransform
  6791. }
  6792. }
  6793. function getTimeout (delays, durations) {
  6794. /* istanbul ignore next */
  6795. while (delays.length < durations.length) {
  6796. delays = delays.concat(delays);
  6797. }
  6798. return Math.max.apply(null, durations.map(function (d, i) {
  6799. return toMs(d) + toMs(delays[i])
  6800. }))
  6801. }
  6802. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  6803. // in a locale-dependent way, using a comma instead of a dot.
  6804. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  6805. // as a floor function) causing unexpected behaviors
  6806. function toMs (s) {
  6807. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  6808. }
  6809. /* */
  6810. function enter (vnode, toggleDisplay) {
  6811. var el = vnode.elm;
  6812. // call leave callback now
  6813. if (isDef(el._leaveCb)) {
  6814. el._leaveCb.cancelled = true;
  6815. el._leaveCb();
  6816. }
  6817. var data = resolveTransition(vnode.data.transition);
  6818. if (isUndef(data)) {
  6819. return
  6820. }
  6821. /* istanbul ignore if */
  6822. if (isDef(el._enterCb) || el.nodeType !== 1) {
  6823. return
  6824. }
  6825. var css = data.css;
  6826. var type = data.type;
  6827. var enterClass = data.enterClass;
  6828. var enterToClass = data.enterToClass;
  6829. var enterActiveClass = data.enterActiveClass;
  6830. var appearClass = data.appearClass;
  6831. var appearToClass = data.appearToClass;
  6832. var appearActiveClass = data.appearActiveClass;
  6833. var beforeEnter = data.beforeEnter;
  6834. var enter = data.enter;
  6835. var afterEnter = data.afterEnter;
  6836. var enterCancelled = data.enterCancelled;
  6837. var beforeAppear = data.beforeAppear;
  6838. var appear = data.appear;
  6839. var afterAppear = data.afterAppear;
  6840. var appearCancelled = data.appearCancelled;
  6841. var duration = data.duration;
  6842. // activeInstance will always be the <transition> component managing this
  6843. // transition. One edge case to check is when the <transition> is placed
  6844. // as the root node of a child component. In that case we need to check
  6845. // <transition>'s parent for appear check.
  6846. var context = activeInstance;
  6847. var transitionNode = activeInstance.$vnode;
  6848. while (transitionNode && transitionNode.parent) {
  6849. context = transitionNode.context;
  6850. transitionNode = transitionNode.parent;
  6851. }
  6852. var isAppear = !context._isMounted || !vnode.isRootInsert;
  6853. if (isAppear && !appear && appear !== '') {
  6854. return
  6855. }
  6856. var startClass = isAppear && appearClass
  6857. ? appearClass
  6858. : enterClass;
  6859. var activeClass = isAppear && appearActiveClass
  6860. ? appearActiveClass
  6861. : enterActiveClass;
  6862. var toClass = isAppear && appearToClass
  6863. ? appearToClass
  6864. : enterToClass;
  6865. var beforeEnterHook = isAppear
  6866. ? (beforeAppear || beforeEnter)
  6867. : beforeEnter;
  6868. var enterHook = isAppear
  6869. ? (typeof appear === 'function' ? appear : enter)
  6870. : enter;
  6871. var afterEnterHook = isAppear
  6872. ? (afterAppear || afterEnter)
  6873. : afterEnter;
  6874. var enterCancelledHook = isAppear
  6875. ? (appearCancelled || enterCancelled)
  6876. : enterCancelled;
  6877. var explicitEnterDuration = toNumber(
  6878. isObject(duration)
  6879. ? duration.enter
  6880. : duration
  6881. );
  6882. if (process.env.NODE_ENV !== 'production' && explicitEnterDuration != null) {
  6883. checkDuration(explicitEnterDuration, 'enter', vnode);
  6884. }
  6885. var expectsCSS = css !== false && !isIE9;
  6886. var userWantsControl = getHookArgumentsLength(enterHook);
  6887. var cb = el._enterCb = once(function () {
  6888. if (expectsCSS) {
  6889. removeTransitionClass(el, toClass);
  6890. removeTransitionClass(el, activeClass);
  6891. }
  6892. if (cb.cancelled) {
  6893. if (expectsCSS) {
  6894. removeTransitionClass(el, startClass);
  6895. }
  6896. enterCancelledHook && enterCancelledHook(el);
  6897. } else {
  6898. afterEnterHook && afterEnterHook(el);
  6899. }
  6900. el._enterCb = null;
  6901. });
  6902. if (!vnode.data.show) {
  6903. // remove pending leave element on enter by injecting an insert hook
  6904. mergeVNodeHook(vnode, 'insert', function () {
  6905. var parent = el.parentNode;
  6906. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  6907. if (pendingNode &&
  6908. pendingNode.tag === vnode.tag &&
  6909. pendingNode.elm._leaveCb
  6910. ) {
  6911. pendingNode.elm._leaveCb();
  6912. }
  6913. enterHook && enterHook(el, cb);
  6914. });
  6915. }
  6916. // start enter transition
  6917. beforeEnterHook && beforeEnterHook(el);
  6918. if (expectsCSS) {
  6919. addTransitionClass(el, startClass);
  6920. addTransitionClass(el, activeClass);
  6921. nextFrame(function () {
  6922. removeTransitionClass(el, startClass);
  6923. if (!cb.cancelled) {
  6924. addTransitionClass(el, toClass);
  6925. if (!userWantsControl) {
  6926. if (isValidDuration(explicitEnterDuration)) {
  6927. setTimeout(cb, explicitEnterDuration);
  6928. } else {
  6929. whenTransitionEnds(el, type, cb);
  6930. }
  6931. }
  6932. }
  6933. });
  6934. }
  6935. if (vnode.data.show) {
  6936. toggleDisplay && toggleDisplay();
  6937. enterHook && enterHook(el, cb);
  6938. }
  6939. if (!expectsCSS && !userWantsControl) {
  6940. cb();
  6941. }
  6942. }
  6943. function leave (vnode, rm) {
  6944. var el = vnode.elm;
  6945. // call enter callback now
  6946. if (isDef(el._enterCb)) {
  6947. el._enterCb.cancelled = true;
  6948. el._enterCb();
  6949. }
  6950. var data = resolveTransition(vnode.data.transition);
  6951. if (isUndef(data) || el.nodeType !== 1) {
  6952. return rm()
  6953. }
  6954. /* istanbul ignore if */
  6955. if (isDef(el._leaveCb)) {
  6956. return
  6957. }
  6958. var css = data.css;
  6959. var type = data.type;
  6960. var leaveClass = data.leaveClass;
  6961. var leaveToClass = data.leaveToClass;
  6962. var leaveActiveClass = data.leaveActiveClass;
  6963. var beforeLeave = data.beforeLeave;
  6964. var leave = data.leave;
  6965. var afterLeave = data.afterLeave;
  6966. var leaveCancelled = data.leaveCancelled;
  6967. var delayLeave = data.delayLeave;
  6968. var duration = data.duration;
  6969. var expectsCSS = css !== false && !isIE9;
  6970. var userWantsControl = getHookArgumentsLength(leave);
  6971. var explicitLeaveDuration = toNumber(
  6972. isObject(duration)
  6973. ? duration.leave
  6974. : duration
  6975. );
  6976. if (process.env.NODE_ENV !== 'production' && isDef(explicitLeaveDuration)) {
  6977. checkDuration(explicitLeaveDuration, 'leave', vnode);
  6978. }
  6979. var cb = el._leaveCb = once(function () {
  6980. if (el.parentNode && el.parentNode._pending) {
  6981. el.parentNode._pending[vnode.key] = null;
  6982. }
  6983. if (expectsCSS) {
  6984. removeTransitionClass(el, leaveToClass);
  6985. removeTransitionClass(el, leaveActiveClass);
  6986. }
  6987. if (cb.cancelled) {
  6988. if (expectsCSS) {
  6989. removeTransitionClass(el, leaveClass);
  6990. }
  6991. leaveCancelled && leaveCancelled(el);
  6992. } else {
  6993. rm();
  6994. afterLeave && afterLeave(el);
  6995. }
  6996. el._leaveCb = null;
  6997. });
  6998. if (delayLeave) {
  6999. delayLeave(performLeave);
  7000. } else {
  7001. performLeave();
  7002. }
  7003. function performLeave () {
  7004. // the delayed leave may have already been cancelled
  7005. if (cb.cancelled) {
  7006. return
  7007. }
  7008. // record leaving element
  7009. if (!vnode.data.show && el.parentNode) {
  7010. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  7011. }
  7012. beforeLeave && beforeLeave(el);
  7013. if (expectsCSS) {
  7014. addTransitionClass(el, leaveClass);
  7015. addTransitionClass(el, leaveActiveClass);
  7016. nextFrame(function () {
  7017. removeTransitionClass(el, leaveClass);
  7018. if (!cb.cancelled) {
  7019. addTransitionClass(el, leaveToClass);
  7020. if (!userWantsControl) {
  7021. if (isValidDuration(explicitLeaveDuration)) {
  7022. setTimeout(cb, explicitLeaveDuration);
  7023. } else {
  7024. whenTransitionEnds(el, type, cb);
  7025. }
  7026. }
  7027. }
  7028. });
  7029. }
  7030. leave && leave(el, cb);
  7031. if (!expectsCSS && !userWantsControl) {
  7032. cb();
  7033. }
  7034. }
  7035. }
  7036. // only used in dev mode
  7037. function checkDuration (val, name, vnode) {
  7038. if (typeof val !== 'number') {
  7039. warn(
  7040. "<transition> explicit " + name + " duration is not a valid number - " +
  7041. "got " + (JSON.stringify(val)) + ".",
  7042. vnode.context
  7043. );
  7044. } else if (isNaN(val)) {
  7045. warn(
  7046. "<transition> explicit " + name + " duration is NaN - " +
  7047. 'the duration expression might be incorrect.',
  7048. vnode.context
  7049. );
  7050. }
  7051. }
  7052. function isValidDuration (val) {
  7053. return typeof val === 'number' && !isNaN(val)
  7054. }
  7055. /**
  7056. * Normalize a transition hook's argument length. The hook may be:
  7057. * - a merged hook (invoker) with the original in .fns
  7058. * - a wrapped component method (check ._length)
  7059. * - a plain function (.length)
  7060. */
  7061. function getHookArgumentsLength (fn) {
  7062. if (isUndef(fn)) {
  7063. return false
  7064. }
  7065. var invokerFns = fn.fns;
  7066. if (isDef(invokerFns)) {
  7067. // invoker
  7068. return getHookArgumentsLength(
  7069. Array.isArray(invokerFns)
  7070. ? invokerFns[0]
  7071. : invokerFns
  7072. )
  7073. } else {
  7074. return (fn._length || fn.length) > 1
  7075. }
  7076. }
  7077. function _enter (_, vnode) {
  7078. if (vnode.data.show !== true) {
  7079. enter(vnode);
  7080. }
  7081. }
  7082. var transition = inBrowser ? {
  7083. create: _enter,
  7084. activate: _enter,
  7085. remove: function remove$$1 (vnode, rm) {
  7086. /* istanbul ignore else */
  7087. if (vnode.data.show !== true) {
  7088. leave(vnode, rm);
  7089. } else {
  7090. rm();
  7091. }
  7092. }
  7093. } : {};
  7094. var platformModules = [
  7095. attrs,
  7096. klass,
  7097. events,
  7098. domProps,
  7099. style,
  7100. transition
  7101. ];
  7102. /* */
  7103. // the directive module should be applied last, after all
  7104. // built-in modules have been applied.
  7105. var modules = platformModules.concat(baseModules);
  7106. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  7107. /**
  7108. * Not type checking this file because flow doesn't like attaching
  7109. * properties to Elements.
  7110. */
  7111. /* istanbul ignore if */
  7112. if (isIE9) {
  7113. // http://www.matts411.com/post/internet-explorer-9-oninput/
  7114. document.addEventListener('selectionchange', function () {
  7115. var el = document.activeElement;
  7116. if (el && el.vmodel) {
  7117. trigger(el, 'input');
  7118. }
  7119. });
  7120. }
  7121. var directive = {
  7122. inserted: function inserted (el, binding, vnode, oldVnode) {
  7123. if (vnode.tag === 'select') {
  7124. // #6903
  7125. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  7126. mergeVNodeHook(vnode, 'postpatch', function () {
  7127. directive.componentUpdated(el, binding, vnode);
  7128. });
  7129. } else {
  7130. setSelected(el, binding, vnode.context);
  7131. }
  7132. el._vOptions = [].map.call(el.options, getValue);
  7133. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  7134. el._vModifiers = binding.modifiers;
  7135. if (!binding.modifiers.lazy) {
  7136. el.addEventListener('compositionstart', onCompositionStart);
  7137. el.addEventListener('compositionend', onCompositionEnd);
  7138. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  7139. // switching focus before confirming composition choice
  7140. // this also fixes the issue where some browsers e.g. iOS Chrome
  7141. // fires "change" instead of "input" on autocomplete.
  7142. el.addEventListener('change', onCompositionEnd);
  7143. /* istanbul ignore if */
  7144. if (isIE9) {
  7145. el.vmodel = true;
  7146. }
  7147. }
  7148. }
  7149. },
  7150. componentUpdated: function componentUpdated (el, binding, vnode) {
  7151. if (vnode.tag === 'select') {
  7152. setSelected(el, binding, vnode.context);
  7153. // in case the options rendered by v-for have changed,
  7154. // it's possible that the value is out-of-sync with the rendered options.
  7155. // detect such cases and filter out values that no longer has a matching
  7156. // option in the DOM.
  7157. var prevOptions = el._vOptions;
  7158. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  7159. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  7160. // trigger change event if
  7161. // no matching option found for at least one value
  7162. var needReset = el.multiple
  7163. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  7164. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  7165. if (needReset) {
  7166. trigger(el, 'change');
  7167. }
  7168. }
  7169. }
  7170. }
  7171. };
  7172. function setSelected (el, binding, vm) {
  7173. actuallySetSelected(el, binding, vm);
  7174. /* istanbul ignore if */
  7175. if (isIE || isEdge) {
  7176. setTimeout(function () {
  7177. actuallySetSelected(el, binding, vm);
  7178. }, 0);
  7179. }
  7180. }
  7181. function actuallySetSelected (el, binding, vm) {
  7182. var value = binding.value;
  7183. var isMultiple = el.multiple;
  7184. if (isMultiple && !Array.isArray(value)) {
  7185. process.env.NODE_ENV !== 'production' && warn(
  7186. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  7187. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  7188. vm
  7189. );
  7190. return
  7191. }
  7192. var selected, option;
  7193. for (var i = 0, l = el.options.length; i < l; i++) {
  7194. option = el.options[i];
  7195. if (isMultiple) {
  7196. selected = looseIndexOf(value, getValue(option)) > -1;
  7197. if (option.selected !== selected) {
  7198. option.selected = selected;
  7199. }
  7200. } else {
  7201. if (looseEqual(getValue(option), value)) {
  7202. if (el.selectedIndex !== i) {
  7203. el.selectedIndex = i;
  7204. }
  7205. return
  7206. }
  7207. }
  7208. }
  7209. if (!isMultiple) {
  7210. el.selectedIndex = -1;
  7211. }
  7212. }
  7213. function hasNoMatchingOption (value, options) {
  7214. return options.every(function (o) { return !looseEqual(o, value); })
  7215. }
  7216. function getValue (option) {
  7217. return '_value' in option
  7218. ? option._value
  7219. : option.value
  7220. }
  7221. function onCompositionStart (e) {
  7222. e.target.composing = true;
  7223. }
  7224. function onCompositionEnd (e) {
  7225. // prevent triggering an input event for no reason
  7226. if (!e.target.composing) { return }
  7227. e.target.composing = false;
  7228. trigger(e.target, 'input');
  7229. }
  7230. function trigger (el, type) {
  7231. var e = document.createEvent('HTMLEvents');
  7232. e.initEvent(type, true, true);
  7233. el.dispatchEvent(e);
  7234. }
  7235. /* */
  7236. // recursively search for possible transition defined inside the component root
  7237. function locateNode (vnode) {
  7238. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  7239. ? locateNode(vnode.componentInstance._vnode)
  7240. : vnode
  7241. }
  7242. var show = {
  7243. bind: function bind (el, ref, vnode) {
  7244. var value = ref.value;
  7245. vnode = locateNode(vnode);
  7246. var transition$$1 = vnode.data && vnode.data.transition;
  7247. var originalDisplay = el.__vOriginalDisplay =
  7248. el.style.display === 'none' ? '' : el.style.display;
  7249. if (value && transition$$1) {
  7250. vnode.data.show = true;
  7251. enter(vnode, function () {
  7252. el.style.display = originalDisplay;
  7253. });
  7254. } else {
  7255. el.style.display = value ? originalDisplay : 'none';
  7256. }
  7257. },
  7258. update: function update (el, ref, vnode) {
  7259. var value = ref.value;
  7260. var oldValue = ref.oldValue;
  7261. /* istanbul ignore if */
  7262. if (!value === !oldValue) { return }
  7263. vnode = locateNode(vnode);
  7264. var transition$$1 = vnode.data && vnode.data.transition;
  7265. if (transition$$1) {
  7266. vnode.data.show = true;
  7267. if (value) {
  7268. enter(vnode, function () {
  7269. el.style.display = el.__vOriginalDisplay;
  7270. });
  7271. } else {
  7272. leave(vnode, function () {
  7273. el.style.display = 'none';
  7274. });
  7275. }
  7276. } else {
  7277. el.style.display = value ? el.__vOriginalDisplay : 'none';
  7278. }
  7279. },
  7280. unbind: function unbind (
  7281. el,
  7282. binding,
  7283. vnode,
  7284. oldVnode,
  7285. isDestroy
  7286. ) {
  7287. if (!isDestroy) {
  7288. el.style.display = el.__vOriginalDisplay;
  7289. }
  7290. }
  7291. };
  7292. var platformDirectives = {
  7293. model: directive,
  7294. show: show
  7295. };
  7296. /* */
  7297. var transitionProps = {
  7298. name: String,
  7299. appear: Boolean,
  7300. css: Boolean,
  7301. mode: String,
  7302. type: String,
  7303. enterClass: String,
  7304. leaveClass: String,
  7305. enterToClass: String,
  7306. leaveToClass: String,
  7307. enterActiveClass: String,
  7308. leaveActiveClass: String,
  7309. appearClass: String,
  7310. appearActiveClass: String,
  7311. appearToClass: String,
  7312. duration: [Number, String, Object]
  7313. };
  7314. // in case the child is also an abstract component, e.g. <keep-alive>
  7315. // we want to recursively retrieve the real component to be rendered
  7316. function getRealChild (vnode) {
  7317. var compOptions = vnode && vnode.componentOptions;
  7318. if (compOptions && compOptions.Ctor.options.abstract) {
  7319. return getRealChild(getFirstComponentChild(compOptions.children))
  7320. } else {
  7321. return vnode
  7322. }
  7323. }
  7324. function extractTransitionData (comp) {
  7325. var data = {};
  7326. var options = comp.$options;
  7327. // props
  7328. for (var key in options.propsData) {
  7329. data[key] = comp[key];
  7330. }
  7331. // events.
  7332. // extract listeners and pass them directly to the transition methods
  7333. var listeners = options._parentListeners;
  7334. for (var key$1 in listeners) {
  7335. data[camelize(key$1)] = listeners[key$1];
  7336. }
  7337. return data
  7338. }
  7339. function placeholder (h, rawChild) {
  7340. if (/\d-keep-alive$/.test(rawChild.tag)) {
  7341. return h('keep-alive', {
  7342. props: rawChild.componentOptions.propsData
  7343. })
  7344. }
  7345. }
  7346. function hasParentTransition (vnode) {
  7347. while ((vnode = vnode.parent)) {
  7348. if (vnode.data.transition) {
  7349. return true
  7350. }
  7351. }
  7352. }
  7353. function isSameChild (child, oldChild) {
  7354. return oldChild.key === child.key && oldChild.tag === child.tag
  7355. }
  7356. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  7357. var isVShowDirective = function (d) { return d.name === 'show'; };
  7358. var Transition = {
  7359. name: 'transition',
  7360. props: transitionProps,
  7361. abstract: true,
  7362. render: function render (h) {
  7363. var this$1 = this;
  7364. var children = this.$slots.default;
  7365. if (!children) {
  7366. return
  7367. }
  7368. // filter out text nodes (possible whitespaces)
  7369. children = children.filter(isNotTextNode);
  7370. /* istanbul ignore if */
  7371. if (!children.length) {
  7372. return
  7373. }
  7374. // warn multiple elements
  7375. if (process.env.NODE_ENV !== 'production' && children.length > 1) {
  7376. warn(
  7377. '<transition> can only be used on a single element. Use ' +
  7378. '<transition-group> for lists.',
  7379. this.$parent
  7380. );
  7381. }
  7382. var mode = this.mode;
  7383. // warn invalid mode
  7384. if (process.env.NODE_ENV !== 'production' &&
  7385. mode && mode !== 'in-out' && mode !== 'out-in'
  7386. ) {
  7387. warn(
  7388. 'invalid <transition> mode: ' + mode,
  7389. this.$parent
  7390. );
  7391. }
  7392. var rawChild = children[0];
  7393. // if this is a component root node and the component's
  7394. // parent container node also has transition, skip.
  7395. if (hasParentTransition(this.$vnode)) {
  7396. return rawChild
  7397. }
  7398. // apply transition data to child
  7399. // use getRealChild() to ignore abstract components e.g. keep-alive
  7400. var child = getRealChild(rawChild);
  7401. /* istanbul ignore if */
  7402. if (!child) {
  7403. return rawChild
  7404. }
  7405. if (this._leaving) {
  7406. return placeholder(h, rawChild)
  7407. }
  7408. // ensure a key that is unique to the vnode type and to this transition
  7409. // component instance. This key will be used to remove pending leaving nodes
  7410. // during entering.
  7411. var id = "__transition-" + (this._uid) + "-";
  7412. child.key = child.key == null
  7413. ? child.isComment
  7414. ? id + 'comment'
  7415. : id + child.tag
  7416. : isPrimitive(child.key)
  7417. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  7418. : child.key;
  7419. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  7420. var oldRawChild = this._vnode;
  7421. var oldChild = getRealChild(oldRawChild);
  7422. // mark v-show
  7423. // so that the transition module can hand over the control to the directive
  7424. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  7425. child.data.show = true;
  7426. }
  7427. if (
  7428. oldChild &&
  7429. oldChild.data &&
  7430. !isSameChild(child, oldChild) &&
  7431. !isAsyncPlaceholder(oldChild) &&
  7432. // #6687 component root is a comment node
  7433. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  7434. ) {
  7435. // replace old child transition data with fresh one
  7436. // important for dynamic transitions!
  7437. var oldData = oldChild.data.transition = extend({}, data);
  7438. // handle transition mode
  7439. if (mode === 'out-in') {
  7440. // return placeholder node and queue update when leave finishes
  7441. this._leaving = true;
  7442. mergeVNodeHook(oldData, 'afterLeave', function () {
  7443. this$1._leaving = false;
  7444. this$1.$forceUpdate();
  7445. });
  7446. return placeholder(h, rawChild)
  7447. } else if (mode === 'in-out') {
  7448. if (isAsyncPlaceholder(child)) {
  7449. return oldRawChild
  7450. }
  7451. var delayedLeave;
  7452. var performLeave = function () { delayedLeave(); };
  7453. mergeVNodeHook(data, 'afterEnter', performLeave);
  7454. mergeVNodeHook(data, 'enterCancelled', performLeave);
  7455. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  7456. }
  7457. }
  7458. return rawChild
  7459. }
  7460. };
  7461. /* */
  7462. var props = extend({
  7463. tag: String,
  7464. moveClass: String
  7465. }, transitionProps);
  7466. delete props.mode;
  7467. var TransitionGroup = {
  7468. props: props,
  7469. beforeMount: function beforeMount () {
  7470. var this$1 = this;
  7471. var update = this._update;
  7472. this._update = function (vnode, hydrating) {
  7473. var restoreActiveInstance = setActiveInstance(this$1);
  7474. // force removing pass
  7475. this$1.__patch__(
  7476. this$1._vnode,
  7477. this$1.kept,
  7478. false, // hydrating
  7479. true // removeOnly (!important, avoids unnecessary moves)
  7480. );
  7481. this$1._vnode = this$1.kept;
  7482. restoreActiveInstance();
  7483. update.call(this$1, vnode, hydrating);
  7484. };
  7485. },
  7486. render: function render (h) {
  7487. var tag = this.tag || this.$vnode.data.tag || 'span';
  7488. var map = Object.create(null);
  7489. var prevChildren = this.prevChildren = this.children;
  7490. var rawChildren = this.$slots.default || [];
  7491. var children = this.children = [];
  7492. var transitionData = extractTransitionData(this);
  7493. for (var i = 0; i < rawChildren.length; i++) {
  7494. var c = rawChildren[i];
  7495. if (c.tag) {
  7496. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  7497. children.push(c);
  7498. map[c.key] = c
  7499. ;(c.data || (c.data = {})).transition = transitionData;
  7500. } else if (process.env.NODE_ENV !== 'production') {
  7501. var opts = c.componentOptions;
  7502. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  7503. warn(("<transition-group> children must be keyed: <" + name + ">"));
  7504. }
  7505. }
  7506. }
  7507. if (prevChildren) {
  7508. var kept = [];
  7509. var removed = [];
  7510. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  7511. var c$1 = prevChildren[i$1];
  7512. c$1.data.transition = transitionData;
  7513. c$1.data.pos = c$1.elm.getBoundingClientRect();
  7514. if (map[c$1.key]) {
  7515. kept.push(c$1);
  7516. } else {
  7517. removed.push(c$1);
  7518. }
  7519. }
  7520. this.kept = h(tag, null, kept);
  7521. this.removed = removed;
  7522. }
  7523. return h(tag, null, children)
  7524. },
  7525. updated: function updated () {
  7526. var children = this.prevChildren;
  7527. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  7528. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  7529. return
  7530. }
  7531. // we divide the work into three loops to avoid mixing DOM reads and writes
  7532. // in each iteration - which helps prevent layout thrashing.
  7533. children.forEach(callPendingCbs);
  7534. children.forEach(recordPosition);
  7535. children.forEach(applyTranslation);
  7536. // force reflow to put everything in position
  7537. // assign to this to avoid being removed in tree-shaking
  7538. // $flow-disable-line
  7539. this._reflow = document.body.offsetHeight;
  7540. children.forEach(function (c) {
  7541. if (c.data.moved) {
  7542. var el = c.elm;
  7543. var s = el.style;
  7544. addTransitionClass(el, moveClass);
  7545. s.transform = s.WebkitTransform = s.transitionDuration = '';
  7546. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  7547. if (e && e.target !== el) {
  7548. return
  7549. }
  7550. if (!e || /transform$/.test(e.propertyName)) {
  7551. el.removeEventListener(transitionEndEvent, cb);
  7552. el._moveCb = null;
  7553. removeTransitionClass(el, moveClass);
  7554. }
  7555. });
  7556. }
  7557. });
  7558. },
  7559. methods: {
  7560. hasMove: function hasMove (el, moveClass) {
  7561. /* istanbul ignore if */
  7562. if (!hasTransition) {
  7563. return false
  7564. }
  7565. /* istanbul ignore if */
  7566. if (this._hasMove) {
  7567. return this._hasMove
  7568. }
  7569. // Detect whether an element with the move class applied has
  7570. // CSS transitions. Since the element may be inside an entering
  7571. // transition at this very moment, we make a clone of it and remove
  7572. // all other transition classes applied to ensure only the move class
  7573. // is applied.
  7574. var clone = el.cloneNode();
  7575. if (el._transitionClasses) {
  7576. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  7577. }
  7578. addClass(clone, moveClass);
  7579. clone.style.display = 'none';
  7580. this.$el.appendChild(clone);
  7581. var info = getTransitionInfo(clone);
  7582. this.$el.removeChild(clone);
  7583. return (this._hasMove = info.hasTransform)
  7584. }
  7585. }
  7586. };
  7587. function callPendingCbs (c) {
  7588. /* istanbul ignore if */
  7589. if (c.elm._moveCb) {
  7590. c.elm._moveCb();
  7591. }
  7592. /* istanbul ignore if */
  7593. if (c.elm._enterCb) {
  7594. c.elm._enterCb();
  7595. }
  7596. }
  7597. function recordPosition (c) {
  7598. c.data.newPos = c.elm.getBoundingClientRect();
  7599. }
  7600. function applyTranslation (c) {
  7601. var oldPos = c.data.pos;
  7602. var newPos = c.data.newPos;
  7603. var dx = oldPos.left - newPos.left;
  7604. var dy = oldPos.top - newPos.top;
  7605. if (dx || dy) {
  7606. c.data.moved = true;
  7607. var s = c.elm.style;
  7608. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  7609. s.transitionDuration = '0s';
  7610. }
  7611. }
  7612. var platformComponents = {
  7613. Transition: Transition,
  7614. TransitionGroup: TransitionGroup
  7615. };
  7616. /* */
  7617. // install platform specific utils
  7618. Vue.config.mustUseProp = mustUseProp;
  7619. Vue.config.isReservedTag = isReservedTag;
  7620. Vue.config.isReservedAttr = isReservedAttr;
  7621. Vue.config.getTagNamespace = getTagNamespace;
  7622. Vue.config.isUnknownElement = isUnknownElement;
  7623. // install platform runtime directives & components
  7624. extend(Vue.options.directives, platformDirectives);
  7625. extend(Vue.options.components, platformComponents);
  7626. // install platform patch function
  7627. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  7628. // public mount method
  7629. Vue.prototype.$mount = function (
  7630. el,
  7631. hydrating
  7632. ) {
  7633. el = el && inBrowser ? query(el) : undefined;
  7634. return mountComponent(this, el, hydrating)
  7635. };
  7636. // devtools global hook
  7637. /* istanbul ignore next */
  7638. if (inBrowser) {
  7639. setTimeout(function () {
  7640. if (config.devtools) {
  7641. if (devtools) {
  7642. devtools.emit('init', Vue);
  7643. } else if (
  7644. process.env.NODE_ENV !== 'production' &&
  7645. process.env.NODE_ENV !== 'test'
  7646. ) {
  7647. console[console.info ? 'info' : 'log'](
  7648. 'Download the Vue Devtools extension for a better development experience:\n' +
  7649. 'https://github.com/vuejs/vue-devtools'
  7650. );
  7651. }
  7652. }
  7653. if (process.env.NODE_ENV !== 'production' &&
  7654. process.env.NODE_ENV !== 'test' &&
  7655. config.productionTip !== false &&
  7656. typeof console !== 'undefined'
  7657. ) {
  7658. console[console.info ? 'info' : 'log'](
  7659. "You are running Vue in development mode.\n" +
  7660. "Make sure to turn on production mode when deploying for production.\n" +
  7661. "See more tips at https://vuejs.org/guide/deployment.html"
  7662. );
  7663. }
  7664. }, 0);
  7665. }
  7666. /* */
  7667. export default Vue;