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.

12008 lines
314 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. 'use strict';
  7. /* */
  8. var emptyObject = Object.freeze({});
  9. // These helpers produce better VM code in JS engines due to their
  10. // explicitness and function inlining.
  11. function isUndef (v) {
  12. return v === undefined || v === null
  13. }
  14. function isDef (v) {
  15. return v !== undefined && v !== null
  16. }
  17. function isTrue (v) {
  18. return v === true
  19. }
  20. function isFalse (v) {
  21. return v === false
  22. }
  23. /**
  24. * Check if value is primitive.
  25. */
  26. function isPrimitive (value) {
  27. return (
  28. typeof value === 'string' ||
  29. typeof value === 'number' ||
  30. // $flow-disable-line
  31. typeof value === 'symbol' ||
  32. typeof value === 'boolean'
  33. )
  34. }
  35. /**
  36. * Quick object check - this is primarily used to tell
  37. * Objects from primitive values when we know the value
  38. * is a JSON-compliant type.
  39. */
  40. function isObject (obj) {
  41. return obj !== null && typeof obj === 'object'
  42. }
  43. /**
  44. * Get the raw type string of a value, e.g., [object Object].
  45. */
  46. var _toString = Object.prototype.toString;
  47. function toRawType (value) {
  48. return _toString.call(value).slice(8, -1)
  49. }
  50. /**
  51. * Strict object type check. Only returns true
  52. * for plain JavaScript objects.
  53. */
  54. function isPlainObject (obj) {
  55. return _toString.call(obj) === '[object Object]'
  56. }
  57. function isRegExp (v) {
  58. return _toString.call(v) === '[object RegExp]'
  59. }
  60. /**
  61. * Check if val is a valid array index.
  62. */
  63. function isValidArrayIndex (val) {
  64. var n = parseFloat(String(val));
  65. return n >= 0 && Math.floor(n) === n && isFinite(val)
  66. }
  67. function isPromise (val) {
  68. return (
  69. isDef(val) &&
  70. typeof val.then === 'function' &&
  71. typeof val.catch === 'function'
  72. )
  73. }
  74. /**
  75. * Convert a value to a string that is actually rendered.
  76. */
  77. function toString (val) {
  78. return val == null
  79. ? ''
  80. : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString)
  81. ? JSON.stringify(val, null, 2)
  82. : String(val)
  83. }
  84. /**
  85. * Convert an input value to a number for persistence.
  86. * If the conversion fails, return original string.
  87. */
  88. function toNumber (val) {
  89. var n = parseFloat(val);
  90. return isNaN(n) ? val : n
  91. }
  92. /**
  93. * Make a map and return a function for checking if a key
  94. * is in that map.
  95. */
  96. function makeMap (
  97. str,
  98. expectsLowerCase
  99. ) {
  100. var map = Object.create(null);
  101. var list = str.split(',');
  102. for (var i = 0; i < list.length; i++) {
  103. map[list[i]] = true;
  104. }
  105. return expectsLowerCase
  106. ? function (val) { return map[val.toLowerCase()]; }
  107. : function (val) { return map[val]; }
  108. }
  109. /**
  110. * Check if a tag is a built-in tag.
  111. */
  112. var isBuiltInTag = makeMap('slot,component', true);
  113. /**
  114. * Check if an attribute is a reserved attribute.
  115. */
  116. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  117. /**
  118. * Remove an item from an array.
  119. */
  120. function remove (arr, item) {
  121. if (arr.length) {
  122. var index = arr.indexOf(item);
  123. if (index > -1) {
  124. return arr.splice(index, 1)
  125. }
  126. }
  127. }
  128. /**
  129. * Check whether an object has the property.
  130. */
  131. var hasOwnProperty = Object.prototype.hasOwnProperty;
  132. function hasOwn (obj, key) {
  133. return hasOwnProperty.call(obj, key)
  134. }
  135. /**
  136. * Create a cached version of a pure function.
  137. */
  138. function cached (fn) {
  139. var cache = Object.create(null);
  140. return (function cachedFn (str) {
  141. var hit = cache[str];
  142. return hit || (cache[str] = fn(str))
  143. })
  144. }
  145. /**
  146. * Camelize a hyphen-delimited string.
  147. */
  148. var camelizeRE = /-(\w)/g;
  149. var camelize = cached(function (str) {
  150. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  151. });
  152. /**
  153. * Capitalize a string.
  154. */
  155. var capitalize = cached(function (str) {
  156. return str.charAt(0).toUpperCase() + str.slice(1)
  157. });
  158. /**
  159. * Hyphenate a camelCase string.
  160. */
  161. var hyphenateRE = /\B([A-Z])/g;
  162. var hyphenate = cached(function (str) {
  163. return str.replace(hyphenateRE, '-$1').toLowerCase()
  164. });
  165. /**
  166. * Simple bind polyfill for environments that do not support it,
  167. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  168. * since native bind is now performant enough in most browsers.
  169. * But removing it would mean breaking code that was able to run in
  170. * PhantomJS 1.x, so this must be kept for backward compatibility.
  171. */
  172. /* istanbul ignore next */
  173. function polyfillBind (fn, ctx) {
  174. function boundFn (a) {
  175. var l = arguments.length;
  176. return l
  177. ? l > 1
  178. ? fn.apply(ctx, arguments)
  179. : fn.call(ctx, a)
  180. : fn.call(ctx)
  181. }
  182. boundFn._length = fn.length;
  183. return boundFn
  184. }
  185. function nativeBind (fn, ctx) {
  186. return fn.bind(ctx)
  187. }
  188. var bind = Function.prototype.bind
  189. ? nativeBind
  190. : polyfillBind;
  191. /**
  192. * Convert an Array-like object to a real Array.
  193. */
  194. function toArray (list, start) {
  195. start = start || 0;
  196. var i = list.length - start;
  197. var ret = new Array(i);
  198. while (i--) {
  199. ret[i] = list[i + start];
  200. }
  201. return ret
  202. }
  203. /**
  204. * Mix properties into target object.
  205. */
  206. function extend (to, _from) {
  207. for (var key in _from) {
  208. to[key] = _from[key];
  209. }
  210. return to
  211. }
  212. /**
  213. * Merge an Array of Objects into a single Object.
  214. */
  215. function toObject (arr) {
  216. var res = {};
  217. for (var i = 0; i < arr.length; i++) {
  218. if (arr[i]) {
  219. extend(res, arr[i]);
  220. }
  221. }
  222. return res
  223. }
  224. /* eslint-disable no-unused-vars */
  225. /**
  226. * Perform no operation.
  227. * Stubbing args to make Flow happy without leaving useless transpiled code
  228. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  229. */
  230. function noop (a, b, c) {}
  231. /**
  232. * Always return false.
  233. */
  234. var no = function (a, b, c) { return false; };
  235. /* eslint-enable no-unused-vars */
  236. /**
  237. * Return the same value.
  238. */
  239. var identity = function (_) { return _; };
  240. /**
  241. * Generate a string containing static keys from compiler modules.
  242. */
  243. function genStaticKeys (modules) {
  244. return modules.reduce(function (keys, m) {
  245. return keys.concat(m.staticKeys || [])
  246. }, []).join(',')
  247. }
  248. /**
  249. * Check if two values are loosely equal - that is,
  250. * if they are plain objects, do they have the same shape?
  251. */
  252. function looseEqual (a, b) {
  253. if (a === b) { return true }
  254. var isObjectA = isObject(a);
  255. var isObjectB = isObject(b);
  256. if (isObjectA && isObjectB) {
  257. try {
  258. var isArrayA = Array.isArray(a);
  259. var isArrayB = Array.isArray(b);
  260. if (isArrayA && isArrayB) {
  261. return a.length === b.length && a.every(function (e, i) {
  262. return looseEqual(e, b[i])
  263. })
  264. } else if (a instanceof Date && b instanceof Date) {
  265. return a.getTime() === b.getTime()
  266. } else if (!isArrayA && !isArrayB) {
  267. var keysA = Object.keys(a);
  268. var keysB = Object.keys(b);
  269. return keysA.length === keysB.length && keysA.every(function (key) {
  270. return looseEqual(a[key], b[key])
  271. })
  272. } else {
  273. /* istanbul ignore next */
  274. return false
  275. }
  276. } catch (e) {
  277. /* istanbul ignore next */
  278. return false
  279. }
  280. } else if (!isObjectA && !isObjectB) {
  281. return String(a) === String(b)
  282. } else {
  283. return false
  284. }
  285. }
  286. /**
  287. * Return the first index at which a loosely equal value can be
  288. * found in the array (if value is a plain object, the array must
  289. * contain an object of the same shape), or -1 if it is not present.
  290. */
  291. function looseIndexOf (arr, val) {
  292. for (var i = 0; i < arr.length; i++) {
  293. if (looseEqual(arr[i], val)) { return i }
  294. }
  295. return -1
  296. }
  297. /**
  298. * Ensure a function is called only once.
  299. */
  300. function once (fn) {
  301. var called = false;
  302. return function () {
  303. if (!called) {
  304. called = true;
  305. fn.apply(this, arguments);
  306. }
  307. }
  308. }
  309. var SSR_ATTR = 'data-server-rendered';
  310. var ASSET_TYPES = [
  311. 'component',
  312. 'directive',
  313. 'filter'
  314. ];
  315. var LIFECYCLE_HOOKS = [
  316. 'beforeCreate',
  317. 'created',
  318. 'beforeMount',
  319. 'mounted',
  320. 'beforeUpdate',
  321. 'updated',
  322. 'beforeDestroy',
  323. 'destroyed',
  324. 'activated',
  325. 'deactivated',
  326. 'errorCaptured',
  327. 'serverPrefetch'
  328. ];
  329. /* */
  330. var config = ({
  331. /**
  332. * Option merge strategies (used in core/util/options)
  333. */
  334. // $flow-disable-line
  335. optionMergeStrategies: Object.create(null),
  336. /**
  337. * Whether to suppress warnings.
  338. */
  339. silent: false,
  340. /**
  341. * Show production mode tip message on boot?
  342. */
  343. productionTip: "development" !== 'production',
  344. /**
  345. * Whether to enable devtools
  346. */
  347. devtools: "development" !== 'production',
  348. /**
  349. * Whether to record perf
  350. */
  351. performance: false,
  352. /**
  353. * Error handler for watcher errors
  354. */
  355. errorHandler: null,
  356. /**
  357. * Warn handler for watcher warns
  358. */
  359. warnHandler: null,
  360. /**
  361. * Ignore certain custom elements
  362. */
  363. ignoredElements: [],
  364. /**
  365. * Custom user key aliases for v-on
  366. */
  367. // $flow-disable-line
  368. keyCodes: Object.create(null),
  369. /**
  370. * Check if a tag is reserved so that it cannot be registered as a
  371. * component. This is platform-dependent and may be overwritten.
  372. */
  373. isReservedTag: no,
  374. /**
  375. * Check if an attribute is reserved so that it cannot be used as a component
  376. * prop. This is platform-dependent and may be overwritten.
  377. */
  378. isReservedAttr: no,
  379. /**
  380. * Check if a tag is an unknown element.
  381. * Platform-dependent.
  382. */
  383. isUnknownElement: no,
  384. /**
  385. * Get the namespace of an element
  386. */
  387. getTagNamespace: noop,
  388. /**
  389. * Parse the real tag name for the specific platform.
  390. */
  391. parsePlatformTagName: identity,
  392. /**
  393. * Check if an attribute must be bound using property, e.g. value
  394. * Platform-dependent.
  395. */
  396. mustUseProp: no,
  397. /**
  398. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  399. * This will significantly reduce performance if set to false.
  400. */
  401. async: true,
  402. /**
  403. * Exposed for legacy reasons
  404. */
  405. _lifecycleHooks: LIFECYCLE_HOOKS
  406. });
  407. /* */
  408. /**
  409. * unicode letters used for parsing html tags, component names and property paths.
  410. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
  411. * skipping \u10000-\uEFFFF due to it freezing up PhantomJS
  412. */
  413. 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/;
  414. /**
  415. * Check if a string starts with $ or _
  416. */
  417. function isReserved (str) {
  418. var c = (str + '').charCodeAt(0);
  419. return c === 0x24 || c === 0x5F
  420. }
  421. /**
  422. * Define a property.
  423. */
  424. function def (obj, key, val, enumerable) {
  425. Object.defineProperty(obj, key, {
  426. value: val,
  427. enumerable: !!enumerable,
  428. writable: true,
  429. configurable: true
  430. });
  431. }
  432. /**
  433. * Parse simple path.
  434. */
  435. var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]"));
  436. function parsePath (path) {
  437. if (bailRE.test(path)) {
  438. return
  439. }
  440. var segments = path.split('.');
  441. return function (obj) {
  442. for (var i = 0; i < segments.length; i++) {
  443. if (!obj) { return }
  444. obj = obj[segments[i]];
  445. }
  446. return obj
  447. }
  448. }
  449. /* */
  450. // can we use __proto__?
  451. var hasProto = '__proto__' in {};
  452. // Browser environment sniffing
  453. var inBrowser = typeof window !== 'undefined';
  454. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  455. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  456. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  457. var isIE = UA && /msie|trident/.test(UA);
  458. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  459. var isEdge = UA && UA.indexOf('edge/') > 0;
  460. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  461. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  462. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  463. var isPhantomJS = UA && /phantomjs/.test(UA);
  464. var isFF = UA && UA.match(/firefox\/(\d+)/);
  465. // Firefox has a "watch" function on Object.prototype...
  466. var nativeWatch = ({}).watch;
  467. var supportsPassive = false;
  468. if (inBrowser) {
  469. try {
  470. var opts = {};
  471. Object.defineProperty(opts, 'passive', ({
  472. get: function get () {
  473. /* istanbul ignore next */
  474. supportsPassive = true;
  475. }
  476. })); // https://github.com/facebook/flow/issues/285
  477. window.addEventListener('test-passive', null, opts);
  478. } catch (e) {}
  479. }
  480. // this needs to be lazy-evaled because vue may be required before
  481. // vue-server-renderer can set VUE_ENV
  482. var _isServer;
  483. var isServerRendering = function () {
  484. if (_isServer === undefined) {
  485. /* istanbul ignore if */
  486. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  487. // detect presence of vue-server-renderer and avoid
  488. // Webpack shimming the process
  489. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  490. } else {
  491. _isServer = false;
  492. }
  493. }
  494. return _isServer
  495. };
  496. // detect devtools
  497. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  498. /* istanbul ignore next */
  499. function isNative (Ctor) {
  500. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  501. }
  502. var hasSymbol =
  503. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  504. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  505. var _Set;
  506. /* istanbul ignore if */ // $flow-disable-line
  507. if (typeof Set !== 'undefined' && isNative(Set)) {
  508. // use native Set when available.
  509. _Set = Set;
  510. } else {
  511. // a non-standard Set polyfill that only works with primitive keys.
  512. _Set = /*@__PURE__*/(function () {
  513. function Set () {
  514. this.set = Object.create(null);
  515. }
  516. Set.prototype.has = function has (key) {
  517. return this.set[key] === true
  518. };
  519. Set.prototype.add = function add (key) {
  520. this.set[key] = true;
  521. };
  522. Set.prototype.clear = function clear () {
  523. this.set = Object.create(null);
  524. };
  525. return Set;
  526. }());
  527. }
  528. /* */
  529. var warn = noop;
  530. var tip = noop;
  531. var generateComponentTrace = (noop); // work around flow check
  532. var formatComponentName = (noop);
  533. {
  534. var hasConsole = typeof console !== 'undefined';
  535. var classifyRE = /(?:^|[-_])(\w)/g;
  536. var classify = function (str) { return str
  537. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  538. .replace(/[-_]/g, ''); };
  539. warn = function (msg, vm) {
  540. var trace = vm ? generateComponentTrace(vm) : '';
  541. if (config.warnHandler) {
  542. config.warnHandler.call(null, msg, vm, trace);
  543. } else if (hasConsole && (!config.silent)) {
  544. console.error(("[Vue warn]: " + msg + trace));
  545. }
  546. };
  547. tip = function (msg, vm) {
  548. if (hasConsole && (!config.silent)) {
  549. console.warn("[Vue tip]: " + msg + (
  550. vm ? generateComponentTrace(vm) : ''
  551. ));
  552. }
  553. };
  554. formatComponentName = function (vm, includeFile) {
  555. if (vm.$root === vm) {
  556. return '<Root>'
  557. }
  558. var options = typeof vm === 'function' && vm.cid != null
  559. ? vm.options
  560. : vm._isVue
  561. ? vm.$options || vm.constructor.options
  562. : vm;
  563. var name = options.name || options._componentTag;
  564. var file = options.__file;
  565. if (!name && file) {
  566. var match = file.match(/([^/\\]+)\.vue$/);
  567. name = match && match[1];
  568. }
  569. return (
  570. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  571. (file && includeFile !== false ? (" at " + file) : '')
  572. )
  573. };
  574. var repeat = function (str, n) {
  575. var res = '';
  576. while (n) {
  577. if (n % 2 === 1) { res += str; }
  578. if (n > 1) { str += str; }
  579. n >>= 1;
  580. }
  581. return res
  582. };
  583. generateComponentTrace = function (vm) {
  584. if (vm._isVue && vm.$parent) {
  585. var tree = [];
  586. var currentRecursiveSequence = 0;
  587. while (vm) {
  588. if (tree.length > 0) {
  589. var last = tree[tree.length - 1];
  590. if (last.constructor === vm.constructor) {
  591. currentRecursiveSequence++;
  592. vm = vm.$parent;
  593. continue
  594. } else if (currentRecursiveSequence > 0) {
  595. tree[tree.length - 1] = [last, currentRecursiveSequence];
  596. currentRecursiveSequence = 0;
  597. }
  598. }
  599. tree.push(vm);
  600. vm = vm.$parent;
  601. }
  602. return '\n\nfound in\n\n' + tree
  603. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  604. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  605. : formatComponentName(vm))); })
  606. .join('\n')
  607. } else {
  608. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  609. }
  610. };
  611. }
  612. /* */
  613. var uid = 0;
  614. /**
  615. * A dep is an observable that can have multiple
  616. * directives subscribing to it.
  617. */
  618. var Dep = function Dep () {
  619. this.id = uid++;
  620. this.subs = [];
  621. };
  622. Dep.prototype.addSub = function addSub (sub) {
  623. this.subs.push(sub);
  624. };
  625. Dep.prototype.removeSub = function removeSub (sub) {
  626. remove(this.subs, sub);
  627. };
  628. Dep.prototype.depend = function depend () {
  629. if (Dep.target) {
  630. Dep.target.addDep(this);
  631. }
  632. };
  633. Dep.prototype.notify = function notify () {
  634. // stabilize the subscriber list first
  635. var subs = this.subs.slice();
  636. if (!config.async) {
  637. // subs aren't sorted in scheduler if not running async
  638. // we need to sort them now to make sure they fire in correct
  639. // order
  640. subs.sort(function (a, b) { return a.id - b.id; });
  641. }
  642. for (var i = 0, l = subs.length; i < l; i++) {
  643. subs[i].update();
  644. }
  645. };
  646. // The current target watcher being evaluated.
  647. // This is globally unique because only one watcher
  648. // can be evaluated at a time.
  649. Dep.target = null;
  650. var targetStack = [];
  651. function pushTarget (target) {
  652. targetStack.push(target);
  653. Dep.target = target;
  654. }
  655. function popTarget () {
  656. targetStack.pop();
  657. Dep.target = targetStack[targetStack.length - 1];
  658. }
  659. /* */
  660. var VNode = function VNode (
  661. tag,
  662. data,
  663. children,
  664. text,
  665. elm,
  666. context,
  667. componentOptions,
  668. asyncFactory
  669. ) {
  670. this.tag = tag;
  671. this.data = data;
  672. this.children = children;
  673. this.text = text;
  674. this.elm = elm;
  675. this.ns = undefined;
  676. this.context = context;
  677. this.fnContext = undefined;
  678. this.fnOptions = undefined;
  679. this.fnScopeId = undefined;
  680. this.key = data && data.key;
  681. this.componentOptions = componentOptions;
  682. this.componentInstance = undefined;
  683. this.parent = undefined;
  684. this.raw = false;
  685. this.isStatic = false;
  686. this.isRootInsert = true;
  687. this.isComment = false;
  688. this.isCloned = false;
  689. this.isOnce = false;
  690. this.asyncFactory = asyncFactory;
  691. this.asyncMeta = undefined;
  692. this.isAsyncPlaceholder = false;
  693. };
  694. var prototypeAccessors = { child: { configurable: true } };
  695. // DEPRECATED: alias for componentInstance for backwards compat.
  696. /* istanbul ignore next */
  697. prototypeAccessors.child.get = function () {
  698. return this.componentInstance
  699. };
  700. Object.defineProperties( VNode.prototype, prototypeAccessors );
  701. var createEmptyVNode = function (text) {
  702. if ( text === void 0 ) text = '';
  703. var node = new VNode();
  704. node.text = text;
  705. node.isComment = true;
  706. return node
  707. };
  708. function createTextVNode (val) {
  709. return new VNode(undefined, undefined, undefined, String(val))
  710. }
  711. // optimized shallow clone
  712. // used for static nodes and slot nodes because they may be reused across
  713. // multiple renders, cloning them avoids errors when DOM manipulations rely
  714. // on their elm reference.
  715. function cloneVNode (vnode) {
  716. var cloned = new VNode(
  717. vnode.tag,
  718. vnode.data,
  719. // #7975
  720. // clone children array to avoid mutating original in case of cloning
  721. // a child.
  722. vnode.children && vnode.children.slice(),
  723. vnode.text,
  724. vnode.elm,
  725. vnode.context,
  726. vnode.componentOptions,
  727. vnode.asyncFactory
  728. );
  729. cloned.ns = vnode.ns;
  730. cloned.isStatic = vnode.isStatic;
  731. cloned.key = vnode.key;
  732. cloned.isComment = vnode.isComment;
  733. cloned.fnContext = vnode.fnContext;
  734. cloned.fnOptions = vnode.fnOptions;
  735. cloned.fnScopeId = vnode.fnScopeId;
  736. cloned.asyncMeta = vnode.asyncMeta;
  737. cloned.isCloned = true;
  738. return cloned
  739. }
  740. /*
  741. * not type checking this file because flow doesn't play well with
  742. * dynamically accessing methods on Array prototype
  743. */
  744. var arrayProto = Array.prototype;
  745. var arrayMethods = Object.create(arrayProto);
  746. var methodsToPatch = [
  747. 'push',
  748. 'pop',
  749. 'shift',
  750. 'unshift',
  751. 'splice',
  752. 'sort',
  753. 'reverse'
  754. ];
  755. /**
  756. * Intercept mutating methods and emit events
  757. */
  758. methodsToPatch.forEach(function (method) {
  759. // cache original method
  760. var original = arrayProto[method];
  761. def(arrayMethods, method, function mutator () {
  762. var args = [], len = arguments.length;
  763. while ( len-- ) args[ len ] = arguments[ len ];
  764. var result = original.apply(this, args);
  765. var ob = this.__ob__;
  766. var inserted;
  767. switch (method) {
  768. case 'push':
  769. case 'unshift':
  770. inserted = args;
  771. break
  772. case 'splice':
  773. inserted = args.slice(2);
  774. break
  775. }
  776. if (inserted) { ob.observeArray(inserted); }
  777. // notify change
  778. ob.dep.notify();
  779. return result
  780. });
  781. });
  782. /* */
  783. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  784. /**
  785. * In some cases we may want to disable observation inside a component's
  786. * update computation.
  787. */
  788. var shouldObserve = true;
  789. function toggleObserving (value) {
  790. shouldObserve = value;
  791. }
  792. /**
  793. * Observer class that is attached to each observed
  794. * object. Once attached, the observer converts the target
  795. * object's property keys into getter/setters that
  796. * collect dependencies and dispatch updates.
  797. */
  798. var Observer = function Observer (value) {
  799. this.value = value;
  800. this.dep = new Dep();
  801. this.vmCount = 0;
  802. def(value, '__ob__', this);
  803. if (Array.isArray(value)) {
  804. if (hasProto) {
  805. protoAugment(value, arrayMethods);
  806. } else {
  807. copyAugment(value, arrayMethods, arrayKeys);
  808. }
  809. this.observeArray(value);
  810. } else {
  811. this.walk(value);
  812. }
  813. };
  814. /**
  815. * Walk through all properties and convert them into
  816. * getter/setters. This method should only be called when
  817. * value type is Object.
  818. */
  819. Observer.prototype.walk = function walk (obj) {
  820. var keys = Object.keys(obj);
  821. for (var i = 0; i < keys.length; i++) {
  822. defineReactive$$1(obj, keys[i]);
  823. }
  824. };
  825. /**
  826. * Observe a list of Array items.
  827. */
  828. Observer.prototype.observeArray = function observeArray (items) {
  829. for (var i = 0, l = items.length; i < l; i++) {
  830. observe(items[i]);
  831. }
  832. };
  833. // helpers
  834. /**
  835. * Augment a target Object or Array by intercepting
  836. * the prototype chain using __proto__
  837. */
  838. function protoAugment (target, src) {
  839. /* eslint-disable no-proto */
  840. target.__proto__ = src;
  841. /* eslint-enable no-proto */
  842. }
  843. /**
  844. * Augment a target Object or Array by defining
  845. * hidden properties.
  846. */
  847. /* istanbul ignore next */
  848. function copyAugment (target, src, keys) {
  849. for (var i = 0, l = keys.length; i < l; i++) {
  850. var key = keys[i];
  851. def(target, key, src[key]);
  852. }
  853. }
  854. /**
  855. * Attempt to create an observer instance for a value,
  856. * returns the new observer if successfully observed,
  857. * or the existing observer if the value already has one.
  858. */
  859. function observe (value, asRootData) {
  860. if (!isObject(value) || value instanceof VNode) {
  861. return
  862. }
  863. var ob;
  864. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  865. ob = value.__ob__;
  866. } else if (
  867. shouldObserve &&
  868. !isServerRendering() &&
  869. (Array.isArray(value) || isPlainObject(value)) &&
  870. Object.isExtensible(value) &&
  871. !value._isVue
  872. ) {
  873. ob = new Observer(value);
  874. }
  875. if (asRootData && ob) {
  876. ob.vmCount++;
  877. }
  878. return ob
  879. }
  880. /**
  881. * Define a reactive property on an Object.
  882. */
  883. function defineReactive$$1 (
  884. obj,
  885. key,
  886. val,
  887. customSetter,
  888. shallow
  889. ) {
  890. var dep = new Dep();
  891. var property = Object.getOwnPropertyDescriptor(obj, key);
  892. if (property && property.configurable === false) {
  893. return
  894. }
  895. // cater for pre-defined getter/setters
  896. var getter = property && property.get;
  897. var setter = property && property.set;
  898. if ((!getter || setter) && arguments.length === 2) {
  899. val = obj[key];
  900. }
  901. var childOb = !shallow && observe(val);
  902. Object.defineProperty(obj, key, {
  903. enumerable: true,
  904. configurable: true,
  905. get: function reactiveGetter () {
  906. var value = getter ? getter.call(obj) : val;
  907. if (Dep.target) {
  908. dep.depend();
  909. if (childOb) {
  910. childOb.dep.depend();
  911. if (Array.isArray(value)) {
  912. dependArray(value);
  913. }
  914. }
  915. }
  916. return value
  917. },
  918. set: function reactiveSetter (newVal) {
  919. var value = getter ? getter.call(obj) : val;
  920. /* eslint-disable no-self-compare */
  921. if (newVal === value || (newVal !== newVal && value !== value)) {
  922. return
  923. }
  924. /* eslint-enable no-self-compare */
  925. if (customSetter) {
  926. customSetter();
  927. }
  928. // #7981: for accessor properties without setter
  929. if (getter && !setter) { return }
  930. if (setter) {
  931. setter.call(obj, newVal);
  932. } else {
  933. val = newVal;
  934. }
  935. childOb = !shallow && observe(newVal);
  936. dep.notify();
  937. }
  938. });
  939. }
  940. /**
  941. * Set a property on an object. Adds the new property and
  942. * triggers change notification if the property doesn't
  943. * already exist.
  944. */
  945. function set (target, key, val) {
  946. if (isUndef(target) || isPrimitive(target)
  947. ) {
  948. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  949. }
  950. if (Array.isArray(target) && isValidArrayIndex(key)) {
  951. target.length = Math.max(target.length, key);
  952. target.splice(key, 1, val);
  953. return val
  954. }
  955. if (key in target && !(key in Object.prototype)) {
  956. target[key] = val;
  957. return val
  958. }
  959. var ob = (target).__ob__;
  960. if (target._isVue || (ob && ob.vmCount)) {
  961. warn(
  962. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  963. 'at runtime - declare it upfront in the data option.'
  964. );
  965. return val
  966. }
  967. if (!ob) {
  968. target[key] = val;
  969. return val
  970. }
  971. defineReactive$$1(ob.value, key, val);
  972. ob.dep.notify();
  973. return val
  974. }
  975. /**
  976. * Delete a property and trigger change if necessary.
  977. */
  978. function del (target, key) {
  979. if (isUndef(target) || isPrimitive(target)
  980. ) {
  981. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  982. }
  983. if (Array.isArray(target) && isValidArrayIndex(key)) {
  984. target.splice(key, 1);
  985. return
  986. }
  987. var ob = (target).__ob__;
  988. if (target._isVue || (ob && ob.vmCount)) {
  989. warn(
  990. 'Avoid deleting properties on a Vue instance or its root $data ' +
  991. '- just set it to null.'
  992. );
  993. return
  994. }
  995. if (!hasOwn(target, key)) {
  996. return
  997. }
  998. delete target[key];
  999. if (!ob) {
  1000. return
  1001. }
  1002. ob.dep.notify();
  1003. }
  1004. /**
  1005. * Collect dependencies on array elements when the array is touched, since
  1006. * we cannot intercept array element access like property getters.
  1007. */
  1008. function dependArray (value) {
  1009. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  1010. e = value[i];
  1011. e && e.__ob__ && e.__ob__.dep.depend();
  1012. if (Array.isArray(e)) {
  1013. dependArray(e);
  1014. }
  1015. }
  1016. }
  1017. /* */
  1018. /**
  1019. * Option overwriting strategies are functions that handle
  1020. * how to merge a parent option value and a child option
  1021. * value into the final value.
  1022. */
  1023. var strats = config.optionMergeStrategies;
  1024. /**
  1025. * Options with restrictions
  1026. */
  1027. {
  1028. strats.el = strats.propsData = function (parent, child, vm, key) {
  1029. if (!vm) {
  1030. warn(
  1031. "option \"" + key + "\" can only be used during instance " +
  1032. 'creation with the `new` keyword.'
  1033. );
  1034. }
  1035. return defaultStrat(parent, child)
  1036. };
  1037. }
  1038. /**
  1039. * Helper that recursively merges two data objects together.
  1040. */
  1041. function mergeData (to, from) {
  1042. if (!from) { return to }
  1043. var key, toVal, fromVal;
  1044. var keys = hasSymbol
  1045. ? Reflect.ownKeys(from)
  1046. : Object.keys(from);
  1047. for (var i = 0; i < keys.length; i++) {
  1048. key = keys[i];
  1049. // in case the object is already observed...
  1050. if (key === '__ob__') { continue }
  1051. toVal = to[key];
  1052. fromVal = from[key];
  1053. if (!hasOwn(to, key)) {
  1054. set(to, key, fromVal);
  1055. } else if (
  1056. toVal !== fromVal &&
  1057. isPlainObject(toVal) &&
  1058. isPlainObject(fromVal)
  1059. ) {
  1060. mergeData(toVal, fromVal);
  1061. }
  1062. }
  1063. return to
  1064. }
  1065. /**
  1066. * Data
  1067. */
  1068. function mergeDataOrFn (
  1069. parentVal,
  1070. childVal,
  1071. vm
  1072. ) {
  1073. if (!vm) {
  1074. // in a Vue.extend merge, both should be functions
  1075. if (!childVal) {
  1076. return parentVal
  1077. }
  1078. if (!parentVal) {
  1079. return childVal
  1080. }
  1081. // when parentVal & childVal are both present,
  1082. // we need to return a function that returns the
  1083. // merged result of both functions... no need to
  1084. // check if parentVal is a function here because
  1085. // it has to be a function to pass previous merges.
  1086. return function mergedDataFn () {
  1087. return mergeData(
  1088. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  1089. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  1090. )
  1091. }
  1092. } else {
  1093. return function mergedInstanceDataFn () {
  1094. // instance merge
  1095. var instanceData = typeof childVal === 'function'
  1096. ? childVal.call(vm, vm)
  1097. : childVal;
  1098. var defaultData = typeof parentVal === 'function'
  1099. ? parentVal.call(vm, vm)
  1100. : parentVal;
  1101. if (instanceData) {
  1102. return mergeData(instanceData, defaultData)
  1103. } else {
  1104. return defaultData
  1105. }
  1106. }
  1107. }
  1108. }
  1109. strats.data = function (
  1110. parentVal,
  1111. childVal,
  1112. vm
  1113. ) {
  1114. if (!vm) {
  1115. if (childVal && typeof childVal !== 'function') {
  1116. warn(
  1117. 'The "data" option should be a function ' +
  1118. 'that returns a per-instance value in component ' +
  1119. 'definitions.',
  1120. vm
  1121. );
  1122. return parentVal
  1123. }
  1124. return mergeDataOrFn(parentVal, childVal)
  1125. }
  1126. return mergeDataOrFn(parentVal, childVal, vm)
  1127. };
  1128. /**
  1129. * Hooks and props are merged as arrays.
  1130. */
  1131. function mergeHook (
  1132. parentVal,
  1133. childVal
  1134. ) {
  1135. var res = childVal
  1136. ? parentVal
  1137. ? parentVal.concat(childVal)
  1138. : Array.isArray(childVal)
  1139. ? childVal
  1140. : [childVal]
  1141. : parentVal;
  1142. return res
  1143. ? dedupeHooks(res)
  1144. : res
  1145. }
  1146. function dedupeHooks (hooks) {
  1147. var res = [];
  1148. for (var i = 0; i < hooks.length; i++) {
  1149. if (res.indexOf(hooks[i]) === -1) {
  1150. res.push(hooks[i]);
  1151. }
  1152. }
  1153. return res
  1154. }
  1155. LIFECYCLE_HOOKS.forEach(function (hook) {
  1156. strats[hook] = mergeHook;
  1157. });
  1158. /**
  1159. * Assets
  1160. *
  1161. * When a vm is present (instance creation), we need to do
  1162. * a three-way merge between constructor options, instance
  1163. * options and parent options.
  1164. */
  1165. function mergeAssets (
  1166. parentVal,
  1167. childVal,
  1168. vm,
  1169. key
  1170. ) {
  1171. var res = Object.create(parentVal || null);
  1172. if (childVal) {
  1173. assertObjectType(key, childVal, vm);
  1174. return extend(res, childVal)
  1175. } else {
  1176. return res
  1177. }
  1178. }
  1179. ASSET_TYPES.forEach(function (type) {
  1180. strats[type + 's'] = mergeAssets;
  1181. });
  1182. /**
  1183. * Watchers.
  1184. *
  1185. * Watchers hashes should not overwrite one
  1186. * another, so we merge them as arrays.
  1187. */
  1188. strats.watch = function (
  1189. parentVal,
  1190. childVal,
  1191. vm,
  1192. key
  1193. ) {
  1194. // work around Firefox's Object.prototype.watch...
  1195. if (parentVal === nativeWatch) { parentVal = undefined; }
  1196. if (childVal === nativeWatch) { childVal = undefined; }
  1197. /* istanbul ignore if */
  1198. if (!childVal) { return Object.create(parentVal || null) }
  1199. {
  1200. assertObjectType(key, childVal, vm);
  1201. }
  1202. if (!parentVal) { return childVal }
  1203. var ret = {};
  1204. extend(ret, parentVal);
  1205. for (var key$1 in childVal) {
  1206. var parent = ret[key$1];
  1207. var child = childVal[key$1];
  1208. if (parent && !Array.isArray(parent)) {
  1209. parent = [parent];
  1210. }
  1211. ret[key$1] = parent
  1212. ? parent.concat(child)
  1213. : Array.isArray(child) ? child : [child];
  1214. }
  1215. return ret
  1216. };
  1217. /**
  1218. * Other object hashes.
  1219. */
  1220. strats.props =
  1221. strats.methods =
  1222. strats.inject =
  1223. strats.computed = function (
  1224. parentVal,
  1225. childVal,
  1226. vm,
  1227. key
  1228. ) {
  1229. if (childVal && "development" !== 'production') {
  1230. assertObjectType(key, childVal, vm);
  1231. }
  1232. if (!parentVal) { return childVal }
  1233. var ret = Object.create(null);
  1234. extend(ret, parentVal);
  1235. if (childVal) { extend(ret, childVal); }
  1236. return ret
  1237. };
  1238. strats.provide = mergeDataOrFn;
  1239. /**
  1240. * Default strategy.
  1241. */
  1242. var defaultStrat = function (parentVal, childVal) {
  1243. return childVal === undefined
  1244. ? parentVal
  1245. : childVal
  1246. };
  1247. /**
  1248. * Validate component names
  1249. */
  1250. function checkComponents (options) {
  1251. for (var key in options.components) {
  1252. validateComponentName(key);
  1253. }
  1254. }
  1255. function validateComponentName (name) {
  1256. if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) {
  1257. warn(
  1258. 'Invalid component name: "' + name + '". Component names ' +
  1259. 'should conform to valid custom element name in html5 specification.'
  1260. );
  1261. }
  1262. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  1263. warn(
  1264. 'Do not use built-in or reserved HTML elements as component ' +
  1265. 'id: ' + name
  1266. );
  1267. }
  1268. }
  1269. /**
  1270. * Ensure all props option syntax are normalized into the
  1271. * Object-based format.
  1272. */
  1273. function normalizeProps (options, vm) {
  1274. var props = options.props;
  1275. if (!props) { return }
  1276. var res = {};
  1277. var i, val, name;
  1278. if (Array.isArray(props)) {
  1279. i = props.length;
  1280. while (i--) {
  1281. val = props[i];
  1282. if (typeof val === 'string') {
  1283. name = camelize(val);
  1284. res[name] = { type: null };
  1285. } else {
  1286. warn('props must be strings when using array syntax.');
  1287. }
  1288. }
  1289. } else if (isPlainObject(props)) {
  1290. for (var key in props) {
  1291. val = props[key];
  1292. name = camelize(key);
  1293. res[name] = isPlainObject(val)
  1294. ? val
  1295. : { type: val };
  1296. }
  1297. } else {
  1298. warn(
  1299. "Invalid value for option \"props\": expected an Array or an Object, " +
  1300. "but got " + (toRawType(props)) + ".",
  1301. vm
  1302. );
  1303. }
  1304. options.props = res;
  1305. }
  1306. /**
  1307. * Normalize all injections into Object-based format
  1308. */
  1309. function normalizeInject (options, vm) {
  1310. var inject = options.inject;
  1311. if (!inject) { return }
  1312. var normalized = options.inject = {};
  1313. if (Array.isArray(inject)) {
  1314. for (var i = 0; i < inject.length; i++) {
  1315. normalized[inject[i]] = { from: inject[i] };
  1316. }
  1317. } else if (isPlainObject(inject)) {
  1318. for (var key in inject) {
  1319. var val = inject[key];
  1320. normalized[key] = isPlainObject(val)
  1321. ? extend({ from: key }, val)
  1322. : { from: val };
  1323. }
  1324. } else {
  1325. warn(
  1326. "Invalid value for option \"inject\": expected an Array or an Object, " +
  1327. "but got " + (toRawType(inject)) + ".",
  1328. vm
  1329. );
  1330. }
  1331. }
  1332. /**
  1333. * Normalize raw function directives into object format.
  1334. */
  1335. function normalizeDirectives (options) {
  1336. var dirs = options.directives;
  1337. if (dirs) {
  1338. for (var key in dirs) {
  1339. var def$$1 = dirs[key];
  1340. if (typeof def$$1 === 'function') {
  1341. dirs[key] = { bind: def$$1, update: def$$1 };
  1342. }
  1343. }
  1344. }
  1345. }
  1346. function assertObjectType (name, value, vm) {
  1347. if (!isPlainObject(value)) {
  1348. warn(
  1349. "Invalid value for option \"" + name + "\": expected an Object, " +
  1350. "but got " + (toRawType(value)) + ".",
  1351. vm
  1352. );
  1353. }
  1354. }
  1355. /**
  1356. * Merge two option objects into a new one.
  1357. * Core utility used in both instantiation and inheritance.
  1358. */
  1359. function mergeOptions (
  1360. parent,
  1361. child,
  1362. vm
  1363. ) {
  1364. {
  1365. checkComponents(child);
  1366. }
  1367. if (typeof child === 'function') {
  1368. child = child.options;
  1369. }
  1370. normalizeProps(child, vm);
  1371. normalizeInject(child, vm);
  1372. normalizeDirectives(child);
  1373. // Apply extends and mixins on the child options,
  1374. // but only if it is a raw options object that isn't
  1375. // the result of another mergeOptions call.
  1376. // Only merged options has the _base property.
  1377. if (!child._base) {
  1378. if (child.extends) {
  1379. parent = mergeOptions(parent, child.extends, vm);
  1380. }
  1381. if (child.mixins) {
  1382. for (var i = 0, l = child.mixins.length; i < l; i++) {
  1383. parent = mergeOptions(parent, child.mixins[i], vm);
  1384. }
  1385. }
  1386. }
  1387. var options = {};
  1388. var key;
  1389. for (key in parent) {
  1390. mergeField(key);
  1391. }
  1392. for (key in child) {
  1393. if (!hasOwn(parent, key)) {
  1394. mergeField(key);
  1395. }
  1396. }
  1397. function mergeField (key) {
  1398. var strat = strats[key] || defaultStrat;
  1399. options[key] = strat(parent[key], child[key], vm, key);
  1400. }
  1401. return options
  1402. }
  1403. /**
  1404. * Resolve an asset.
  1405. * This function is used because child instances need access
  1406. * to assets defined in its ancestor chain.
  1407. */
  1408. function resolveAsset (
  1409. options,
  1410. type,
  1411. id,
  1412. warnMissing
  1413. ) {
  1414. /* istanbul ignore if */
  1415. if (typeof id !== 'string') {
  1416. return
  1417. }
  1418. var assets = options[type];
  1419. // check local registration variations first
  1420. if (hasOwn(assets, id)) { return assets[id] }
  1421. var camelizedId = camelize(id);
  1422. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  1423. var PascalCaseId = capitalize(camelizedId);
  1424. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  1425. // fallback to prototype chain
  1426. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  1427. if (warnMissing && !res) {
  1428. warn(
  1429. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  1430. options
  1431. );
  1432. }
  1433. return res
  1434. }
  1435. /* */
  1436. function validateProp (
  1437. key,
  1438. propOptions,
  1439. propsData,
  1440. vm
  1441. ) {
  1442. var prop = propOptions[key];
  1443. var absent = !hasOwn(propsData, key);
  1444. var value = propsData[key];
  1445. // boolean casting
  1446. var booleanIndex = getTypeIndex(Boolean, prop.type);
  1447. if (booleanIndex > -1) {
  1448. if (absent && !hasOwn(prop, 'default')) {
  1449. value = false;
  1450. } else if (value === '' || value === hyphenate(key)) {
  1451. // only cast empty string / same name to boolean if
  1452. // boolean has higher priority
  1453. var stringIndex = getTypeIndex(String, prop.type);
  1454. if (stringIndex < 0 || booleanIndex < stringIndex) {
  1455. value = true;
  1456. }
  1457. }
  1458. }
  1459. // check default value
  1460. if (value === undefined) {
  1461. value = getPropDefaultValue(vm, prop, key);
  1462. // since the default value is a fresh copy,
  1463. // make sure to observe it.
  1464. var prevShouldObserve = shouldObserve;
  1465. toggleObserving(true);
  1466. observe(value);
  1467. toggleObserving(prevShouldObserve);
  1468. }
  1469. {
  1470. assertProp(prop, key, value, vm, absent);
  1471. }
  1472. return value
  1473. }
  1474. /**
  1475. * Get the default value of a prop.
  1476. */
  1477. function getPropDefaultValue (vm, prop, key) {
  1478. // no default, return undefined
  1479. if (!hasOwn(prop, 'default')) {
  1480. return undefined
  1481. }
  1482. var def = prop.default;
  1483. // warn against non-factory defaults for Object & Array
  1484. if (isObject(def)) {
  1485. warn(
  1486. 'Invalid default value for prop "' + key + '": ' +
  1487. 'Props with type Object/Array must use a factory function ' +
  1488. 'to return the default value.',
  1489. vm
  1490. );
  1491. }
  1492. // the raw prop value was also undefined from previous render,
  1493. // return previous default value to avoid unnecessary watcher trigger
  1494. if (vm && vm.$options.propsData &&
  1495. vm.$options.propsData[key] === undefined &&
  1496. vm._props[key] !== undefined
  1497. ) {
  1498. return vm._props[key]
  1499. }
  1500. // call factory function for non-Function types
  1501. // a value is Function if its prototype is function even across different execution context
  1502. return typeof def === 'function' && getType(prop.type) !== 'Function'
  1503. ? def.call(vm)
  1504. : def
  1505. }
  1506. /**
  1507. * Assert whether a prop is valid.
  1508. */
  1509. function assertProp (
  1510. prop,
  1511. name,
  1512. value,
  1513. vm,
  1514. absent
  1515. ) {
  1516. if (prop.required && absent) {
  1517. warn(
  1518. 'Missing required prop: "' + name + '"',
  1519. vm
  1520. );
  1521. return
  1522. }
  1523. if (value == null && !prop.required) {
  1524. return
  1525. }
  1526. var type = prop.type;
  1527. var valid = !type || type === true;
  1528. var expectedTypes = [];
  1529. if (type) {
  1530. if (!Array.isArray(type)) {
  1531. type = [type];
  1532. }
  1533. for (var i = 0; i < type.length && !valid; i++) {
  1534. var assertedType = assertType(value, type[i], vm);
  1535. expectedTypes.push(assertedType.expectedType || '');
  1536. valid = assertedType.valid;
  1537. }
  1538. }
  1539. var haveExpectedTypes = expectedTypes.some(function (t) { return t; });
  1540. if (!valid && haveExpectedTypes) {
  1541. warn(
  1542. getInvalidTypeMessage(name, value, expectedTypes),
  1543. vm
  1544. );
  1545. return
  1546. }
  1547. var validator = prop.validator;
  1548. if (validator) {
  1549. if (!validator(value)) {
  1550. warn(
  1551. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  1552. vm
  1553. );
  1554. }
  1555. }
  1556. }
  1557. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol|BigInt)$/;
  1558. function assertType (value, type, vm) {
  1559. var valid;
  1560. var expectedType = getType(type);
  1561. if (simpleCheckRE.test(expectedType)) {
  1562. var t = typeof value;
  1563. valid = t === expectedType.toLowerCase();
  1564. // for primitive wrapper objects
  1565. if (!valid && t === 'object') {
  1566. valid = value instanceof type;
  1567. }
  1568. } else if (expectedType === 'Object') {
  1569. valid = isPlainObject(value);
  1570. } else if (expectedType === 'Array') {
  1571. valid = Array.isArray(value);
  1572. } else {
  1573. try {
  1574. valid = value instanceof type;
  1575. } catch (e) {
  1576. warn('Invalid prop type: "' + String(type) + '" is not a constructor', vm);
  1577. valid = false;
  1578. }
  1579. }
  1580. return {
  1581. valid: valid,
  1582. expectedType: expectedType
  1583. }
  1584. }
  1585. var functionTypeCheckRE = /^\s*function (\w+)/;
  1586. /**
  1587. * Use function string name to check built-in types,
  1588. * because a simple equality check will fail when running
  1589. * across different vms / iframes.
  1590. */
  1591. function getType (fn) {
  1592. var match = fn && fn.toString().match(functionTypeCheckRE);
  1593. return match ? match[1] : ''
  1594. }
  1595. function isSameType (a, b) {
  1596. return getType(a) === getType(b)
  1597. }
  1598. function getTypeIndex (type, expectedTypes) {
  1599. if (!Array.isArray(expectedTypes)) {
  1600. return isSameType(expectedTypes, type) ? 0 : -1
  1601. }
  1602. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  1603. if (isSameType(expectedTypes[i], type)) {
  1604. return i
  1605. }
  1606. }
  1607. return -1
  1608. }
  1609. function getInvalidTypeMessage (name, value, expectedTypes) {
  1610. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  1611. " Expected " + (expectedTypes.map(capitalize).join(', '));
  1612. var expectedType = expectedTypes[0];
  1613. var receivedType = toRawType(value);
  1614. // check if we need to specify expected value
  1615. if (
  1616. expectedTypes.length === 1 &&
  1617. isExplicable(expectedType) &&
  1618. isExplicable(typeof value) &&
  1619. !isBoolean(expectedType, receivedType)
  1620. ) {
  1621. message += " with value " + (styleValue(value, expectedType));
  1622. }
  1623. message += ", got " + receivedType + " ";
  1624. // check if we need to specify received value
  1625. if (isExplicable(receivedType)) {
  1626. message += "with value " + (styleValue(value, receivedType)) + ".";
  1627. }
  1628. return message
  1629. }
  1630. function styleValue (value, type) {
  1631. if (type === 'String') {
  1632. return ("\"" + value + "\"")
  1633. } else if (type === 'Number') {
  1634. return ("" + (Number(value)))
  1635. } else {
  1636. return ("" + value)
  1637. }
  1638. }
  1639. var EXPLICABLE_TYPES = ['string', 'number', 'boolean'];
  1640. function isExplicable (value) {
  1641. return EXPLICABLE_TYPES.some(function (elem) { return value.toLowerCase() === elem; })
  1642. }
  1643. function isBoolean () {
  1644. var args = [], len = arguments.length;
  1645. while ( len-- ) args[ len ] = arguments[ len ];
  1646. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  1647. }
  1648. /* */
  1649. function handleError (err, vm, info) {
  1650. // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
  1651. // See: https://github.com/vuejs/vuex/issues/1505
  1652. pushTarget();
  1653. try {
  1654. if (vm) {
  1655. var cur = vm;
  1656. while ((cur = cur.$parent)) {
  1657. var hooks = cur.$options.errorCaptured;
  1658. if (hooks) {
  1659. for (var i = 0; i < hooks.length; i++) {
  1660. try {
  1661. var capture = hooks[i].call(cur, err, vm, info) === false;
  1662. if (capture) { return }
  1663. } catch (e) {
  1664. globalHandleError(e, cur, 'errorCaptured hook');
  1665. }
  1666. }
  1667. }
  1668. }
  1669. }
  1670. globalHandleError(err, vm, info);
  1671. } finally {
  1672. popTarget();
  1673. }
  1674. }
  1675. function invokeWithErrorHandling (
  1676. handler,
  1677. context,
  1678. args,
  1679. vm,
  1680. info
  1681. ) {
  1682. var res;
  1683. try {
  1684. res = args ? handler.apply(context, args) : handler.call(context);
  1685. if (res && !res._isVue && isPromise(res) && !res._handled) {
  1686. res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); });
  1687. // issue #9511
  1688. // avoid catch triggering multiple times when nested calls
  1689. res._handled = true;
  1690. }
  1691. } catch (e) {
  1692. handleError(e, vm, info);
  1693. }
  1694. return res
  1695. }
  1696. function globalHandleError (err, vm, info) {
  1697. if (config.errorHandler) {
  1698. try {
  1699. return config.errorHandler.call(null, err, vm, info)
  1700. } catch (e) {
  1701. // if the user intentionally throws the original error in the handler,
  1702. // do not log it twice
  1703. if (e !== err) {
  1704. logError(e, null, 'config.errorHandler');
  1705. }
  1706. }
  1707. }
  1708. logError(err, vm, info);
  1709. }
  1710. function logError (err, vm, info) {
  1711. {
  1712. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  1713. }
  1714. /* istanbul ignore else */
  1715. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  1716. console.error(err);
  1717. } else {
  1718. throw err
  1719. }
  1720. }
  1721. /* */
  1722. var isUsingMicroTask = false;
  1723. var callbacks = [];
  1724. var pending = false;
  1725. function flushCallbacks () {
  1726. pending = false;
  1727. var copies = callbacks.slice(0);
  1728. callbacks.length = 0;
  1729. for (var i = 0; i < copies.length; i++) {
  1730. copies[i]();
  1731. }
  1732. }
  1733. // Here we have async deferring wrappers using microtasks.
  1734. // In 2.5 we used (macro) tasks (in combination with microtasks).
  1735. // However, it has subtle problems when state is changed right before repaint
  1736. // (e.g. #6813, out-in transitions).
  1737. // Also, using (macro) tasks in event handler would cause some weird behaviors
  1738. // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109).
  1739. // So we now use microtasks everywhere, again.
  1740. // A major drawback of this tradeoff is that there are some scenarios
  1741. // where microtasks have too high a priority and fire in between supposedly
  1742. // sequential events (e.g. #4521, #6690, which have workarounds)
  1743. // or even between bubbling of the same event (#6566).
  1744. var timerFunc;
  1745. // The nextTick behavior leverages the microtask queue, which can be accessed
  1746. // via either native Promise.then or MutationObserver.
  1747. // MutationObserver has wider support, however it is seriously bugged in
  1748. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  1749. // completely stops working after triggering a few times... so, if native
  1750. // Promise is available, we will use it:
  1751. /* istanbul ignore next, $flow-disable-line */
  1752. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  1753. var p = Promise.resolve();
  1754. timerFunc = function () {
  1755. p.then(flushCallbacks);
  1756. // In problematic UIWebViews, Promise.then doesn't completely break, but
  1757. // it can get stuck in a weird state where callbacks are pushed into the
  1758. // microtask queue but the queue isn't being flushed, until the browser
  1759. // needs to do some other work, e.g. handle a timer. Therefore we can
  1760. // "force" the microtask queue to be flushed by adding an empty timer.
  1761. if (isIOS) { setTimeout(noop); }
  1762. };
  1763. isUsingMicroTask = true;
  1764. } else if (!isIE && typeof MutationObserver !== 'undefined' && (
  1765. isNative(MutationObserver) ||
  1766. // PhantomJS and iOS 7.x
  1767. MutationObserver.toString() === '[object MutationObserverConstructor]'
  1768. )) {
  1769. // Use MutationObserver where native Promise is not available,
  1770. // e.g. PhantomJS, iOS7, Android 4.4
  1771. // (#6466 MutationObserver is unreliable in IE11)
  1772. var counter = 1;
  1773. var observer = new MutationObserver(flushCallbacks);
  1774. var textNode = document.createTextNode(String(counter));
  1775. observer.observe(textNode, {
  1776. characterData: true
  1777. });
  1778. timerFunc = function () {
  1779. counter = (counter + 1) % 2;
  1780. textNode.data = String(counter);
  1781. };
  1782. isUsingMicroTask = true;
  1783. } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  1784. // Fallback to setImmediate.
  1785. // Technically it leverages the (macro) task queue,
  1786. // but it is still a better choice than setTimeout.
  1787. timerFunc = function () {
  1788. setImmediate(flushCallbacks);
  1789. };
  1790. } else {
  1791. // Fallback to setTimeout.
  1792. timerFunc = function () {
  1793. setTimeout(flushCallbacks, 0);
  1794. };
  1795. }
  1796. function nextTick (cb, ctx) {
  1797. var _resolve;
  1798. callbacks.push(function () {
  1799. if (cb) {
  1800. try {
  1801. cb.call(ctx);
  1802. } catch (e) {
  1803. handleError(e, ctx, 'nextTick');
  1804. }
  1805. } else if (_resolve) {
  1806. _resolve(ctx);
  1807. }
  1808. });
  1809. if (!pending) {
  1810. pending = true;
  1811. timerFunc();
  1812. }
  1813. // $flow-disable-line
  1814. if (!cb && typeof Promise !== 'undefined') {
  1815. return new Promise(function (resolve) {
  1816. _resolve = resolve;
  1817. })
  1818. }
  1819. }
  1820. /* */
  1821. var mark;
  1822. var measure;
  1823. {
  1824. var perf = inBrowser && window.performance;
  1825. /* istanbul ignore if */
  1826. if (
  1827. perf &&
  1828. perf.mark &&
  1829. perf.measure &&
  1830. perf.clearMarks &&
  1831. perf.clearMeasures
  1832. ) {
  1833. mark = function (tag) { return perf.mark(tag); };
  1834. measure = function (name, startTag, endTag) {
  1835. perf.measure(name, startTag, endTag);
  1836. perf.clearMarks(startTag);
  1837. perf.clearMarks(endTag);
  1838. // perf.clearMeasures(name)
  1839. };
  1840. }
  1841. }
  1842. /* not type checking this file because flow doesn't play well with Proxy */
  1843. var initProxy;
  1844. {
  1845. var allowedGlobals = makeMap(
  1846. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  1847. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  1848. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,' +
  1849. 'require' // for Webpack/Browserify
  1850. );
  1851. var warnNonPresent = function (target, key) {
  1852. warn(
  1853. "Property or method \"" + key + "\" is not defined on the instance but " +
  1854. 'referenced during render. Make sure that this property is reactive, ' +
  1855. 'either in the data option, or for class-based components, by ' +
  1856. 'initializing the property. ' +
  1857. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  1858. target
  1859. );
  1860. };
  1861. var warnReservedPrefix = function (target, key) {
  1862. warn(
  1863. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  1864. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  1865. 'prevent conflicts with Vue internals. ' +
  1866. 'See: https://vuejs.org/v2/api/#data',
  1867. target
  1868. );
  1869. };
  1870. var hasProxy =
  1871. typeof Proxy !== 'undefined' && isNative(Proxy);
  1872. if (hasProxy) {
  1873. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  1874. config.keyCodes = new Proxy(config.keyCodes, {
  1875. set: function set (target, key, value) {
  1876. if (isBuiltInModifier(key)) {
  1877. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  1878. return false
  1879. } else {
  1880. target[key] = value;
  1881. return true
  1882. }
  1883. }
  1884. });
  1885. }
  1886. var hasHandler = {
  1887. has: function has (target, key) {
  1888. var has = key in target;
  1889. var isAllowed = allowedGlobals(key) ||
  1890. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  1891. if (!has && !isAllowed) {
  1892. if (key in target.$data) { warnReservedPrefix(target, key); }
  1893. else { warnNonPresent(target, key); }
  1894. }
  1895. return has || !isAllowed
  1896. }
  1897. };
  1898. var getHandler = {
  1899. get: function get (target, key) {
  1900. if (typeof key === 'string' && !(key in target)) {
  1901. if (key in target.$data) { warnReservedPrefix(target, key); }
  1902. else { warnNonPresent(target, key); }
  1903. }
  1904. return target[key]
  1905. }
  1906. };
  1907. initProxy = function initProxy (vm) {
  1908. if (hasProxy) {
  1909. // determine which proxy handler to use
  1910. var options = vm.$options;
  1911. var handlers = options.render && options.render._withStripped
  1912. ? getHandler
  1913. : hasHandler;
  1914. vm._renderProxy = new Proxy(vm, handlers);
  1915. } else {
  1916. vm._renderProxy = vm;
  1917. }
  1918. };
  1919. }
  1920. /* */
  1921. var seenObjects = new _Set();
  1922. /**
  1923. * Recursively traverse an object to evoke all converted
  1924. * getters, so that every nested property inside the object
  1925. * is collected as a "deep" dependency.
  1926. */
  1927. function traverse (val) {
  1928. _traverse(val, seenObjects);
  1929. seenObjects.clear();
  1930. }
  1931. function _traverse (val, seen) {
  1932. var i, keys;
  1933. var isA = Array.isArray(val);
  1934. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  1935. return
  1936. }
  1937. if (val.__ob__) {
  1938. var depId = val.__ob__.dep.id;
  1939. if (seen.has(depId)) {
  1940. return
  1941. }
  1942. seen.add(depId);
  1943. }
  1944. if (isA) {
  1945. i = val.length;
  1946. while (i--) { _traverse(val[i], seen); }
  1947. } else {
  1948. keys = Object.keys(val);
  1949. i = keys.length;
  1950. while (i--) { _traverse(val[keys[i]], seen); }
  1951. }
  1952. }
  1953. /* */
  1954. var normalizeEvent = cached(function (name) {
  1955. var passive = name.charAt(0) === '&';
  1956. name = passive ? name.slice(1) : name;
  1957. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  1958. name = once$$1 ? name.slice(1) : name;
  1959. var capture = name.charAt(0) === '!';
  1960. name = capture ? name.slice(1) : name;
  1961. return {
  1962. name: name,
  1963. once: once$$1,
  1964. capture: capture,
  1965. passive: passive
  1966. }
  1967. });
  1968. function createFnInvoker (fns, vm) {
  1969. function invoker () {
  1970. var arguments$1 = arguments;
  1971. var fns = invoker.fns;
  1972. if (Array.isArray(fns)) {
  1973. var cloned = fns.slice();
  1974. for (var i = 0; i < cloned.length; i++) {
  1975. invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler");
  1976. }
  1977. } else {
  1978. // return handler return value for single handlers
  1979. return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler")
  1980. }
  1981. }
  1982. invoker.fns = fns;
  1983. return invoker
  1984. }
  1985. function updateListeners (
  1986. on,
  1987. oldOn,
  1988. add,
  1989. remove$$1,
  1990. createOnceHandler,
  1991. vm
  1992. ) {
  1993. var name, def$$1, cur, old, event;
  1994. for (name in on) {
  1995. def$$1 = cur = on[name];
  1996. old = oldOn[name];
  1997. event = normalizeEvent(name);
  1998. if (isUndef(cur)) {
  1999. warn(
  2000. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  2001. vm
  2002. );
  2003. } else if (isUndef(old)) {
  2004. if (isUndef(cur.fns)) {
  2005. cur = on[name] = createFnInvoker(cur, vm);
  2006. }
  2007. if (isTrue(event.once)) {
  2008. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  2009. }
  2010. add(event.name, cur, event.capture, event.passive, event.params);
  2011. } else if (cur !== old) {
  2012. old.fns = cur;
  2013. on[name] = old;
  2014. }
  2015. }
  2016. for (name in oldOn) {
  2017. if (isUndef(on[name])) {
  2018. event = normalizeEvent(name);
  2019. remove$$1(event.name, oldOn[name], event.capture);
  2020. }
  2021. }
  2022. }
  2023. /* */
  2024. function mergeVNodeHook (def, hookKey, hook) {
  2025. if (def instanceof VNode) {
  2026. def = def.data.hook || (def.data.hook = {});
  2027. }
  2028. var invoker;
  2029. var oldHook = def[hookKey];
  2030. function wrappedHook () {
  2031. hook.apply(this, arguments);
  2032. // important: remove merged hook to ensure it's called only once
  2033. // and prevent memory leak
  2034. remove(invoker.fns, wrappedHook);
  2035. }
  2036. if (isUndef(oldHook)) {
  2037. // no existing hook
  2038. invoker = createFnInvoker([wrappedHook]);
  2039. } else {
  2040. /* istanbul ignore if */
  2041. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  2042. // already a merged invoker
  2043. invoker = oldHook;
  2044. invoker.fns.push(wrappedHook);
  2045. } else {
  2046. // existing plain hook
  2047. invoker = createFnInvoker([oldHook, wrappedHook]);
  2048. }
  2049. }
  2050. invoker.merged = true;
  2051. def[hookKey] = invoker;
  2052. }
  2053. /* */
  2054. function extractPropsFromVNodeData (
  2055. data,
  2056. Ctor,
  2057. tag
  2058. ) {
  2059. // we are only extracting raw values here.
  2060. // validation and default values are handled in the child
  2061. // component itself.
  2062. var propOptions = Ctor.options.props;
  2063. if (isUndef(propOptions)) {
  2064. return
  2065. }
  2066. var res = {};
  2067. var attrs = data.attrs;
  2068. var props = data.props;
  2069. if (isDef(attrs) || isDef(props)) {
  2070. for (var key in propOptions) {
  2071. var altKey = hyphenate(key);
  2072. {
  2073. var keyInLowerCase = key.toLowerCase();
  2074. if (
  2075. key !== keyInLowerCase &&
  2076. attrs && hasOwn(attrs, keyInLowerCase)
  2077. ) {
  2078. tip(
  2079. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  2080. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  2081. " \"" + key + "\". " +
  2082. "Note that HTML attributes are case-insensitive and camelCased " +
  2083. "props need to use their kebab-case equivalents when using in-DOM " +
  2084. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  2085. );
  2086. }
  2087. }
  2088. checkProp(res, props, key, altKey, true) ||
  2089. checkProp(res, attrs, key, altKey, false);
  2090. }
  2091. }
  2092. return res
  2093. }
  2094. function checkProp (
  2095. res,
  2096. hash,
  2097. key,
  2098. altKey,
  2099. preserve
  2100. ) {
  2101. if (isDef(hash)) {
  2102. if (hasOwn(hash, key)) {
  2103. res[key] = hash[key];
  2104. if (!preserve) {
  2105. delete hash[key];
  2106. }
  2107. return true
  2108. } else if (hasOwn(hash, altKey)) {
  2109. res[key] = hash[altKey];
  2110. if (!preserve) {
  2111. delete hash[altKey];
  2112. }
  2113. return true
  2114. }
  2115. }
  2116. return false
  2117. }
  2118. /* */
  2119. // The template compiler attempts to minimize the need for normalization by
  2120. // statically analyzing the template at compile time.
  2121. //
  2122. // For plain HTML markup, normalization can be completely skipped because the
  2123. // generated render function is guaranteed to return Array<VNode>. There are
  2124. // two cases where extra normalization is needed:
  2125. // 1. When the children contains components - because a functional component
  2126. // may return an Array instead of a single root. In this case, just a simple
  2127. // normalization is needed - if any child is an Array, we flatten the whole
  2128. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  2129. // because functional components already normalize their own children.
  2130. function simpleNormalizeChildren (children) {
  2131. for (var i = 0; i < children.length; i++) {
  2132. if (Array.isArray(children[i])) {
  2133. return Array.prototype.concat.apply([], children)
  2134. }
  2135. }
  2136. return children
  2137. }
  2138. // 2. When the children contains constructs that always generated nested Arrays,
  2139. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  2140. // with hand-written render functions / JSX. In such cases a full normalization
  2141. // is needed to cater to all possible types of children values.
  2142. function normalizeChildren (children) {
  2143. return isPrimitive(children)
  2144. ? [createTextVNode(children)]
  2145. : Array.isArray(children)
  2146. ? normalizeArrayChildren(children)
  2147. : undefined
  2148. }
  2149. function isTextNode (node) {
  2150. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  2151. }
  2152. function normalizeArrayChildren (children, nestedIndex) {
  2153. var res = [];
  2154. var i, c, lastIndex, last;
  2155. for (i = 0; i < children.length; i++) {
  2156. c = children[i];
  2157. if (isUndef(c) || typeof c === 'boolean') { continue }
  2158. lastIndex = res.length - 1;
  2159. last = res[lastIndex];
  2160. // nested
  2161. if (Array.isArray(c)) {
  2162. if (c.length > 0) {
  2163. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  2164. // merge adjacent text nodes
  2165. if (isTextNode(c[0]) && isTextNode(last)) {
  2166. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  2167. c.shift();
  2168. }
  2169. res.push.apply(res, c);
  2170. }
  2171. } else if (isPrimitive(c)) {
  2172. if (isTextNode(last)) {
  2173. // merge adjacent text nodes
  2174. // this is necessary for SSR hydration because text nodes are
  2175. // essentially merged when rendered to HTML strings
  2176. res[lastIndex] = createTextVNode(last.text + c);
  2177. } else if (c !== '') {
  2178. // convert primitive to vnode
  2179. res.push(createTextVNode(c));
  2180. }
  2181. } else {
  2182. if (isTextNode(c) && isTextNode(last)) {
  2183. // merge adjacent text nodes
  2184. res[lastIndex] = createTextVNode(last.text + c.text);
  2185. } else {
  2186. // default key for nested array children (likely generated by v-for)
  2187. if (isTrue(children._isVList) &&
  2188. isDef(c.tag) &&
  2189. isUndef(c.key) &&
  2190. isDef(nestedIndex)) {
  2191. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  2192. }
  2193. res.push(c);
  2194. }
  2195. }
  2196. }
  2197. return res
  2198. }
  2199. /* */
  2200. function initProvide (vm) {
  2201. var provide = vm.$options.provide;
  2202. if (provide) {
  2203. vm._provided = typeof provide === 'function'
  2204. ? provide.call(vm)
  2205. : provide;
  2206. }
  2207. }
  2208. function initInjections (vm) {
  2209. var result = resolveInject(vm.$options.inject, vm);
  2210. if (result) {
  2211. toggleObserving(false);
  2212. Object.keys(result).forEach(function (key) {
  2213. /* istanbul ignore else */
  2214. {
  2215. defineReactive$$1(vm, key, result[key], function () {
  2216. warn(
  2217. "Avoid mutating an injected value directly since the changes will be " +
  2218. "overwritten whenever the provided component re-renders. " +
  2219. "injection being mutated: \"" + key + "\"",
  2220. vm
  2221. );
  2222. });
  2223. }
  2224. });
  2225. toggleObserving(true);
  2226. }
  2227. }
  2228. function resolveInject (inject, vm) {
  2229. if (inject) {
  2230. // inject is :any because flow is not smart enough to figure out cached
  2231. var result = Object.create(null);
  2232. var keys = hasSymbol
  2233. ? Reflect.ownKeys(inject)
  2234. : Object.keys(inject);
  2235. for (var i = 0; i < keys.length; i++) {
  2236. var key = keys[i];
  2237. // #6574 in case the inject object is observed...
  2238. if (key === '__ob__') { continue }
  2239. var provideKey = inject[key].from;
  2240. var source = vm;
  2241. while (source) {
  2242. if (source._provided && hasOwn(source._provided, provideKey)) {
  2243. result[key] = source._provided[provideKey];
  2244. break
  2245. }
  2246. source = source.$parent;
  2247. }
  2248. if (!source) {
  2249. if ('default' in inject[key]) {
  2250. var provideDefault = inject[key].default;
  2251. result[key] = typeof provideDefault === 'function'
  2252. ? provideDefault.call(vm)
  2253. : provideDefault;
  2254. } else {
  2255. warn(("Injection \"" + key + "\" not found"), vm);
  2256. }
  2257. }
  2258. }
  2259. return result
  2260. }
  2261. }
  2262. /* */
  2263. /**
  2264. * Runtime helper for resolving raw children VNodes into a slot object.
  2265. */
  2266. function resolveSlots (
  2267. children,
  2268. context
  2269. ) {
  2270. if (!children || !children.length) {
  2271. return {}
  2272. }
  2273. var slots = {};
  2274. for (var i = 0, l = children.length; i < l; i++) {
  2275. var child = children[i];
  2276. var data = child.data;
  2277. // remove slot attribute if the node is resolved as a Vue slot node
  2278. if (data && data.attrs && data.attrs.slot) {
  2279. delete data.attrs.slot;
  2280. }
  2281. // named slots should only be respected if the vnode was rendered in the
  2282. // same context.
  2283. if ((child.context === context || child.fnContext === context) &&
  2284. data && data.slot != null
  2285. ) {
  2286. var name = data.slot;
  2287. var slot = (slots[name] || (slots[name] = []));
  2288. if (child.tag === 'template') {
  2289. slot.push.apply(slot, child.children || []);
  2290. } else {
  2291. slot.push(child);
  2292. }
  2293. } else {
  2294. (slots.default || (slots.default = [])).push(child);
  2295. }
  2296. }
  2297. // ignore slots that contains only whitespace
  2298. for (var name$1 in slots) {
  2299. if (slots[name$1].every(isWhitespace)) {
  2300. delete slots[name$1];
  2301. }
  2302. }
  2303. return slots
  2304. }
  2305. function isWhitespace (node) {
  2306. return (node.isComment && !node.asyncFactory) || node.text === ' '
  2307. }
  2308. /* */
  2309. function isAsyncPlaceholder (node) {
  2310. return node.isComment && node.asyncFactory
  2311. }
  2312. /* */
  2313. function normalizeScopedSlots (
  2314. slots,
  2315. normalSlots,
  2316. prevSlots
  2317. ) {
  2318. var res;
  2319. var hasNormalSlots = Object.keys(normalSlots).length > 0;
  2320. var isStable = slots ? !!slots.$stable : !hasNormalSlots;
  2321. var key = slots && slots.$key;
  2322. if (!slots) {
  2323. res = {};
  2324. } else if (slots._normalized) {
  2325. // fast path 1: child component re-render only, parent did not change
  2326. return slots._normalized
  2327. } else if (
  2328. isStable &&
  2329. prevSlots &&
  2330. prevSlots !== emptyObject &&
  2331. key === prevSlots.$key &&
  2332. !hasNormalSlots &&
  2333. !prevSlots.$hasNormal
  2334. ) {
  2335. // fast path 2: stable scoped slots w/ no normal slots to proxy,
  2336. // only need to normalize once
  2337. return prevSlots
  2338. } else {
  2339. res = {};
  2340. for (var key$1 in slots) {
  2341. if (slots[key$1] && key$1[0] !== '$') {
  2342. res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]);
  2343. }
  2344. }
  2345. }
  2346. // expose normal slots on scopedSlots
  2347. for (var key$2 in normalSlots) {
  2348. if (!(key$2 in res)) {
  2349. res[key$2] = proxyNormalSlot(normalSlots, key$2);
  2350. }
  2351. }
  2352. // avoriaz seems to mock a non-extensible $scopedSlots object
  2353. // and when that is passed down this would cause an error
  2354. if (slots && Object.isExtensible(slots)) {
  2355. (slots)._normalized = res;
  2356. }
  2357. def(res, '$stable', isStable);
  2358. def(res, '$key', key);
  2359. def(res, '$hasNormal', hasNormalSlots);
  2360. return res
  2361. }
  2362. function normalizeScopedSlot(normalSlots, key, fn) {
  2363. var normalized = function () {
  2364. var res = arguments.length ? fn.apply(null, arguments) : fn({});
  2365. res = res && typeof res === 'object' && !Array.isArray(res)
  2366. ? [res] // single vnode
  2367. : normalizeChildren(res);
  2368. var vnode = res && res[0];
  2369. return res && (
  2370. !vnode ||
  2371. (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode)) // #9658, #10391
  2372. ) ? undefined
  2373. : res
  2374. };
  2375. // this is a slot using the new v-slot syntax without scope. although it is
  2376. // compiled as a scoped slot, render fn users would expect it to be present
  2377. // on this.$slots because the usage is semantically a normal slot.
  2378. if (fn.proxy) {
  2379. Object.defineProperty(normalSlots, key, {
  2380. get: normalized,
  2381. enumerable: true,
  2382. configurable: true
  2383. });
  2384. }
  2385. return normalized
  2386. }
  2387. function proxyNormalSlot(slots, key) {
  2388. return function () { return slots[key]; }
  2389. }
  2390. /* */
  2391. /**
  2392. * Runtime helper for rendering v-for lists.
  2393. */
  2394. function renderList (
  2395. val,
  2396. render
  2397. ) {
  2398. var ret, i, l, keys, key;
  2399. if (Array.isArray(val) || typeof val === 'string') {
  2400. ret = new Array(val.length);
  2401. for (i = 0, l = val.length; i < l; i++) {
  2402. ret[i] = render(val[i], i);
  2403. }
  2404. } else if (typeof val === 'number') {
  2405. ret = new Array(val);
  2406. for (i = 0; i < val; i++) {
  2407. ret[i] = render(i + 1, i);
  2408. }
  2409. } else if (isObject(val)) {
  2410. if (hasSymbol && val[Symbol.iterator]) {
  2411. ret = [];
  2412. var iterator = val[Symbol.iterator]();
  2413. var result = iterator.next();
  2414. while (!result.done) {
  2415. ret.push(render(result.value, ret.length));
  2416. result = iterator.next();
  2417. }
  2418. } else {
  2419. keys = Object.keys(val);
  2420. ret = new Array(keys.length);
  2421. for (i = 0, l = keys.length; i < l; i++) {
  2422. key = keys[i];
  2423. ret[i] = render(val[key], key, i);
  2424. }
  2425. }
  2426. }
  2427. if (!isDef(ret)) {
  2428. ret = [];
  2429. }
  2430. (ret)._isVList = true;
  2431. return ret
  2432. }
  2433. /* */
  2434. /**
  2435. * Runtime helper for rendering <slot>
  2436. */
  2437. function renderSlot (
  2438. name,
  2439. fallbackRender,
  2440. props,
  2441. bindObject
  2442. ) {
  2443. var scopedSlotFn = this.$scopedSlots[name];
  2444. var nodes;
  2445. if (scopedSlotFn) {
  2446. // scoped slot
  2447. props = props || {};
  2448. if (bindObject) {
  2449. if (!isObject(bindObject)) {
  2450. warn('slot v-bind without argument expects an Object', this);
  2451. }
  2452. props = extend(extend({}, bindObject), props);
  2453. }
  2454. nodes =
  2455. scopedSlotFn(props) ||
  2456. (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
  2457. } else {
  2458. nodes =
  2459. this.$slots[name] ||
  2460. (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender);
  2461. }
  2462. var target = props && props.slot;
  2463. if (target) {
  2464. return this.$createElement('template', { slot: target }, nodes)
  2465. } else {
  2466. return nodes
  2467. }
  2468. }
  2469. /* */
  2470. /**
  2471. * Runtime helper for resolving filters
  2472. */
  2473. function resolveFilter (id) {
  2474. return resolveAsset(this.$options, 'filters', id, true) || identity
  2475. }
  2476. /* */
  2477. function isKeyNotMatch (expect, actual) {
  2478. if (Array.isArray(expect)) {
  2479. return expect.indexOf(actual) === -1
  2480. } else {
  2481. return expect !== actual
  2482. }
  2483. }
  2484. /**
  2485. * Runtime helper for checking keyCodes from config.
  2486. * exposed as Vue.prototype._k
  2487. * passing in eventKeyName as last argument separately for backwards compat
  2488. */
  2489. function checkKeyCodes (
  2490. eventKeyCode,
  2491. key,
  2492. builtInKeyCode,
  2493. eventKeyName,
  2494. builtInKeyName
  2495. ) {
  2496. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  2497. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  2498. return isKeyNotMatch(builtInKeyName, eventKeyName)
  2499. } else if (mappedKeyCode) {
  2500. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  2501. } else if (eventKeyName) {
  2502. return hyphenate(eventKeyName) !== key
  2503. }
  2504. return eventKeyCode === undefined
  2505. }
  2506. /* */
  2507. /**
  2508. * Runtime helper for merging v-bind="object" into a VNode's data.
  2509. */
  2510. function bindObjectProps (
  2511. data,
  2512. tag,
  2513. value,
  2514. asProp,
  2515. isSync
  2516. ) {
  2517. if (value) {
  2518. if (!isObject(value)) {
  2519. warn(
  2520. 'v-bind without argument expects an Object or Array value',
  2521. this
  2522. );
  2523. } else {
  2524. if (Array.isArray(value)) {
  2525. value = toObject(value);
  2526. }
  2527. var hash;
  2528. var loop = function ( key ) {
  2529. if (
  2530. key === 'class' ||
  2531. key === 'style' ||
  2532. isReservedAttribute(key)
  2533. ) {
  2534. hash = data;
  2535. } else {
  2536. var type = data.attrs && data.attrs.type;
  2537. hash = asProp || config.mustUseProp(tag, type, key)
  2538. ? data.domProps || (data.domProps = {})
  2539. : data.attrs || (data.attrs = {});
  2540. }
  2541. var camelizedKey = camelize(key);
  2542. var hyphenatedKey = hyphenate(key);
  2543. if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) {
  2544. hash[key] = value[key];
  2545. if (isSync) {
  2546. var on = data.on || (data.on = {});
  2547. on[("update:" + key)] = function ($event) {
  2548. value[key] = $event;
  2549. };
  2550. }
  2551. }
  2552. };
  2553. for (var key in value) loop( key );
  2554. }
  2555. }
  2556. return data
  2557. }
  2558. /* */
  2559. /**
  2560. * Runtime helper for rendering static trees.
  2561. */
  2562. function renderStatic (
  2563. index,
  2564. isInFor
  2565. ) {
  2566. var cached = this._staticTrees || (this._staticTrees = []);
  2567. var tree = cached[index];
  2568. // if has already-rendered static tree and not inside v-for,
  2569. // we can reuse the same tree.
  2570. if (tree && !isInFor) {
  2571. return tree
  2572. }
  2573. // otherwise, render a fresh tree.
  2574. tree = cached[index] = this.$options.staticRenderFns[index].call(
  2575. this._renderProxy,
  2576. null,
  2577. this // for render fns generated for functional component templates
  2578. );
  2579. markStatic(tree, ("__static__" + index), false);
  2580. return tree
  2581. }
  2582. /**
  2583. * Runtime helper for v-once.
  2584. * Effectively it means marking the node as static with a unique key.
  2585. */
  2586. function markOnce (
  2587. tree,
  2588. index,
  2589. key
  2590. ) {
  2591. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  2592. return tree
  2593. }
  2594. function markStatic (
  2595. tree,
  2596. key,
  2597. isOnce
  2598. ) {
  2599. if (Array.isArray(tree)) {
  2600. for (var i = 0; i < tree.length; i++) {
  2601. if (tree[i] && typeof tree[i] !== 'string') {
  2602. markStaticNode(tree[i], (key + "_" + i), isOnce);
  2603. }
  2604. }
  2605. } else {
  2606. markStaticNode(tree, key, isOnce);
  2607. }
  2608. }
  2609. function markStaticNode (node, key, isOnce) {
  2610. node.isStatic = true;
  2611. node.key = key;
  2612. node.isOnce = isOnce;
  2613. }
  2614. /* */
  2615. function bindObjectListeners (data, value) {
  2616. if (value) {
  2617. if (!isPlainObject(value)) {
  2618. warn(
  2619. 'v-on without argument expects an Object value',
  2620. this
  2621. );
  2622. } else {
  2623. var on = data.on = data.on ? extend({}, data.on) : {};
  2624. for (var key in value) {
  2625. var existing = on[key];
  2626. var ours = value[key];
  2627. on[key] = existing ? [].concat(existing, ours) : ours;
  2628. }
  2629. }
  2630. }
  2631. return data
  2632. }
  2633. /* */
  2634. function resolveScopedSlots (
  2635. fns, // see flow/vnode
  2636. res,
  2637. // the following are added in 2.6
  2638. hasDynamicKeys,
  2639. contentHashKey
  2640. ) {
  2641. res = res || { $stable: !hasDynamicKeys };
  2642. for (var i = 0; i < fns.length; i++) {
  2643. var slot = fns[i];
  2644. if (Array.isArray(slot)) {
  2645. resolveScopedSlots(slot, res, hasDynamicKeys);
  2646. } else if (slot) {
  2647. // marker for reverse proxying v-slot without scope on this.$slots
  2648. if (slot.proxy) {
  2649. slot.fn.proxy = true;
  2650. }
  2651. res[slot.key] = slot.fn;
  2652. }
  2653. }
  2654. if (contentHashKey) {
  2655. (res).$key = contentHashKey;
  2656. }
  2657. return res
  2658. }
  2659. /* */
  2660. function bindDynamicKeys (baseObj, values) {
  2661. for (var i = 0; i < values.length; i += 2) {
  2662. var key = values[i];
  2663. if (typeof key === 'string' && key) {
  2664. baseObj[values[i]] = values[i + 1];
  2665. } else if (key !== '' && key !== null) {
  2666. // null is a special value for explicitly removing a binding
  2667. warn(
  2668. ("Invalid value for dynamic directive argument (expected string or null): " + key),
  2669. this
  2670. );
  2671. }
  2672. }
  2673. return baseObj
  2674. }
  2675. // helper to dynamically append modifier runtime markers to event names.
  2676. // ensure only append when value is already string, otherwise it will be cast
  2677. // to string and cause the type check to miss.
  2678. function prependModifier (value, symbol) {
  2679. return typeof value === 'string' ? symbol + value : value
  2680. }
  2681. /* */
  2682. function installRenderHelpers (target) {
  2683. target._o = markOnce;
  2684. target._n = toNumber;
  2685. target._s = toString;
  2686. target._l = renderList;
  2687. target._t = renderSlot;
  2688. target._q = looseEqual;
  2689. target._i = looseIndexOf;
  2690. target._m = renderStatic;
  2691. target._f = resolveFilter;
  2692. target._k = checkKeyCodes;
  2693. target._b = bindObjectProps;
  2694. target._v = createTextVNode;
  2695. target._e = createEmptyVNode;
  2696. target._u = resolveScopedSlots;
  2697. target._g = bindObjectListeners;
  2698. target._d = bindDynamicKeys;
  2699. target._p = prependModifier;
  2700. }
  2701. /* */
  2702. function FunctionalRenderContext (
  2703. data,
  2704. props,
  2705. children,
  2706. parent,
  2707. Ctor
  2708. ) {
  2709. var this$1 = this;
  2710. var options = Ctor.options;
  2711. // ensure the createElement function in functional components
  2712. // gets a unique context - this is necessary for correct named slot check
  2713. var contextVm;
  2714. if (hasOwn(parent, '_uid')) {
  2715. contextVm = Object.create(parent);
  2716. // $flow-disable-line
  2717. contextVm._original = parent;
  2718. } else {
  2719. // the context vm passed in is a functional context as well.
  2720. // in this case we want to make sure we are able to get a hold to the
  2721. // real context instance.
  2722. contextVm = parent;
  2723. // $flow-disable-line
  2724. parent = parent._original;
  2725. }
  2726. var isCompiled = isTrue(options._compiled);
  2727. var needNormalization = !isCompiled;
  2728. this.data = data;
  2729. this.props = props;
  2730. this.children = children;
  2731. this.parent = parent;
  2732. this.listeners = data.on || emptyObject;
  2733. this.injections = resolveInject(options.inject, parent);
  2734. this.slots = function () {
  2735. if (!this$1.$slots) {
  2736. normalizeScopedSlots(
  2737. data.scopedSlots,
  2738. this$1.$slots = resolveSlots(children, parent)
  2739. );
  2740. }
  2741. return this$1.$slots
  2742. };
  2743. Object.defineProperty(this, 'scopedSlots', ({
  2744. enumerable: true,
  2745. get: function get () {
  2746. return normalizeScopedSlots(data.scopedSlots, this.slots())
  2747. }
  2748. }));
  2749. // support for compiled functional template
  2750. if (isCompiled) {
  2751. // exposing $options for renderStatic()
  2752. this.$options = options;
  2753. // pre-resolve slots for renderSlot()
  2754. this.$slots = this.slots();
  2755. this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
  2756. }
  2757. if (options._scopeId) {
  2758. this._c = function (a, b, c, d) {
  2759. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  2760. if (vnode && !Array.isArray(vnode)) {
  2761. vnode.fnScopeId = options._scopeId;
  2762. vnode.fnContext = parent;
  2763. }
  2764. return vnode
  2765. };
  2766. } else {
  2767. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  2768. }
  2769. }
  2770. installRenderHelpers(FunctionalRenderContext.prototype);
  2771. function createFunctionalComponent (
  2772. Ctor,
  2773. propsData,
  2774. data,
  2775. contextVm,
  2776. children
  2777. ) {
  2778. var options = Ctor.options;
  2779. var props = {};
  2780. var propOptions = options.props;
  2781. if (isDef(propOptions)) {
  2782. for (var key in propOptions) {
  2783. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  2784. }
  2785. } else {
  2786. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  2787. if (isDef(data.props)) { mergeProps(props, data.props); }
  2788. }
  2789. var renderContext = new FunctionalRenderContext(
  2790. data,
  2791. props,
  2792. children,
  2793. contextVm,
  2794. Ctor
  2795. );
  2796. var vnode = options.render.call(null, renderContext._c, renderContext);
  2797. if (vnode instanceof VNode) {
  2798. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  2799. } else if (Array.isArray(vnode)) {
  2800. var vnodes = normalizeChildren(vnode) || [];
  2801. var res = new Array(vnodes.length);
  2802. for (var i = 0; i < vnodes.length; i++) {
  2803. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  2804. }
  2805. return res
  2806. }
  2807. }
  2808. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  2809. // #7817 clone node before setting fnContext, otherwise if the node is reused
  2810. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  2811. // that should not be matched to match.
  2812. var clone = cloneVNode(vnode);
  2813. clone.fnContext = contextVm;
  2814. clone.fnOptions = options;
  2815. {
  2816. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  2817. }
  2818. if (data.slot) {
  2819. (clone.data || (clone.data = {})).slot = data.slot;
  2820. }
  2821. return clone
  2822. }
  2823. function mergeProps (to, from) {
  2824. for (var key in from) {
  2825. to[camelize(key)] = from[key];
  2826. }
  2827. }
  2828. /* */
  2829. /* */
  2830. /* */
  2831. /* */
  2832. // inline hooks to be invoked on component VNodes during patch
  2833. var componentVNodeHooks = {
  2834. init: function init (vnode, hydrating) {
  2835. if (
  2836. vnode.componentInstance &&
  2837. !vnode.componentInstance._isDestroyed &&
  2838. vnode.data.keepAlive
  2839. ) {
  2840. // kept-alive components, treat as a patch
  2841. var mountedNode = vnode; // work around flow
  2842. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  2843. } else {
  2844. var child = vnode.componentInstance = createComponentInstanceForVnode(
  2845. vnode,
  2846. activeInstance
  2847. );
  2848. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  2849. }
  2850. },
  2851. prepatch: function prepatch (oldVnode, vnode) {
  2852. var options = vnode.componentOptions;
  2853. var child = vnode.componentInstance = oldVnode.componentInstance;
  2854. updateChildComponent(
  2855. child,
  2856. options.propsData, // updated props
  2857. options.listeners, // updated listeners
  2858. vnode, // new parent vnode
  2859. options.children // new children
  2860. );
  2861. },
  2862. insert: function insert (vnode) {
  2863. var context = vnode.context;
  2864. var componentInstance = vnode.componentInstance;
  2865. if (!componentInstance._isMounted) {
  2866. componentInstance._isMounted = true;
  2867. callHook(componentInstance, 'mounted');
  2868. }
  2869. if (vnode.data.keepAlive) {
  2870. if (context._isMounted) {
  2871. // vue-router#1212
  2872. // During updates, a kept-alive component's child components may
  2873. // change, so directly walking the tree here may call activated hooks
  2874. // on incorrect children. Instead we push them into a queue which will
  2875. // be processed after the whole patch process ended.
  2876. queueActivatedComponent(componentInstance);
  2877. } else {
  2878. activateChildComponent(componentInstance, true /* direct */);
  2879. }
  2880. }
  2881. },
  2882. destroy: function destroy (vnode) {
  2883. var componentInstance = vnode.componentInstance;
  2884. if (!componentInstance._isDestroyed) {
  2885. if (!vnode.data.keepAlive) {
  2886. componentInstance.$destroy();
  2887. } else {
  2888. deactivateChildComponent(componentInstance, true /* direct */);
  2889. }
  2890. }
  2891. }
  2892. };
  2893. var hooksToMerge = Object.keys(componentVNodeHooks);
  2894. function createComponent (
  2895. Ctor,
  2896. data,
  2897. context,
  2898. children,
  2899. tag
  2900. ) {
  2901. if (isUndef(Ctor)) {
  2902. return
  2903. }
  2904. var baseCtor = context.$options._base;
  2905. // plain options object: turn it into a constructor
  2906. if (isObject(Ctor)) {
  2907. Ctor = baseCtor.extend(Ctor);
  2908. }
  2909. // if at this stage it's not a constructor or an async component factory,
  2910. // reject.
  2911. if (typeof Ctor !== 'function') {
  2912. {
  2913. warn(("Invalid Component definition: " + (String(Ctor))), context);
  2914. }
  2915. return
  2916. }
  2917. // async component
  2918. var asyncFactory;
  2919. if (isUndef(Ctor.cid)) {
  2920. asyncFactory = Ctor;
  2921. Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
  2922. if (Ctor === undefined) {
  2923. // return a placeholder node for async component, which is rendered
  2924. // as a comment node but preserves all the raw information for the node.
  2925. // the information will be used for async server-rendering and hydration.
  2926. return createAsyncPlaceholder(
  2927. asyncFactory,
  2928. data,
  2929. context,
  2930. children,
  2931. tag
  2932. )
  2933. }
  2934. }
  2935. data = data || {};
  2936. // resolve constructor options in case global mixins are applied after
  2937. // component constructor creation
  2938. resolveConstructorOptions(Ctor);
  2939. // transform component v-model data into props & events
  2940. if (isDef(data.model)) {
  2941. transformModel(Ctor.options, data);
  2942. }
  2943. // extract props
  2944. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  2945. // functional component
  2946. if (isTrue(Ctor.options.functional)) {
  2947. return createFunctionalComponent(Ctor, propsData, data, context, children)
  2948. }
  2949. // extract listeners, since these needs to be treated as
  2950. // child component listeners instead of DOM listeners
  2951. var listeners = data.on;
  2952. // replace with listeners with .native modifier
  2953. // so it gets processed during parent component patch.
  2954. data.on = data.nativeOn;
  2955. if (isTrue(Ctor.options.abstract)) {
  2956. // abstract components do not keep anything
  2957. // other than props & listeners & slot
  2958. // work around flow
  2959. var slot = data.slot;
  2960. data = {};
  2961. if (slot) {
  2962. data.slot = slot;
  2963. }
  2964. }
  2965. // install component management hooks onto the placeholder node
  2966. installComponentHooks(data);
  2967. // return a placeholder vnode
  2968. var name = Ctor.options.name || tag;
  2969. var vnode = new VNode(
  2970. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  2971. data, undefined, undefined, undefined, context,
  2972. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  2973. asyncFactory
  2974. );
  2975. return vnode
  2976. }
  2977. function createComponentInstanceForVnode (
  2978. // we know it's MountedComponentVNode but flow doesn't
  2979. vnode,
  2980. // activeInstance in lifecycle state
  2981. parent
  2982. ) {
  2983. var options = {
  2984. _isComponent: true,
  2985. _parentVnode: vnode,
  2986. parent: parent
  2987. };
  2988. // check inline-template render functions
  2989. var inlineTemplate = vnode.data.inlineTemplate;
  2990. if (isDef(inlineTemplate)) {
  2991. options.render = inlineTemplate.render;
  2992. options.staticRenderFns = inlineTemplate.staticRenderFns;
  2993. }
  2994. return new vnode.componentOptions.Ctor(options)
  2995. }
  2996. function installComponentHooks (data) {
  2997. var hooks = data.hook || (data.hook = {});
  2998. for (var i = 0; i < hooksToMerge.length; i++) {
  2999. var key = hooksToMerge[i];
  3000. var existing = hooks[key];
  3001. var toMerge = componentVNodeHooks[key];
  3002. if (existing !== toMerge && !(existing && existing._merged)) {
  3003. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  3004. }
  3005. }
  3006. }
  3007. function mergeHook$1 (f1, f2) {
  3008. var merged = function (a, b) {
  3009. // flow complains about extra args which is why we use any
  3010. f1(a, b);
  3011. f2(a, b);
  3012. };
  3013. merged._merged = true;
  3014. return merged
  3015. }
  3016. // transform component v-model info (value and callback) into
  3017. // prop and event handler respectively.
  3018. function transformModel (options, data) {
  3019. var prop = (options.model && options.model.prop) || 'value';
  3020. var event = (options.model && options.model.event) || 'input'
  3021. ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
  3022. var on = data.on || (data.on = {});
  3023. var existing = on[event];
  3024. var callback = data.model.callback;
  3025. if (isDef(existing)) {
  3026. if (
  3027. Array.isArray(existing)
  3028. ? existing.indexOf(callback) === -1
  3029. : existing !== callback
  3030. ) {
  3031. on[event] = [callback].concat(existing);
  3032. }
  3033. } else {
  3034. on[event] = callback;
  3035. }
  3036. }
  3037. /* */
  3038. var SIMPLE_NORMALIZE = 1;
  3039. var ALWAYS_NORMALIZE = 2;
  3040. // wrapper function for providing a more flexible interface
  3041. // without getting yelled at by flow
  3042. function createElement (
  3043. context,
  3044. tag,
  3045. data,
  3046. children,
  3047. normalizationType,
  3048. alwaysNormalize
  3049. ) {
  3050. if (Array.isArray(data) || isPrimitive(data)) {
  3051. normalizationType = children;
  3052. children = data;
  3053. data = undefined;
  3054. }
  3055. if (isTrue(alwaysNormalize)) {
  3056. normalizationType = ALWAYS_NORMALIZE;
  3057. }
  3058. return _createElement(context, tag, data, children, normalizationType)
  3059. }
  3060. function _createElement (
  3061. context,
  3062. tag,
  3063. data,
  3064. children,
  3065. normalizationType
  3066. ) {
  3067. if (isDef(data) && isDef((data).__ob__)) {
  3068. warn(
  3069. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  3070. 'Always create fresh vnode data objects in each render!',
  3071. context
  3072. );
  3073. return createEmptyVNode()
  3074. }
  3075. // object syntax in v-bind
  3076. if (isDef(data) && isDef(data.is)) {
  3077. tag = data.is;
  3078. }
  3079. if (!tag) {
  3080. // in case of component :is set to falsy value
  3081. return createEmptyVNode()
  3082. }
  3083. // warn against non-primitive key
  3084. if (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 (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. {
  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. }
  3206. }
  3207. var currentRenderingInstance = null;
  3208. function renderMixin (Vue) {
  3209. // install runtime convenience helpers
  3210. installRenderHelpers(Vue.prototype);
  3211. Vue.prototype.$nextTick = function (fn) {
  3212. return nextTick(fn, this)
  3213. };
  3214. Vue.prototype._render = function () {
  3215. var vm = this;
  3216. var ref = vm.$options;
  3217. var render = ref.render;
  3218. var _parentVnode = ref._parentVnode;
  3219. if (_parentVnode) {
  3220. vm.$scopedSlots = normalizeScopedSlots(
  3221. _parentVnode.data.scopedSlots,
  3222. vm.$slots,
  3223. vm.$scopedSlots
  3224. );
  3225. }
  3226. // set parent vnode. this allows render functions to have access
  3227. // to the data on the placeholder node.
  3228. vm.$vnode = _parentVnode;
  3229. // render self
  3230. var vnode;
  3231. try {
  3232. // There's no need to maintain a stack because all render fns are called
  3233. // separately from one another. Nested component's render fns are called
  3234. // when parent component is patched.
  3235. currentRenderingInstance = vm;
  3236. vnode = render.call(vm._renderProxy, vm.$createElement);
  3237. } catch (e) {
  3238. handleError(e, vm, "render");
  3239. // return error render result,
  3240. // or previous vnode to prevent render error causing blank component
  3241. /* istanbul ignore else */
  3242. if (vm.$options.renderError) {
  3243. try {
  3244. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  3245. } catch (e) {
  3246. handleError(e, vm, "renderError");
  3247. vnode = vm._vnode;
  3248. }
  3249. } else {
  3250. vnode = vm._vnode;
  3251. }
  3252. } finally {
  3253. currentRenderingInstance = null;
  3254. }
  3255. // if the returned array contains only a single node, allow it
  3256. if (Array.isArray(vnode) && vnode.length === 1) {
  3257. vnode = vnode[0];
  3258. }
  3259. // return empty vnode in case the render function errored out
  3260. if (!(vnode instanceof VNode)) {
  3261. if (Array.isArray(vnode)) {
  3262. warn(
  3263. 'Multiple root nodes returned from render function. Render function ' +
  3264. 'should return a single root node.',
  3265. vm
  3266. );
  3267. }
  3268. vnode = createEmptyVNode();
  3269. }
  3270. // set parent
  3271. vnode.parent = _parentVnode;
  3272. return vnode
  3273. };
  3274. }
  3275. /* */
  3276. function ensureCtor (comp, base) {
  3277. if (
  3278. comp.__esModule ||
  3279. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  3280. ) {
  3281. comp = comp.default;
  3282. }
  3283. return isObject(comp)
  3284. ? base.extend(comp)
  3285. : comp
  3286. }
  3287. function createAsyncPlaceholder (
  3288. factory,
  3289. data,
  3290. context,
  3291. children,
  3292. tag
  3293. ) {
  3294. var node = createEmptyVNode();
  3295. node.asyncFactory = factory;
  3296. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  3297. return node
  3298. }
  3299. function resolveAsyncComponent (
  3300. factory,
  3301. baseCtor
  3302. ) {
  3303. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  3304. return factory.errorComp
  3305. }
  3306. if (isDef(factory.resolved)) {
  3307. return factory.resolved
  3308. }
  3309. var owner = currentRenderingInstance;
  3310. if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) {
  3311. // already pending
  3312. factory.owners.push(owner);
  3313. }
  3314. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  3315. return factory.loadingComp
  3316. }
  3317. if (owner && !isDef(factory.owners)) {
  3318. var owners = factory.owners = [owner];
  3319. var sync = true;
  3320. var timerLoading = null;
  3321. var timerTimeout = null
  3322. ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); });
  3323. var forceRender = function (renderCompleted) {
  3324. for (var i = 0, l = owners.length; i < l; i++) {
  3325. (owners[i]).$forceUpdate();
  3326. }
  3327. if (renderCompleted) {
  3328. owners.length = 0;
  3329. if (timerLoading !== null) {
  3330. clearTimeout(timerLoading);
  3331. timerLoading = null;
  3332. }
  3333. if (timerTimeout !== null) {
  3334. clearTimeout(timerTimeout);
  3335. timerTimeout = null;
  3336. }
  3337. }
  3338. };
  3339. var resolve = once(function (res) {
  3340. // cache resolved
  3341. factory.resolved = ensureCtor(res, baseCtor);
  3342. // invoke callbacks only if this is not a synchronous resolve
  3343. // (async resolves are shimmed as synchronous during SSR)
  3344. if (!sync) {
  3345. forceRender(true);
  3346. } else {
  3347. owners.length = 0;
  3348. }
  3349. });
  3350. var reject = once(function (reason) {
  3351. warn(
  3352. "Failed to resolve async component: " + (String(factory)) +
  3353. (reason ? ("\nReason: " + reason) : '')
  3354. );
  3355. if (isDef(factory.errorComp)) {
  3356. factory.error = true;
  3357. forceRender(true);
  3358. }
  3359. });
  3360. var res = factory(resolve, reject);
  3361. if (isObject(res)) {
  3362. if (isPromise(res)) {
  3363. // () => Promise
  3364. if (isUndef(factory.resolved)) {
  3365. res.then(resolve, reject);
  3366. }
  3367. } else if (isPromise(res.component)) {
  3368. res.component.then(resolve, reject);
  3369. if (isDef(res.error)) {
  3370. factory.errorComp = ensureCtor(res.error, baseCtor);
  3371. }
  3372. if (isDef(res.loading)) {
  3373. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  3374. if (res.delay === 0) {
  3375. factory.loading = true;
  3376. } else {
  3377. timerLoading = setTimeout(function () {
  3378. timerLoading = null;
  3379. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  3380. factory.loading = true;
  3381. forceRender(false);
  3382. }
  3383. }, res.delay || 200);
  3384. }
  3385. }
  3386. if (isDef(res.timeout)) {
  3387. timerTimeout = setTimeout(function () {
  3388. timerTimeout = null;
  3389. if (isUndef(factory.resolved)) {
  3390. reject(
  3391. "timeout (" + (res.timeout) + "ms)"
  3392. );
  3393. }
  3394. }, res.timeout);
  3395. }
  3396. }
  3397. }
  3398. sync = false;
  3399. // return in case resolved synchronously
  3400. return factory.loading
  3401. ? factory.loadingComp
  3402. : factory.resolved
  3403. }
  3404. }
  3405. /* */
  3406. function getFirstComponentChild (children) {
  3407. if (Array.isArray(children)) {
  3408. for (var i = 0; i < children.length; i++) {
  3409. var c = children[i];
  3410. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  3411. return c
  3412. }
  3413. }
  3414. }
  3415. }
  3416. /* */
  3417. /* */
  3418. function initEvents (vm) {
  3419. vm._events = Object.create(null);
  3420. vm._hasHookEvent = false;
  3421. // init parent attached events
  3422. var listeners = vm.$options._parentListeners;
  3423. if (listeners) {
  3424. updateComponentListeners(vm, listeners);
  3425. }
  3426. }
  3427. var target;
  3428. function add (event, fn) {
  3429. target.$on(event, fn);
  3430. }
  3431. function remove$1 (event, fn) {
  3432. target.$off(event, fn);
  3433. }
  3434. function createOnceHandler (event, fn) {
  3435. var _target = target;
  3436. return function onceHandler () {
  3437. var res = fn.apply(null, arguments);
  3438. if (res !== null) {
  3439. _target.$off(event, onceHandler);
  3440. }
  3441. }
  3442. }
  3443. function updateComponentListeners (
  3444. vm,
  3445. listeners,
  3446. oldListeners
  3447. ) {
  3448. target = vm;
  3449. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  3450. target = undefined;
  3451. }
  3452. function eventsMixin (Vue) {
  3453. var hookRE = /^hook:/;
  3454. Vue.prototype.$on = function (event, fn) {
  3455. var vm = this;
  3456. if (Array.isArray(event)) {
  3457. for (var i = 0, l = event.length; i < l; i++) {
  3458. vm.$on(event[i], fn);
  3459. }
  3460. } else {
  3461. (vm._events[event] || (vm._events[event] = [])).push(fn);
  3462. // optimize hook:event cost by using a boolean flag marked at registration
  3463. // instead of a hash lookup
  3464. if (hookRE.test(event)) {
  3465. vm._hasHookEvent = true;
  3466. }
  3467. }
  3468. return vm
  3469. };
  3470. Vue.prototype.$once = function (event, fn) {
  3471. var vm = this;
  3472. function on () {
  3473. vm.$off(event, on);
  3474. fn.apply(vm, arguments);
  3475. }
  3476. on.fn = fn;
  3477. vm.$on(event, on);
  3478. return vm
  3479. };
  3480. Vue.prototype.$off = function (event, fn) {
  3481. var vm = this;
  3482. // all
  3483. if (!arguments.length) {
  3484. vm._events = Object.create(null);
  3485. return vm
  3486. }
  3487. // array of events
  3488. if (Array.isArray(event)) {
  3489. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  3490. vm.$off(event[i$1], fn);
  3491. }
  3492. return vm
  3493. }
  3494. // specific event
  3495. var cbs = vm._events[event];
  3496. if (!cbs) {
  3497. return vm
  3498. }
  3499. if (!fn) {
  3500. vm._events[event] = null;
  3501. return vm
  3502. }
  3503. // specific handler
  3504. var cb;
  3505. var i = cbs.length;
  3506. while (i--) {
  3507. cb = cbs[i];
  3508. if (cb === fn || cb.fn === fn) {
  3509. cbs.splice(i, 1);
  3510. break
  3511. }
  3512. }
  3513. return vm
  3514. };
  3515. Vue.prototype.$emit = function (event) {
  3516. var vm = this;
  3517. {
  3518. var lowerCaseEvent = event.toLowerCase();
  3519. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  3520. tip(
  3521. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  3522. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  3523. "Note that HTML attributes are case-insensitive and you cannot use " +
  3524. "v-on to listen to camelCase events when using in-DOM templates. " +
  3525. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  3526. );
  3527. }
  3528. }
  3529. var cbs = vm._events[event];
  3530. if (cbs) {
  3531. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  3532. var args = toArray(arguments, 1);
  3533. var info = "event handler for \"" + event + "\"";
  3534. for (var i = 0, l = cbs.length; i < l; i++) {
  3535. invokeWithErrorHandling(cbs[i], vm, args, vm, info);
  3536. }
  3537. }
  3538. return vm
  3539. };
  3540. }
  3541. /* */
  3542. var activeInstance = null;
  3543. var isUpdatingChildComponent = false;
  3544. function setActiveInstance(vm) {
  3545. var prevActiveInstance = activeInstance;
  3546. activeInstance = vm;
  3547. return function () {
  3548. activeInstance = prevActiveInstance;
  3549. }
  3550. }
  3551. function initLifecycle (vm) {
  3552. var options = vm.$options;
  3553. // locate first non-abstract parent
  3554. var parent = options.parent;
  3555. if (parent && !options.abstract) {
  3556. while (parent.$options.abstract && parent.$parent) {
  3557. parent = parent.$parent;
  3558. }
  3559. parent.$children.push(vm);
  3560. }
  3561. vm.$parent = parent;
  3562. vm.$root = parent ? parent.$root : vm;
  3563. vm.$children = [];
  3564. vm.$refs = {};
  3565. vm._watcher = null;
  3566. vm._inactive = null;
  3567. vm._directInactive = false;
  3568. vm._isMounted = false;
  3569. vm._isDestroyed = false;
  3570. vm._isBeingDestroyed = false;
  3571. }
  3572. function lifecycleMixin (Vue) {
  3573. Vue.prototype._update = function (vnode, hydrating) {
  3574. var vm = this;
  3575. var prevEl = vm.$el;
  3576. var prevVnode = vm._vnode;
  3577. var restoreActiveInstance = setActiveInstance(vm);
  3578. vm._vnode = vnode;
  3579. // Vue.prototype.__patch__ is injected in entry points
  3580. // based on the rendering backend used.
  3581. if (!prevVnode) {
  3582. // initial render
  3583. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  3584. } else {
  3585. // updates
  3586. vm.$el = vm.__patch__(prevVnode, vnode);
  3587. }
  3588. restoreActiveInstance();
  3589. // update __vue__ reference
  3590. if (prevEl) {
  3591. prevEl.__vue__ = null;
  3592. }
  3593. if (vm.$el) {
  3594. vm.$el.__vue__ = vm;
  3595. }
  3596. // if parent is an HOC, update its $el as well
  3597. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  3598. vm.$parent.$el = vm.$el;
  3599. }
  3600. // updated hook is called by the scheduler to ensure that children are
  3601. // updated in a parent's updated hook.
  3602. };
  3603. Vue.prototype.$forceUpdate = function () {
  3604. var vm = this;
  3605. if (vm._watcher) {
  3606. vm._watcher.update();
  3607. }
  3608. };
  3609. Vue.prototype.$destroy = function () {
  3610. var vm = this;
  3611. if (vm._isBeingDestroyed) {
  3612. return
  3613. }
  3614. callHook(vm, 'beforeDestroy');
  3615. vm._isBeingDestroyed = true;
  3616. // remove self from parent
  3617. var parent = vm.$parent;
  3618. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  3619. remove(parent.$children, vm);
  3620. }
  3621. // teardown watchers
  3622. if (vm._watcher) {
  3623. vm._watcher.teardown();
  3624. }
  3625. var i = vm._watchers.length;
  3626. while (i--) {
  3627. vm._watchers[i].teardown();
  3628. }
  3629. // remove reference from data ob
  3630. // frozen object may not have observer.
  3631. if (vm._data.__ob__) {
  3632. vm._data.__ob__.vmCount--;
  3633. }
  3634. // call the last hook...
  3635. vm._isDestroyed = true;
  3636. // invoke destroy hooks on current rendered tree
  3637. vm.__patch__(vm._vnode, null);
  3638. // fire destroyed hook
  3639. callHook(vm, 'destroyed');
  3640. // turn off all instance listeners.
  3641. vm.$off();
  3642. // remove __vue__ reference
  3643. if (vm.$el) {
  3644. vm.$el.__vue__ = null;
  3645. }
  3646. // release circular reference (#6759)
  3647. if (vm.$vnode) {
  3648. vm.$vnode.parent = null;
  3649. }
  3650. };
  3651. }
  3652. function mountComponent (
  3653. vm,
  3654. el,
  3655. hydrating
  3656. ) {
  3657. vm.$el = el;
  3658. if (!vm.$options.render) {
  3659. vm.$options.render = createEmptyVNode;
  3660. {
  3661. /* istanbul ignore if */
  3662. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  3663. vm.$options.el || el) {
  3664. warn(
  3665. 'You are using the runtime-only build of Vue where the template ' +
  3666. 'compiler is not available. Either pre-compile the templates into ' +
  3667. 'render functions, or use the compiler-included build.',
  3668. vm
  3669. );
  3670. } else {
  3671. warn(
  3672. 'Failed to mount component: template or render function not defined.',
  3673. vm
  3674. );
  3675. }
  3676. }
  3677. }
  3678. callHook(vm, 'beforeMount');
  3679. var updateComponent;
  3680. /* istanbul ignore if */
  3681. if (config.performance && mark) {
  3682. updateComponent = function () {
  3683. var name = vm._name;
  3684. var id = vm._uid;
  3685. var startTag = "vue-perf-start:" + id;
  3686. var endTag = "vue-perf-end:" + id;
  3687. mark(startTag);
  3688. var vnode = vm._render();
  3689. mark(endTag);
  3690. measure(("vue " + name + " render"), startTag, endTag);
  3691. mark(startTag);
  3692. vm._update(vnode, hydrating);
  3693. mark(endTag);
  3694. measure(("vue " + name + " patch"), startTag, endTag);
  3695. };
  3696. } else {
  3697. updateComponent = function () {
  3698. vm._update(vm._render(), hydrating);
  3699. };
  3700. }
  3701. // we set this to vm._watcher inside the watcher's constructor
  3702. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  3703. // component's mounted hook), which relies on vm._watcher being already defined
  3704. new Watcher(vm, updateComponent, noop, {
  3705. before: function before () {
  3706. if (vm._isMounted && !vm._isDestroyed) {
  3707. callHook(vm, 'beforeUpdate');
  3708. }
  3709. }
  3710. }, true /* isRenderWatcher */);
  3711. hydrating = false;
  3712. // manually mounted instance, call mounted on self
  3713. // mounted is called for render-created child components in its inserted hook
  3714. if (vm.$vnode == null) {
  3715. vm._isMounted = true;
  3716. callHook(vm, 'mounted');
  3717. }
  3718. return vm
  3719. }
  3720. function updateChildComponent (
  3721. vm,
  3722. propsData,
  3723. listeners,
  3724. parentVnode,
  3725. renderChildren
  3726. ) {
  3727. {
  3728. isUpdatingChildComponent = true;
  3729. }
  3730. // determine whether component has slot children
  3731. // we need to do this before overwriting $options._renderChildren.
  3732. // check if there are dynamic scopedSlots (hand-written or compiled but with
  3733. // dynamic slot names). Static scoped slots compiled from template has the
  3734. // "$stable" marker.
  3735. var newScopedSlots = parentVnode.data.scopedSlots;
  3736. var oldScopedSlots = vm.$scopedSlots;
  3737. var hasDynamicScopedSlot = !!(
  3738. (newScopedSlots && !newScopedSlots.$stable) ||
  3739. (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) ||
  3740. (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) ||
  3741. (!newScopedSlots && vm.$scopedSlots.$key)
  3742. );
  3743. // Any static slot children from the parent may have changed during parent's
  3744. // update. Dynamic scoped slots may also have changed. In such cases, a forced
  3745. // update is necessary to ensure correctness.
  3746. var needsForceUpdate = !!(
  3747. renderChildren || // has new static slots
  3748. vm.$options._renderChildren || // has old static slots
  3749. hasDynamicScopedSlot
  3750. );
  3751. vm.$options._parentVnode = parentVnode;
  3752. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  3753. if (vm._vnode) { // update child tree's parent
  3754. vm._vnode.parent = parentVnode;
  3755. }
  3756. vm.$options._renderChildren = renderChildren;
  3757. // update $attrs and $listeners hash
  3758. // these are also reactive so they may trigger child update if the child
  3759. // used them during render
  3760. vm.$attrs = parentVnode.data.attrs || emptyObject;
  3761. vm.$listeners = listeners || emptyObject;
  3762. // update props
  3763. if (propsData && vm.$options.props) {
  3764. toggleObserving(false);
  3765. var props = vm._props;
  3766. var propKeys = vm.$options._propKeys || [];
  3767. for (var i = 0; i < propKeys.length; i++) {
  3768. var key = propKeys[i];
  3769. var propOptions = vm.$options.props; // wtf flow?
  3770. props[key] = validateProp(key, propOptions, propsData, vm);
  3771. }
  3772. toggleObserving(true);
  3773. // keep a copy of raw propsData
  3774. vm.$options.propsData = propsData;
  3775. }
  3776. // update listeners
  3777. listeners = listeners || emptyObject;
  3778. var oldListeners = vm.$options._parentListeners;
  3779. vm.$options._parentListeners = listeners;
  3780. updateComponentListeners(vm, listeners, oldListeners);
  3781. // resolve slots + force update if has children
  3782. if (needsForceUpdate) {
  3783. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  3784. vm.$forceUpdate();
  3785. }
  3786. {
  3787. isUpdatingChildComponent = false;
  3788. }
  3789. }
  3790. function isInInactiveTree (vm) {
  3791. while (vm && (vm = vm.$parent)) {
  3792. if (vm._inactive) { return true }
  3793. }
  3794. return false
  3795. }
  3796. function activateChildComponent (vm, direct) {
  3797. if (direct) {
  3798. vm._directInactive = false;
  3799. if (isInInactiveTree(vm)) {
  3800. return
  3801. }
  3802. } else if (vm._directInactive) {
  3803. return
  3804. }
  3805. if (vm._inactive || vm._inactive === null) {
  3806. vm._inactive = false;
  3807. for (var i = 0; i < vm.$children.length; i++) {
  3808. activateChildComponent(vm.$children[i]);
  3809. }
  3810. callHook(vm, 'activated');
  3811. }
  3812. }
  3813. function deactivateChildComponent (vm, direct) {
  3814. if (direct) {
  3815. vm._directInactive = true;
  3816. if (isInInactiveTree(vm)) {
  3817. return
  3818. }
  3819. }
  3820. if (!vm._inactive) {
  3821. vm._inactive = true;
  3822. for (var i = 0; i < vm.$children.length; i++) {
  3823. deactivateChildComponent(vm.$children[i]);
  3824. }
  3825. callHook(vm, 'deactivated');
  3826. }
  3827. }
  3828. function callHook (vm, hook) {
  3829. // #7573 disable dep collection when invoking lifecycle hooks
  3830. pushTarget();
  3831. var handlers = vm.$options[hook];
  3832. var info = hook + " hook";
  3833. if (handlers) {
  3834. for (var i = 0, j = handlers.length; i < j; i++) {
  3835. invokeWithErrorHandling(handlers[i], vm, null, vm, info);
  3836. }
  3837. }
  3838. if (vm._hasHookEvent) {
  3839. vm.$emit('hook:' + hook);
  3840. }
  3841. popTarget();
  3842. }
  3843. /* */
  3844. var MAX_UPDATE_COUNT = 100;
  3845. var queue = [];
  3846. var activatedChildren = [];
  3847. var has = {};
  3848. var circular = {};
  3849. var waiting = false;
  3850. var flushing = false;
  3851. var index = 0;
  3852. /**
  3853. * Reset the scheduler's state.
  3854. */
  3855. function resetSchedulerState () {
  3856. index = queue.length = activatedChildren.length = 0;
  3857. has = {};
  3858. {
  3859. circular = {};
  3860. }
  3861. waiting = flushing = false;
  3862. }
  3863. // Async edge case #6566 requires saving the timestamp when event listeners are
  3864. // attached. However, calling performance.now() has a perf overhead especially
  3865. // if the page has thousands of event listeners. Instead, we take a timestamp
  3866. // every time the scheduler flushes and use that for all event listeners
  3867. // attached during that flush.
  3868. var currentFlushTimestamp = 0;
  3869. // Async edge case fix requires storing an event listener's attach timestamp.
  3870. var getNow = Date.now;
  3871. // Determine what event timestamp the browser is using. Annoyingly, the
  3872. // timestamp can either be hi-res (relative to page load) or low-res
  3873. // (relative to UNIX epoch), so in order to compare time we have to use the
  3874. // same timestamp type when saving the flush timestamp.
  3875. // All IE versions use low-res event timestamps, and have problematic clock
  3876. // implementations (#9632)
  3877. if (inBrowser && !isIE) {
  3878. var performance = window.performance;
  3879. if (
  3880. performance &&
  3881. typeof performance.now === 'function' &&
  3882. getNow() > document.createEvent('Event').timeStamp
  3883. ) {
  3884. // if the event timestamp, although evaluated AFTER the Date.now(), is
  3885. // smaller than it, it means the event is using a hi-res timestamp,
  3886. // and we need to use the hi-res version for event listener timestamps as
  3887. // well.
  3888. getNow = function () { return performance.now(); };
  3889. }
  3890. }
  3891. /**
  3892. * Flush both queues and run the watchers.
  3893. */
  3894. function flushSchedulerQueue () {
  3895. currentFlushTimestamp = getNow();
  3896. flushing = true;
  3897. var watcher, id;
  3898. // Sort queue before flush.
  3899. // This ensures that:
  3900. // 1. Components are updated from parent to child. (because parent is always
  3901. // created before the child)
  3902. // 2. A component's user watchers are run before its render watcher (because
  3903. // user watchers are created before the render watcher)
  3904. // 3. If a component is destroyed during a parent component's watcher run,
  3905. // its watchers can be skipped.
  3906. queue.sort(function (a, b) { return a.id - b.id; });
  3907. // do not cache length because more watchers might be pushed
  3908. // as we run existing watchers
  3909. for (index = 0; index < queue.length; index++) {
  3910. watcher = queue[index];
  3911. if (watcher.before) {
  3912. watcher.before();
  3913. }
  3914. id = watcher.id;
  3915. has[id] = null;
  3916. watcher.run();
  3917. // in dev build, check and stop circular updates.
  3918. if (has[id] != null) {
  3919. circular[id] = (circular[id] || 0) + 1;
  3920. if (circular[id] > MAX_UPDATE_COUNT) {
  3921. warn(
  3922. 'You may have an infinite update loop ' + (
  3923. watcher.user
  3924. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  3925. : "in a component render function."
  3926. ),
  3927. watcher.vm
  3928. );
  3929. break
  3930. }
  3931. }
  3932. }
  3933. // keep copies of post queues before resetting state
  3934. var activatedQueue = activatedChildren.slice();
  3935. var updatedQueue = queue.slice();
  3936. resetSchedulerState();
  3937. // call component updated and activated hooks
  3938. callActivatedHooks(activatedQueue);
  3939. callUpdatedHooks(updatedQueue);
  3940. // devtool hook
  3941. /* istanbul ignore if */
  3942. if (devtools && config.devtools) {
  3943. devtools.emit('flush');
  3944. }
  3945. }
  3946. function callUpdatedHooks (queue) {
  3947. var i = queue.length;
  3948. while (i--) {
  3949. var watcher = queue[i];
  3950. var vm = watcher.vm;
  3951. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  3952. callHook(vm, 'updated');
  3953. }
  3954. }
  3955. }
  3956. /**
  3957. * Queue a kept-alive component that was activated during patch.
  3958. * The queue will be processed after the entire tree has been patched.
  3959. */
  3960. function queueActivatedComponent (vm) {
  3961. // setting _inactive to false here so that a render function can
  3962. // rely on checking whether it's in an inactive tree (e.g. router-view)
  3963. vm._inactive = false;
  3964. activatedChildren.push(vm);
  3965. }
  3966. function callActivatedHooks (queue) {
  3967. for (var i = 0; i < queue.length; i++) {
  3968. queue[i]._inactive = true;
  3969. activateChildComponent(queue[i], true /* true */);
  3970. }
  3971. }
  3972. /**
  3973. * Push a watcher into the watcher queue.
  3974. * Jobs with duplicate IDs will be skipped unless it's
  3975. * pushed when the queue is being flushed.
  3976. */
  3977. function queueWatcher (watcher) {
  3978. var id = watcher.id;
  3979. if (has[id] == null) {
  3980. has[id] = true;
  3981. if (!flushing) {
  3982. queue.push(watcher);
  3983. } else {
  3984. // if already flushing, splice the watcher based on its id
  3985. // if already past its id, it will be run next immediately.
  3986. var i = queue.length - 1;
  3987. while (i > index && queue[i].id > watcher.id) {
  3988. i--;
  3989. }
  3990. queue.splice(i + 1, 0, watcher);
  3991. }
  3992. // queue the flush
  3993. if (!waiting) {
  3994. waiting = true;
  3995. if (!config.async) {
  3996. flushSchedulerQueue();
  3997. return
  3998. }
  3999. nextTick(flushSchedulerQueue);
  4000. }
  4001. }
  4002. }
  4003. /* */
  4004. var uid$2 = 0;
  4005. /**
  4006. * A watcher parses an expression, collects dependencies,
  4007. * and fires callback when the expression value changes.
  4008. * This is used for both the $watch() api and directives.
  4009. */
  4010. var Watcher = function Watcher (
  4011. vm,
  4012. expOrFn,
  4013. cb,
  4014. options,
  4015. isRenderWatcher
  4016. ) {
  4017. this.vm = vm;
  4018. if (isRenderWatcher) {
  4019. vm._watcher = this;
  4020. }
  4021. vm._watchers.push(this);
  4022. // options
  4023. if (options) {
  4024. this.deep = !!options.deep;
  4025. this.user = !!options.user;
  4026. this.lazy = !!options.lazy;
  4027. this.sync = !!options.sync;
  4028. this.before = options.before;
  4029. } else {
  4030. this.deep = this.user = this.lazy = this.sync = false;
  4031. }
  4032. this.cb = cb;
  4033. this.id = ++uid$2; // uid for batching
  4034. this.active = true;
  4035. this.dirty = this.lazy; // for lazy watchers
  4036. this.deps = [];
  4037. this.newDeps = [];
  4038. this.depIds = new _Set();
  4039. this.newDepIds = new _Set();
  4040. this.expression = expOrFn.toString();
  4041. // parse expression for getter
  4042. if (typeof expOrFn === 'function') {
  4043. this.getter = expOrFn;
  4044. } else {
  4045. this.getter = parsePath(expOrFn);
  4046. if (!this.getter) {
  4047. this.getter = noop;
  4048. warn(
  4049. "Failed watching path: \"" + expOrFn + "\" " +
  4050. 'Watcher only accepts simple dot-delimited paths. ' +
  4051. 'For full control, use a function instead.',
  4052. vm
  4053. );
  4054. }
  4055. }
  4056. this.value = this.lazy
  4057. ? undefined
  4058. : this.get();
  4059. };
  4060. /**
  4061. * Evaluate the getter, and re-collect dependencies.
  4062. */
  4063. Watcher.prototype.get = function get () {
  4064. pushTarget(this);
  4065. var value;
  4066. var vm = this.vm;
  4067. try {
  4068. value = this.getter.call(vm, vm);
  4069. } catch (e) {
  4070. if (this.user) {
  4071. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  4072. } else {
  4073. throw e
  4074. }
  4075. } finally {
  4076. // "touch" every property so they are all tracked as
  4077. // dependencies for deep watching
  4078. if (this.deep) {
  4079. traverse(value);
  4080. }
  4081. popTarget();
  4082. this.cleanupDeps();
  4083. }
  4084. return value
  4085. };
  4086. /**
  4087. * Add a dependency to this directive.
  4088. */
  4089. Watcher.prototype.addDep = function addDep (dep) {
  4090. var id = dep.id;
  4091. if (!this.newDepIds.has(id)) {
  4092. this.newDepIds.add(id);
  4093. this.newDeps.push(dep);
  4094. if (!this.depIds.has(id)) {
  4095. dep.addSub(this);
  4096. }
  4097. }
  4098. };
  4099. /**
  4100. * Clean up for dependency collection.
  4101. */
  4102. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  4103. var i = this.deps.length;
  4104. while (i--) {
  4105. var dep = this.deps[i];
  4106. if (!this.newDepIds.has(dep.id)) {
  4107. dep.removeSub(this);
  4108. }
  4109. }
  4110. var tmp = this.depIds;
  4111. this.depIds = this.newDepIds;
  4112. this.newDepIds = tmp;
  4113. this.newDepIds.clear();
  4114. tmp = this.deps;
  4115. this.deps = this.newDeps;
  4116. this.newDeps = tmp;
  4117. this.newDeps.length = 0;
  4118. };
  4119. /**
  4120. * Subscriber interface.
  4121. * Will be called when a dependency changes.
  4122. */
  4123. Watcher.prototype.update = function update () {
  4124. /* istanbul ignore else */
  4125. if (this.lazy) {
  4126. this.dirty = true;
  4127. } else if (this.sync) {
  4128. this.run();
  4129. } else {
  4130. queueWatcher(this);
  4131. }
  4132. };
  4133. /**
  4134. * Scheduler job interface.
  4135. * Will be called by the scheduler.
  4136. */
  4137. Watcher.prototype.run = function run () {
  4138. if (this.active) {
  4139. var value = this.get();
  4140. if (
  4141. value !== this.value ||
  4142. // Deep watchers and watchers on Object/Arrays should fire even
  4143. // when the value is the same, because the value may
  4144. // have mutated.
  4145. isObject(value) ||
  4146. this.deep
  4147. ) {
  4148. // set new value
  4149. var oldValue = this.value;
  4150. this.value = value;
  4151. if (this.user) {
  4152. var info = "callback for watcher \"" + (this.expression) + "\"";
  4153. invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info);
  4154. } else {
  4155. this.cb.call(this.vm, value, oldValue);
  4156. }
  4157. }
  4158. }
  4159. };
  4160. /**
  4161. * Evaluate the value of the watcher.
  4162. * This only gets called for lazy watchers.
  4163. */
  4164. Watcher.prototype.evaluate = function evaluate () {
  4165. this.value = this.get();
  4166. this.dirty = false;
  4167. };
  4168. /**
  4169. * Depend on all deps collected by this watcher.
  4170. */
  4171. Watcher.prototype.depend = function depend () {
  4172. var i = this.deps.length;
  4173. while (i--) {
  4174. this.deps[i].depend();
  4175. }
  4176. };
  4177. /**
  4178. * Remove self from all dependencies' subscriber list.
  4179. */
  4180. Watcher.prototype.teardown = function teardown () {
  4181. if (this.active) {
  4182. // remove self from vm's watcher list
  4183. // this is a somewhat expensive operation so we skip it
  4184. // if the vm is being destroyed.
  4185. if (!this.vm._isBeingDestroyed) {
  4186. remove(this.vm._watchers, this);
  4187. }
  4188. var i = this.deps.length;
  4189. while (i--) {
  4190. this.deps[i].removeSub(this);
  4191. }
  4192. this.active = false;
  4193. }
  4194. };
  4195. /* */
  4196. var sharedPropertyDefinition = {
  4197. enumerable: true,
  4198. configurable: true,
  4199. get: noop,
  4200. set: noop
  4201. };
  4202. function proxy (target, sourceKey, key) {
  4203. sharedPropertyDefinition.get = function proxyGetter () {
  4204. return this[sourceKey][key]
  4205. };
  4206. sharedPropertyDefinition.set = function proxySetter (val) {
  4207. this[sourceKey][key] = val;
  4208. };
  4209. Object.defineProperty(target, key, sharedPropertyDefinition);
  4210. }
  4211. function initState (vm) {
  4212. vm._watchers = [];
  4213. var opts = vm.$options;
  4214. if (opts.props) { initProps(vm, opts.props); }
  4215. if (opts.methods) { initMethods(vm, opts.methods); }
  4216. if (opts.data) {
  4217. initData(vm);
  4218. } else {
  4219. observe(vm._data = {}, true /* asRootData */);
  4220. }
  4221. if (opts.computed) { initComputed(vm, opts.computed); }
  4222. if (opts.watch && opts.watch !== nativeWatch) {
  4223. initWatch(vm, opts.watch);
  4224. }
  4225. }
  4226. function initProps (vm, propsOptions) {
  4227. var propsData = vm.$options.propsData || {};
  4228. var props = vm._props = {};
  4229. // cache prop keys so that future props updates can iterate using Array
  4230. // instead of dynamic object key enumeration.
  4231. var keys = vm.$options._propKeys = [];
  4232. var isRoot = !vm.$parent;
  4233. // root instance props should be converted
  4234. if (!isRoot) {
  4235. toggleObserving(false);
  4236. }
  4237. var loop = function ( key ) {
  4238. keys.push(key);
  4239. var value = validateProp(key, propsOptions, propsData, vm);
  4240. /* istanbul ignore else */
  4241. {
  4242. var hyphenatedKey = hyphenate(key);
  4243. if (isReservedAttribute(hyphenatedKey) ||
  4244. config.isReservedAttr(hyphenatedKey)) {
  4245. warn(
  4246. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  4247. vm
  4248. );
  4249. }
  4250. defineReactive$$1(props, key, value, function () {
  4251. if (!isRoot && !isUpdatingChildComponent) {
  4252. warn(
  4253. "Avoid mutating a prop directly since the value will be " +
  4254. "overwritten whenever the parent component re-renders. " +
  4255. "Instead, use a data or computed property based on the prop's " +
  4256. "value. Prop being mutated: \"" + key + "\"",
  4257. vm
  4258. );
  4259. }
  4260. });
  4261. }
  4262. // static props are already proxied on the component's prototype
  4263. // during Vue.extend(). We only need to proxy props defined at
  4264. // instantiation here.
  4265. if (!(key in vm)) {
  4266. proxy(vm, "_props", key);
  4267. }
  4268. };
  4269. for (var key in propsOptions) loop( key );
  4270. toggleObserving(true);
  4271. }
  4272. function initData (vm) {
  4273. var data = vm.$options.data;
  4274. data = vm._data = typeof data === 'function'
  4275. ? getData(data, vm)
  4276. : data || {};
  4277. if (!isPlainObject(data)) {
  4278. data = {};
  4279. warn(
  4280. 'data functions should return an object:\n' +
  4281. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  4282. vm
  4283. );
  4284. }
  4285. // proxy data on instance
  4286. var keys = Object.keys(data);
  4287. var props = vm.$options.props;
  4288. var methods = vm.$options.methods;
  4289. var i = keys.length;
  4290. while (i--) {
  4291. var key = keys[i];
  4292. {
  4293. if (methods && hasOwn(methods, key)) {
  4294. warn(
  4295. ("Method \"" + key + "\" has already been defined as a data property."),
  4296. vm
  4297. );
  4298. }
  4299. }
  4300. if (props && hasOwn(props, key)) {
  4301. warn(
  4302. "The data property \"" + key + "\" is already declared as a prop. " +
  4303. "Use prop default value instead.",
  4304. vm
  4305. );
  4306. } else if (!isReserved(key)) {
  4307. proxy(vm, "_data", key);
  4308. }
  4309. }
  4310. // observe data
  4311. observe(data, true /* asRootData */);
  4312. }
  4313. function getData (data, vm) {
  4314. // #7573 disable dep collection when invoking data getters
  4315. pushTarget();
  4316. try {
  4317. return data.call(vm, vm)
  4318. } catch (e) {
  4319. handleError(e, vm, "data()");
  4320. return {}
  4321. } finally {
  4322. popTarget();
  4323. }
  4324. }
  4325. var computedWatcherOptions = { lazy: true };
  4326. function initComputed (vm, computed) {
  4327. // $flow-disable-line
  4328. var watchers = vm._computedWatchers = Object.create(null);
  4329. // computed properties are just getters during SSR
  4330. var isSSR = isServerRendering();
  4331. for (var key in computed) {
  4332. var userDef = computed[key];
  4333. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  4334. if (getter == null) {
  4335. warn(
  4336. ("Getter is missing for computed property \"" + key + "\"."),
  4337. vm
  4338. );
  4339. }
  4340. if (!isSSR) {
  4341. // create internal watcher for the computed property.
  4342. watchers[key] = new Watcher(
  4343. vm,
  4344. getter || noop,
  4345. noop,
  4346. computedWatcherOptions
  4347. );
  4348. }
  4349. // component-defined computed properties are already defined on the
  4350. // component prototype. We only need to define computed properties defined
  4351. // at instantiation here.
  4352. if (!(key in vm)) {
  4353. defineComputed(vm, key, userDef);
  4354. } else {
  4355. if (key in vm.$data) {
  4356. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  4357. } else if (vm.$options.props && key in vm.$options.props) {
  4358. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  4359. } else if (vm.$options.methods && key in vm.$options.methods) {
  4360. warn(("The computed property \"" + key + "\" is already defined as a method."), vm);
  4361. }
  4362. }
  4363. }
  4364. }
  4365. function defineComputed (
  4366. target,
  4367. key,
  4368. userDef
  4369. ) {
  4370. var shouldCache = !isServerRendering();
  4371. if (typeof userDef === 'function') {
  4372. sharedPropertyDefinition.get = shouldCache
  4373. ? createComputedGetter(key)
  4374. : createGetterInvoker(userDef);
  4375. sharedPropertyDefinition.set = noop;
  4376. } else {
  4377. sharedPropertyDefinition.get = userDef.get
  4378. ? shouldCache && userDef.cache !== false
  4379. ? createComputedGetter(key)
  4380. : createGetterInvoker(userDef.get)
  4381. : noop;
  4382. sharedPropertyDefinition.set = userDef.set || noop;
  4383. }
  4384. if (sharedPropertyDefinition.set === noop) {
  4385. sharedPropertyDefinition.set = function () {
  4386. warn(
  4387. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  4388. this
  4389. );
  4390. };
  4391. }
  4392. Object.defineProperty(target, key, sharedPropertyDefinition);
  4393. }
  4394. function createComputedGetter (key) {
  4395. return function computedGetter () {
  4396. var watcher = this._computedWatchers && this._computedWatchers[key];
  4397. if (watcher) {
  4398. if (watcher.dirty) {
  4399. watcher.evaluate();
  4400. }
  4401. if (Dep.target) {
  4402. watcher.depend();
  4403. }
  4404. return watcher.value
  4405. }
  4406. }
  4407. }
  4408. function createGetterInvoker(fn) {
  4409. return function computedGetter () {
  4410. return fn.call(this, this)
  4411. }
  4412. }
  4413. function initMethods (vm, methods) {
  4414. var props = vm.$options.props;
  4415. for (var key in methods) {
  4416. {
  4417. if (typeof methods[key] !== 'function') {
  4418. warn(
  4419. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  4420. "Did you reference the function correctly?",
  4421. vm
  4422. );
  4423. }
  4424. if (props && hasOwn(props, key)) {
  4425. warn(
  4426. ("Method \"" + key + "\" has already been defined as a prop."),
  4427. vm
  4428. );
  4429. }
  4430. if ((key in vm) && isReserved(key)) {
  4431. warn(
  4432. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  4433. "Avoid defining component methods that start with _ or $."
  4434. );
  4435. }
  4436. }
  4437. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  4438. }
  4439. }
  4440. function initWatch (vm, watch) {
  4441. for (var key in watch) {
  4442. var handler = watch[key];
  4443. if (Array.isArray(handler)) {
  4444. for (var i = 0; i < handler.length; i++) {
  4445. createWatcher(vm, key, handler[i]);
  4446. }
  4447. } else {
  4448. createWatcher(vm, key, handler);
  4449. }
  4450. }
  4451. }
  4452. function createWatcher (
  4453. vm,
  4454. expOrFn,
  4455. handler,
  4456. options
  4457. ) {
  4458. if (isPlainObject(handler)) {
  4459. options = handler;
  4460. handler = handler.handler;
  4461. }
  4462. if (typeof handler === 'string') {
  4463. handler = vm[handler];
  4464. }
  4465. return vm.$watch(expOrFn, handler, options)
  4466. }
  4467. function stateMixin (Vue) {
  4468. // flow somehow has problems with directly declared definition object
  4469. // when using Object.defineProperty, so we have to procedurally build up
  4470. // the object here.
  4471. var dataDef = {};
  4472. dataDef.get = function () { return this._data };
  4473. var propsDef = {};
  4474. propsDef.get = function () { return this._props };
  4475. {
  4476. dataDef.set = function () {
  4477. warn(
  4478. 'Avoid replacing instance root $data. ' +
  4479. 'Use nested data properties instead.',
  4480. this
  4481. );
  4482. };
  4483. propsDef.set = function () {
  4484. warn("$props is readonly.", this);
  4485. };
  4486. }
  4487. Object.defineProperty(Vue.prototype, '$data', dataDef);
  4488. Object.defineProperty(Vue.prototype, '$props', propsDef);
  4489. Vue.prototype.$set = set;
  4490. Vue.prototype.$delete = del;
  4491. Vue.prototype.$watch = function (
  4492. expOrFn,
  4493. cb,
  4494. options
  4495. ) {
  4496. var vm = this;
  4497. if (isPlainObject(cb)) {
  4498. return createWatcher(vm, expOrFn, cb, options)
  4499. }
  4500. options = options || {};
  4501. options.user = true;
  4502. var watcher = new Watcher(vm, expOrFn, cb, options);
  4503. if (options.immediate) {
  4504. var info = "callback for immediate watcher \"" + (watcher.expression) + "\"";
  4505. pushTarget();
  4506. invokeWithErrorHandling(cb, vm, [watcher.value], vm, info);
  4507. popTarget();
  4508. }
  4509. return function unwatchFn () {
  4510. watcher.teardown();
  4511. }
  4512. };
  4513. }
  4514. /* */
  4515. var uid$3 = 0;
  4516. function initMixin (Vue) {
  4517. Vue.prototype._init = function (options) {
  4518. var vm = this;
  4519. // a uid
  4520. vm._uid = uid$3++;
  4521. var startTag, endTag;
  4522. /* istanbul ignore if */
  4523. if (config.performance && mark) {
  4524. startTag = "vue-perf-start:" + (vm._uid);
  4525. endTag = "vue-perf-end:" + (vm._uid);
  4526. mark(startTag);
  4527. }
  4528. // a flag to avoid this being observed
  4529. vm._isVue = true;
  4530. // merge options
  4531. if (options && options._isComponent) {
  4532. // optimize internal component instantiation
  4533. // since dynamic options merging is pretty slow, and none of the
  4534. // internal component options needs special treatment.
  4535. initInternalComponent(vm, options);
  4536. } else {
  4537. vm.$options = mergeOptions(
  4538. resolveConstructorOptions(vm.constructor),
  4539. options || {},
  4540. vm
  4541. );
  4542. }
  4543. /* istanbul ignore else */
  4544. {
  4545. initProxy(vm);
  4546. }
  4547. // expose real self
  4548. vm._self = vm;
  4549. initLifecycle(vm);
  4550. initEvents(vm);
  4551. initRender(vm);
  4552. callHook(vm, 'beforeCreate');
  4553. initInjections(vm); // resolve injections before data/props
  4554. initState(vm);
  4555. initProvide(vm); // resolve provide after data/props
  4556. callHook(vm, 'created');
  4557. /* istanbul ignore if */
  4558. if (config.performance && mark) {
  4559. vm._name = formatComponentName(vm, false);
  4560. mark(endTag);
  4561. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  4562. }
  4563. if (vm.$options.el) {
  4564. vm.$mount(vm.$options.el);
  4565. }
  4566. };
  4567. }
  4568. function initInternalComponent (vm, options) {
  4569. var opts = vm.$options = Object.create(vm.constructor.options);
  4570. // doing this because it's faster than dynamic enumeration.
  4571. var parentVnode = options._parentVnode;
  4572. opts.parent = options.parent;
  4573. opts._parentVnode = parentVnode;
  4574. var vnodeComponentOptions = parentVnode.componentOptions;
  4575. opts.propsData = vnodeComponentOptions.propsData;
  4576. opts._parentListeners = vnodeComponentOptions.listeners;
  4577. opts._renderChildren = vnodeComponentOptions.children;
  4578. opts._componentTag = vnodeComponentOptions.tag;
  4579. if (options.render) {
  4580. opts.render = options.render;
  4581. opts.staticRenderFns = options.staticRenderFns;
  4582. }
  4583. }
  4584. function resolveConstructorOptions (Ctor) {
  4585. var options = Ctor.options;
  4586. if (Ctor.super) {
  4587. var superOptions = resolveConstructorOptions(Ctor.super);
  4588. var cachedSuperOptions = Ctor.superOptions;
  4589. if (superOptions !== cachedSuperOptions) {
  4590. // super option changed,
  4591. // need to resolve new options.
  4592. Ctor.superOptions = superOptions;
  4593. // check if there are any late-modified/attached options (#4976)
  4594. var modifiedOptions = resolveModifiedOptions(Ctor);
  4595. // update base extend options
  4596. if (modifiedOptions) {
  4597. extend(Ctor.extendOptions, modifiedOptions);
  4598. }
  4599. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4600. if (options.name) {
  4601. options.components[options.name] = Ctor;
  4602. }
  4603. }
  4604. }
  4605. return options
  4606. }
  4607. function resolveModifiedOptions (Ctor) {
  4608. var modified;
  4609. var latest = Ctor.options;
  4610. var sealed = Ctor.sealedOptions;
  4611. for (var key in latest) {
  4612. if (latest[key] !== sealed[key]) {
  4613. if (!modified) { modified = {}; }
  4614. modified[key] = latest[key];
  4615. }
  4616. }
  4617. return modified
  4618. }
  4619. function Vue (options) {
  4620. if (!(this instanceof Vue)
  4621. ) {
  4622. warn('Vue is a constructor and should be called with the `new` keyword');
  4623. }
  4624. this._init(options);
  4625. }
  4626. initMixin(Vue);
  4627. stateMixin(Vue);
  4628. eventsMixin(Vue);
  4629. lifecycleMixin(Vue);
  4630. renderMixin(Vue);
  4631. /* */
  4632. function initUse (Vue) {
  4633. Vue.use = function (plugin) {
  4634. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  4635. if (installedPlugins.indexOf(plugin) > -1) {
  4636. return this
  4637. }
  4638. // additional parameters
  4639. var args = toArray(arguments, 1);
  4640. args.unshift(this);
  4641. if (typeof plugin.install === 'function') {
  4642. plugin.install.apply(plugin, args);
  4643. } else if (typeof plugin === 'function') {
  4644. plugin.apply(null, args);
  4645. }
  4646. installedPlugins.push(plugin);
  4647. return this
  4648. };
  4649. }
  4650. /* */
  4651. function initMixin$1 (Vue) {
  4652. Vue.mixin = function (mixin) {
  4653. this.options = mergeOptions(this.options, mixin);
  4654. return this
  4655. };
  4656. }
  4657. /* */
  4658. function initExtend (Vue) {
  4659. /**
  4660. * Each instance constructor, including Vue, has a unique
  4661. * cid. This enables us to create wrapped "child
  4662. * constructors" for prototypal inheritance and cache them.
  4663. */
  4664. Vue.cid = 0;
  4665. var cid = 1;
  4666. /**
  4667. * Class inheritance
  4668. */
  4669. Vue.extend = function (extendOptions) {
  4670. extendOptions = extendOptions || {};
  4671. var Super = this;
  4672. var SuperId = Super.cid;
  4673. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  4674. if (cachedCtors[SuperId]) {
  4675. return cachedCtors[SuperId]
  4676. }
  4677. var name = extendOptions.name || Super.options.name;
  4678. if (name) {
  4679. validateComponentName(name);
  4680. }
  4681. var Sub = function VueComponent (options) {
  4682. this._init(options);
  4683. };
  4684. Sub.prototype = Object.create(Super.prototype);
  4685. Sub.prototype.constructor = Sub;
  4686. Sub.cid = cid++;
  4687. Sub.options = mergeOptions(
  4688. Super.options,
  4689. extendOptions
  4690. );
  4691. Sub['super'] = Super;
  4692. // For props and computed properties, we define the proxy getters on
  4693. // the Vue instances at extension time, on the extended prototype. This
  4694. // avoids Object.defineProperty calls for each instance created.
  4695. if (Sub.options.props) {
  4696. initProps$1(Sub);
  4697. }
  4698. if (Sub.options.computed) {
  4699. initComputed$1(Sub);
  4700. }
  4701. // allow further extension/mixin/plugin usage
  4702. Sub.extend = Super.extend;
  4703. Sub.mixin = Super.mixin;
  4704. Sub.use = Super.use;
  4705. // create asset registers, so extended classes
  4706. // can have their private assets too.
  4707. ASSET_TYPES.forEach(function (type) {
  4708. Sub[type] = Super[type];
  4709. });
  4710. // enable recursive self-lookup
  4711. if (name) {
  4712. Sub.options.components[name] = Sub;
  4713. }
  4714. // keep a reference to the super options at extension time.
  4715. // later at instantiation we can check if Super's options have
  4716. // been updated.
  4717. Sub.superOptions = Super.options;
  4718. Sub.extendOptions = extendOptions;
  4719. Sub.sealedOptions = extend({}, Sub.options);
  4720. // cache constructor
  4721. cachedCtors[SuperId] = Sub;
  4722. return Sub
  4723. };
  4724. }
  4725. function initProps$1 (Comp) {
  4726. var props = Comp.options.props;
  4727. for (var key in props) {
  4728. proxy(Comp.prototype, "_props", key);
  4729. }
  4730. }
  4731. function initComputed$1 (Comp) {
  4732. var computed = Comp.options.computed;
  4733. for (var key in computed) {
  4734. defineComputed(Comp.prototype, key, computed[key]);
  4735. }
  4736. }
  4737. /* */
  4738. function initAssetRegisters (Vue) {
  4739. /**
  4740. * Create asset registration methods.
  4741. */
  4742. ASSET_TYPES.forEach(function (type) {
  4743. Vue[type] = function (
  4744. id,
  4745. definition
  4746. ) {
  4747. if (!definition) {
  4748. return this.options[type + 's'][id]
  4749. } else {
  4750. /* istanbul ignore if */
  4751. if (type === 'component') {
  4752. validateComponentName(id);
  4753. }
  4754. if (type === 'component' && isPlainObject(definition)) {
  4755. definition.name = definition.name || id;
  4756. definition = this.options._base.extend(definition);
  4757. }
  4758. if (type === 'directive' && typeof definition === 'function') {
  4759. definition = { bind: definition, update: definition };
  4760. }
  4761. this.options[type + 's'][id] = definition;
  4762. return definition
  4763. }
  4764. };
  4765. });
  4766. }
  4767. /* */
  4768. function getComponentName (opts) {
  4769. return opts && (opts.Ctor.options.name || opts.tag)
  4770. }
  4771. function matches (pattern, name) {
  4772. if (Array.isArray(pattern)) {
  4773. return pattern.indexOf(name) > -1
  4774. } else if (typeof pattern === 'string') {
  4775. return pattern.split(',').indexOf(name) > -1
  4776. } else if (isRegExp(pattern)) {
  4777. return pattern.test(name)
  4778. }
  4779. /* istanbul ignore next */
  4780. return false
  4781. }
  4782. function pruneCache (keepAliveInstance, filter) {
  4783. var cache = keepAliveInstance.cache;
  4784. var keys = keepAliveInstance.keys;
  4785. var _vnode = keepAliveInstance._vnode;
  4786. for (var key in cache) {
  4787. var entry = cache[key];
  4788. if (entry) {
  4789. var name = entry.name;
  4790. if (name && !filter(name)) {
  4791. pruneCacheEntry(cache, key, keys, _vnode);
  4792. }
  4793. }
  4794. }
  4795. }
  4796. function pruneCacheEntry (
  4797. cache,
  4798. key,
  4799. keys,
  4800. current
  4801. ) {
  4802. var entry = cache[key];
  4803. if (entry && (!current || entry.tag !== current.tag)) {
  4804. entry.componentInstance.$destroy();
  4805. }
  4806. cache[key] = null;
  4807. remove(keys, key);
  4808. }
  4809. var patternTypes = [String, RegExp, Array];
  4810. var KeepAlive = {
  4811. name: 'keep-alive',
  4812. abstract: true,
  4813. props: {
  4814. include: patternTypes,
  4815. exclude: patternTypes,
  4816. max: [String, Number]
  4817. },
  4818. methods: {
  4819. cacheVNode: function cacheVNode() {
  4820. var ref = this;
  4821. var cache = ref.cache;
  4822. var keys = ref.keys;
  4823. var vnodeToCache = ref.vnodeToCache;
  4824. var keyToCache = ref.keyToCache;
  4825. if (vnodeToCache) {
  4826. var tag = vnodeToCache.tag;
  4827. var componentInstance = vnodeToCache.componentInstance;
  4828. var componentOptions = vnodeToCache.componentOptions;
  4829. cache[keyToCache] = {
  4830. name: getComponentName(componentOptions),
  4831. tag: tag,
  4832. componentInstance: componentInstance,
  4833. };
  4834. keys.push(keyToCache);
  4835. // prune oldest entry
  4836. if (this.max && keys.length > parseInt(this.max)) {
  4837. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  4838. }
  4839. this.vnodeToCache = null;
  4840. }
  4841. }
  4842. },
  4843. created: function created () {
  4844. this.cache = Object.create(null);
  4845. this.keys = [];
  4846. },
  4847. destroyed: function destroyed () {
  4848. for (var key in this.cache) {
  4849. pruneCacheEntry(this.cache, key, this.keys);
  4850. }
  4851. },
  4852. mounted: function mounted () {
  4853. var this$1 = this;
  4854. this.cacheVNode();
  4855. this.$watch('include', function (val) {
  4856. pruneCache(this$1, function (name) { return matches(val, name); });
  4857. });
  4858. this.$watch('exclude', function (val) {
  4859. pruneCache(this$1, function (name) { return !matches(val, name); });
  4860. });
  4861. },
  4862. updated: function updated () {
  4863. this.cacheVNode();
  4864. },
  4865. render: function render () {
  4866. var slot = this.$slots.default;
  4867. var vnode = getFirstComponentChild(slot);
  4868. var componentOptions = vnode && vnode.componentOptions;
  4869. if (componentOptions) {
  4870. // check pattern
  4871. var name = getComponentName(componentOptions);
  4872. var ref = this;
  4873. var include = ref.include;
  4874. var exclude = ref.exclude;
  4875. if (
  4876. // not included
  4877. (include && (!name || !matches(include, name))) ||
  4878. // excluded
  4879. (exclude && name && matches(exclude, name))
  4880. ) {
  4881. return vnode
  4882. }
  4883. var ref$1 = this;
  4884. var cache = ref$1.cache;
  4885. var keys = ref$1.keys;
  4886. var key = vnode.key == null
  4887. // same constructor may get registered as different local components
  4888. // so cid alone is not enough (#3269)
  4889. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  4890. : vnode.key;
  4891. if (cache[key]) {
  4892. vnode.componentInstance = cache[key].componentInstance;
  4893. // make current key freshest
  4894. remove(keys, key);
  4895. keys.push(key);
  4896. } else {
  4897. // delay setting the cache until update
  4898. this.vnodeToCache = vnode;
  4899. this.keyToCache = key;
  4900. }
  4901. vnode.data.keepAlive = true;
  4902. }
  4903. return vnode || (slot && slot[0])
  4904. }
  4905. };
  4906. var builtInComponents = {
  4907. KeepAlive: KeepAlive
  4908. };
  4909. /* */
  4910. function initGlobalAPI (Vue) {
  4911. // config
  4912. var configDef = {};
  4913. configDef.get = function () { return config; };
  4914. {
  4915. configDef.set = function () {
  4916. warn(
  4917. 'Do not replace the Vue.config object, set individual fields instead.'
  4918. );
  4919. };
  4920. }
  4921. Object.defineProperty(Vue, 'config', configDef);
  4922. // exposed util methods.
  4923. // NOTE: these are not considered part of the public API - avoid relying on
  4924. // them unless you are aware of the risk.
  4925. Vue.util = {
  4926. warn: warn,
  4927. extend: extend,
  4928. mergeOptions: mergeOptions,
  4929. defineReactive: defineReactive$$1
  4930. };
  4931. Vue.set = set;
  4932. Vue.delete = del;
  4933. Vue.nextTick = nextTick;
  4934. // 2.6 explicit observable API
  4935. Vue.observable = function (obj) {
  4936. observe(obj);
  4937. return obj
  4938. };
  4939. Vue.options = Object.create(null);
  4940. ASSET_TYPES.forEach(function (type) {
  4941. Vue.options[type + 's'] = Object.create(null);
  4942. });
  4943. // this is used to identify the "base" constructor to extend all plain-object
  4944. // components with in Weex's multi-instance scenarios.
  4945. Vue.options._base = Vue;
  4946. extend(Vue.options.components, builtInComponents);
  4947. initUse(Vue);
  4948. initMixin$1(Vue);
  4949. initExtend(Vue);
  4950. initAssetRegisters(Vue);
  4951. }
  4952. initGlobalAPI(Vue);
  4953. Object.defineProperty(Vue.prototype, '$isServer', {
  4954. get: isServerRendering
  4955. });
  4956. Object.defineProperty(Vue.prototype, '$ssrContext', {
  4957. get: function get () {
  4958. /* istanbul ignore next */
  4959. return this.$vnode && this.$vnode.ssrContext
  4960. }
  4961. });
  4962. // expose FunctionalRenderContext for ssr runtime helper installation
  4963. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  4964. value: FunctionalRenderContext
  4965. });
  4966. Vue.version = '2.6.14';
  4967. /* */
  4968. // these are reserved for web because they are directly compiled away
  4969. // during template compilation
  4970. var isReservedAttr = makeMap('style,class');
  4971. // attributes that should be using props for binding
  4972. var acceptValue = makeMap('input,textarea,option,select,progress');
  4973. var mustUseProp = function (tag, type, attr) {
  4974. return (
  4975. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  4976. (attr === 'selected' && tag === 'option') ||
  4977. (attr === 'checked' && tag === 'input') ||
  4978. (attr === 'muted' && tag === 'video')
  4979. )
  4980. };
  4981. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  4982. var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only');
  4983. var convertEnumeratedValue = function (key, value) {
  4984. return isFalsyAttrValue(value) || value === 'false'
  4985. ? 'false'
  4986. // allow arbitrary string value for contenteditable
  4987. : key === 'contenteditable' && isValidContentEditableValue(value)
  4988. ? value
  4989. : 'true'
  4990. };
  4991. var isBooleanAttr = makeMap(
  4992. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  4993. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  4994. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  4995. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  4996. 'required,reversed,scoped,seamless,selected,sortable,' +
  4997. 'truespeed,typemustmatch,visible'
  4998. );
  4999. var xlinkNS = 'http://www.w3.org/1999/xlink';
  5000. var isXlink = function (name) {
  5001. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  5002. };
  5003. var getXlinkProp = function (name) {
  5004. return isXlink(name) ? name.slice(6, name.length) : ''
  5005. };
  5006. var isFalsyAttrValue = function (val) {
  5007. return val == null || val === false
  5008. };
  5009. /* */
  5010. function genClassForVnode (vnode) {
  5011. var data = vnode.data;
  5012. var parentNode = vnode;
  5013. var childNode = vnode;
  5014. while (isDef(childNode.componentInstance)) {
  5015. childNode = childNode.componentInstance._vnode;
  5016. if (childNode && childNode.data) {
  5017. data = mergeClassData(childNode.data, data);
  5018. }
  5019. }
  5020. while (isDef(parentNode = parentNode.parent)) {
  5021. if (parentNode && parentNode.data) {
  5022. data = mergeClassData(data, parentNode.data);
  5023. }
  5024. }
  5025. return renderClass(data.staticClass, data.class)
  5026. }
  5027. function mergeClassData (child, parent) {
  5028. return {
  5029. staticClass: concat(child.staticClass, parent.staticClass),
  5030. class: isDef(child.class)
  5031. ? [child.class, parent.class]
  5032. : parent.class
  5033. }
  5034. }
  5035. function renderClass (
  5036. staticClass,
  5037. dynamicClass
  5038. ) {
  5039. if (isDef(staticClass) || isDef(dynamicClass)) {
  5040. return concat(staticClass, stringifyClass(dynamicClass))
  5041. }
  5042. /* istanbul ignore next */
  5043. return ''
  5044. }
  5045. function concat (a, b) {
  5046. return a ? b ? (a + ' ' + b) : a : (b || '')
  5047. }
  5048. function stringifyClass (value) {
  5049. if (Array.isArray(value)) {
  5050. return stringifyArray(value)
  5051. }
  5052. if (isObject(value)) {
  5053. return stringifyObject(value)
  5054. }
  5055. if (typeof value === 'string') {
  5056. return value
  5057. }
  5058. /* istanbul ignore next */
  5059. return ''
  5060. }
  5061. function stringifyArray (value) {
  5062. var res = '';
  5063. var stringified;
  5064. for (var i = 0, l = value.length; i < l; i++) {
  5065. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  5066. if (res) { res += ' '; }
  5067. res += stringified;
  5068. }
  5069. }
  5070. return res
  5071. }
  5072. function stringifyObject (value) {
  5073. var res = '';
  5074. for (var key in value) {
  5075. if (value[key]) {
  5076. if (res) { res += ' '; }
  5077. res += key;
  5078. }
  5079. }
  5080. return res
  5081. }
  5082. /* */
  5083. var namespaceMap = {
  5084. svg: 'http://www.w3.org/2000/svg',
  5085. math: 'http://www.w3.org/1998/Math/MathML'
  5086. };
  5087. var isHTMLTag = makeMap(
  5088. 'html,body,base,head,link,meta,style,title,' +
  5089. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  5090. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  5091. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  5092. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  5093. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  5094. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  5095. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  5096. 'output,progress,select,textarea,' +
  5097. 'details,dialog,menu,menuitem,summary,' +
  5098. 'content,element,shadow,template,blockquote,iframe,tfoot'
  5099. );
  5100. // this map is intentionally selective, only covering SVG elements that may
  5101. // contain child elements.
  5102. var isSVG = makeMap(
  5103. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  5104. 'foreignobject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  5105. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  5106. true
  5107. );
  5108. var isPreTag = function (tag) { return tag === 'pre'; };
  5109. var isReservedTag = function (tag) {
  5110. return isHTMLTag(tag) || isSVG(tag)
  5111. };
  5112. function getTagNamespace (tag) {
  5113. if (isSVG(tag)) {
  5114. return 'svg'
  5115. }
  5116. // basic support for MathML
  5117. // note it doesn't support other MathML elements being component roots
  5118. if (tag === 'math') {
  5119. return 'math'
  5120. }
  5121. }
  5122. var unknownElementCache = Object.create(null);
  5123. function isUnknownElement (tag) {
  5124. /* istanbul ignore if */
  5125. if (!inBrowser) {
  5126. return true
  5127. }
  5128. if (isReservedTag(tag)) {
  5129. return false
  5130. }
  5131. tag = tag.toLowerCase();
  5132. /* istanbul ignore if */
  5133. if (unknownElementCache[tag] != null) {
  5134. return unknownElementCache[tag]
  5135. }
  5136. var el = document.createElement(tag);
  5137. if (tag.indexOf('-') > -1) {
  5138. // http://stackoverflow.com/a/28210364/1070244
  5139. return (unknownElementCache[tag] = (
  5140. el.constructor === window.HTMLUnknownElement ||
  5141. el.constructor === window.HTMLElement
  5142. ))
  5143. } else {
  5144. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  5145. }
  5146. }
  5147. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  5148. /* */
  5149. /**
  5150. * Query an element selector if it's not an element already.
  5151. */
  5152. function query (el) {
  5153. if (typeof el === 'string') {
  5154. var selected = document.querySelector(el);
  5155. if (!selected) {
  5156. warn(
  5157. 'Cannot find element: ' + el
  5158. );
  5159. return document.createElement('div')
  5160. }
  5161. return selected
  5162. } else {
  5163. return el
  5164. }
  5165. }
  5166. /* */
  5167. function createElement$1 (tagName, vnode) {
  5168. var elm = document.createElement(tagName);
  5169. if (tagName !== 'select') {
  5170. return elm
  5171. }
  5172. // false or null will remove the attribute but undefined will not
  5173. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  5174. elm.setAttribute('multiple', 'multiple');
  5175. }
  5176. return elm
  5177. }
  5178. function createElementNS (namespace, tagName) {
  5179. return document.createElementNS(namespaceMap[namespace], tagName)
  5180. }
  5181. function createTextNode (text) {
  5182. return document.createTextNode(text)
  5183. }
  5184. function createComment (text) {
  5185. return document.createComment(text)
  5186. }
  5187. function insertBefore (parentNode, newNode, referenceNode) {
  5188. parentNode.insertBefore(newNode, referenceNode);
  5189. }
  5190. function removeChild (node, child) {
  5191. node.removeChild(child);
  5192. }
  5193. function appendChild (node, child) {
  5194. node.appendChild(child);
  5195. }
  5196. function parentNode (node) {
  5197. return node.parentNode
  5198. }
  5199. function nextSibling (node) {
  5200. return node.nextSibling
  5201. }
  5202. function tagName (node) {
  5203. return node.tagName
  5204. }
  5205. function setTextContent (node, text) {
  5206. node.textContent = text;
  5207. }
  5208. function setStyleScope (node, scopeId) {
  5209. node.setAttribute(scopeId, '');
  5210. }
  5211. var nodeOps = /*#__PURE__*/Object.freeze({
  5212. createElement: createElement$1,
  5213. createElementNS: createElementNS,
  5214. createTextNode: createTextNode,
  5215. createComment: createComment,
  5216. insertBefore: insertBefore,
  5217. removeChild: removeChild,
  5218. appendChild: appendChild,
  5219. parentNode: parentNode,
  5220. nextSibling: nextSibling,
  5221. tagName: tagName,
  5222. setTextContent: setTextContent,
  5223. setStyleScope: setStyleScope
  5224. });
  5225. /* */
  5226. var ref = {
  5227. create: function create (_, vnode) {
  5228. registerRef(vnode);
  5229. },
  5230. update: function update (oldVnode, vnode) {
  5231. if (oldVnode.data.ref !== vnode.data.ref) {
  5232. registerRef(oldVnode, true);
  5233. registerRef(vnode);
  5234. }
  5235. },
  5236. destroy: function destroy (vnode) {
  5237. registerRef(vnode, true);
  5238. }
  5239. };
  5240. function registerRef (vnode, isRemoval) {
  5241. var key = vnode.data.ref;
  5242. if (!isDef(key)) { return }
  5243. var vm = vnode.context;
  5244. var ref = vnode.componentInstance || vnode.elm;
  5245. var refs = vm.$refs;
  5246. if (isRemoval) {
  5247. if (Array.isArray(refs[key])) {
  5248. remove(refs[key], ref);
  5249. } else if (refs[key] === ref) {
  5250. refs[key] = undefined;
  5251. }
  5252. } else {
  5253. if (vnode.data.refInFor) {
  5254. if (!Array.isArray(refs[key])) {
  5255. refs[key] = [ref];
  5256. } else if (refs[key].indexOf(ref) < 0) {
  5257. // $flow-disable-line
  5258. refs[key].push(ref);
  5259. }
  5260. } else {
  5261. refs[key] = ref;
  5262. }
  5263. }
  5264. }
  5265. /**
  5266. * Virtual DOM patching algorithm based on Snabbdom by
  5267. * Simon Friis Vindum (@paldepind)
  5268. * Licensed under the MIT License
  5269. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  5270. *
  5271. * modified by Evan You (@yyx990803)
  5272. *
  5273. * Not type-checking this because this file is perf-critical and the cost
  5274. * of making flow understand it is not worth it.
  5275. */
  5276. var emptyNode = new VNode('', {}, []);
  5277. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  5278. function sameVnode (a, b) {
  5279. return (
  5280. a.key === b.key &&
  5281. a.asyncFactory === b.asyncFactory && (
  5282. (
  5283. a.tag === b.tag &&
  5284. a.isComment === b.isComment &&
  5285. isDef(a.data) === isDef(b.data) &&
  5286. sameInputType(a, b)
  5287. ) || (
  5288. isTrue(a.isAsyncPlaceholder) &&
  5289. isUndef(b.asyncFactory.error)
  5290. )
  5291. )
  5292. )
  5293. }
  5294. function sameInputType (a, b) {
  5295. if (a.tag !== 'input') { return true }
  5296. var i;
  5297. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  5298. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  5299. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  5300. }
  5301. function createKeyToOldIdx (children, beginIdx, endIdx) {
  5302. var i, key;
  5303. var map = {};
  5304. for (i = beginIdx; i <= endIdx; ++i) {
  5305. key = children[i].key;
  5306. if (isDef(key)) { map[key] = i; }
  5307. }
  5308. return map
  5309. }
  5310. function createPatchFunction (backend) {
  5311. var i, j;
  5312. var cbs = {};
  5313. var modules = backend.modules;
  5314. var nodeOps = backend.nodeOps;
  5315. for (i = 0; i < hooks.length; ++i) {
  5316. cbs[hooks[i]] = [];
  5317. for (j = 0; j < modules.length; ++j) {
  5318. if (isDef(modules[j][hooks[i]])) {
  5319. cbs[hooks[i]].push(modules[j][hooks[i]]);
  5320. }
  5321. }
  5322. }
  5323. function emptyNodeAt (elm) {
  5324. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  5325. }
  5326. function createRmCb (childElm, listeners) {
  5327. function remove$$1 () {
  5328. if (--remove$$1.listeners === 0) {
  5329. removeNode(childElm);
  5330. }
  5331. }
  5332. remove$$1.listeners = listeners;
  5333. return remove$$1
  5334. }
  5335. function removeNode (el) {
  5336. var parent = nodeOps.parentNode(el);
  5337. // element may have already been removed due to v-html / v-text
  5338. if (isDef(parent)) {
  5339. nodeOps.removeChild(parent, el);
  5340. }
  5341. }
  5342. function isUnknownElement$$1 (vnode, inVPre) {
  5343. return (
  5344. !inVPre &&
  5345. !vnode.ns &&
  5346. !(
  5347. config.ignoredElements.length &&
  5348. config.ignoredElements.some(function (ignore) {
  5349. return isRegExp(ignore)
  5350. ? ignore.test(vnode.tag)
  5351. : ignore === vnode.tag
  5352. })
  5353. ) &&
  5354. config.isUnknownElement(vnode.tag)
  5355. )
  5356. }
  5357. var creatingElmInVPre = 0;
  5358. function createElm (
  5359. vnode,
  5360. insertedVnodeQueue,
  5361. parentElm,
  5362. refElm,
  5363. nested,
  5364. ownerArray,
  5365. index
  5366. ) {
  5367. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5368. // This vnode was used in a previous render!
  5369. // now it's used as a new node, overwriting its elm would cause
  5370. // potential patch errors down the road when it's used as an insertion
  5371. // reference node. Instead, we clone the node on-demand before creating
  5372. // associated DOM element for it.
  5373. vnode = ownerArray[index] = cloneVNode(vnode);
  5374. }
  5375. vnode.isRootInsert = !nested; // for transition enter check
  5376. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  5377. return
  5378. }
  5379. var data = vnode.data;
  5380. var children = vnode.children;
  5381. var tag = vnode.tag;
  5382. if (isDef(tag)) {
  5383. {
  5384. if (data && data.pre) {
  5385. creatingElmInVPre++;
  5386. }
  5387. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  5388. warn(
  5389. 'Unknown custom element: <' + tag + '> - did you ' +
  5390. 'register the component correctly? For recursive components, ' +
  5391. 'make sure to provide the "name" option.',
  5392. vnode.context
  5393. );
  5394. }
  5395. }
  5396. vnode.elm = vnode.ns
  5397. ? nodeOps.createElementNS(vnode.ns, tag)
  5398. : nodeOps.createElement(tag, vnode);
  5399. setScope(vnode);
  5400. /* istanbul ignore if */
  5401. {
  5402. createChildren(vnode, children, insertedVnodeQueue);
  5403. if (isDef(data)) {
  5404. invokeCreateHooks(vnode, insertedVnodeQueue);
  5405. }
  5406. insert(parentElm, vnode.elm, refElm);
  5407. }
  5408. if (data && data.pre) {
  5409. creatingElmInVPre--;
  5410. }
  5411. } else if (isTrue(vnode.isComment)) {
  5412. vnode.elm = nodeOps.createComment(vnode.text);
  5413. insert(parentElm, vnode.elm, refElm);
  5414. } else {
  5415. vnode.elm = nodeOps.createTextNode(vnode.text);
  5416. insert(parentElm, vnode.elm, refElm);
  5417. }
  5418. }
  5419. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5420. var i = vnode.data;
  5421. if (isDef(i)) {
  5422. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  5423. if (isDef(i = i.hook) && isDef(i = i.init)) {
  5424. i(vnode, false /* hydrating */);
  5425. }
  5426. // after calling the init hook, if the vnode is a child component
  5427. // it should've created a child instance and mounted it. the child
  5428. // component also has set the placeholder vnode's elm.
  5429. // in that case we can just return the element and be done.
  5430. if (isDef(vnode.componentInstance)) {
  5431. initComponent(vnode, insertedVnodeQueue);
  5432. insert(parentElm, vnode.elm, refElm);
  5433. if (isTrue(isReactivated)) {
  5434. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  5435. }
  5436. return true
  5437. }
  5438. }
  5439. }
  5440. function initComponent (vnode, insertedVnodeQueue) {
  5441. if (isDef(vnode.data.pendingInsert)) {
  5442. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  5443. vnode.data.pendingInsert = null;
  5444. }
  5445. vnode.elm = vnode.componentInstance.$el;
  5446. if (isPatchable(vnode)) {
  5447. invokeCreateHooks(vnode, insertedVnodeQueue);
  5448. setScope(vnode);
  5449. } else {
  5450. // empty component root.
  5451. // skip all element-related modules except for ref (#3455)
  5452. registerRef(vnode);
  5453. // make sure to invoke the insert hook
  5454. insertedVnodeQueue.push(vnode);
  5455. }
  5456. }
  5457. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5458. var i;
  5459. // hack for #4339: a reactivated component with inner transition
  5460. // does not trigger because the inner node's created hooks are not called
  5461. // again. It's not ideal to involve module-specific logic in here but
  5462. // there doesn't seem to be a better way to do it.
  5463. var innerNode = vnode;
  5464. while (innerNode.componentInstance) {
  5465. innerNode = innerNode.componentInstance._vnode;
  5466. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  5467. for (i = 0; i < cbs.activate.length; ++i) {
  5468. cbs.activate[i](emptyNode, innerNode);
  5469. }
  5470. insertedVnodeQueue.push(innerNode);
  5471. break
  5472. }
  5473. }
  5474. // unlike a newly created component,
  5475. // a reactivated keep-alive component doesn't insert itself
  5476. insert(parentElm, vnode.elm, refElm);
  5477. }
  5478. function insert (parent, elm, ref$$1) {
  5479. if (isDef(parent)) {
  5480. if (isDef(ref$$1)) {
  5481. if (nodeOps.parentNode(ref$$1) === parent) {
  5482. nodeOps.insertBefore(parent, elm, ref$$1);
  5483. }
  5484. } else {
  5485. nodeOps.appendChild(parent, elm);
  5486. }
  5487. }
  5488. }
  5489. function createChildren (vnode, children, insertedVnodeQueue) {
  5490. if (Array.isArray(children)) {
  5491. {
  5492. checkDuplicateKeys(children);
  5493. }
  5494. for (var i = 0; i < children.length; ++i) {
  5495. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  5496. }
  5497. } else if (isPrimitive(vnode.text)) {
  5498. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  5499. }
  5500. }
  5501. function isPatchable (vnode) {
  5502. while (vnode.componentInstance) {
  5503. vnode = vnode.componentInstance._vnode;
  5504. }
  5505. return isDef(vnode.tag)
  5506. }
  5507. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  5508. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  5509. cbs.create[i$1](emptyNode, vnode);
  5510. }
  5511. i = vnode.data.hook; // Reuse variable
  5512. if (isDef(i)) {
  5513. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  5514. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  5515. }
  5516. }
  5517. // set scope id attribute for scoped CSS.
  5518. // this is implemented as a special case to avoid the overhead
  5519. // of going through the normal attribute patching process.
  5520. function setScope (vnode) {
  5521. var i;
  5522. if (isDef(i = vnode.fnScopeId)) {
  5523. nodeOps.setStyleScope(vnode.elm, i);
  5524. } else {
  5525. var ancestor = vnode;
  5526. while (ancestor) {
  5527. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  5528. nodeOps.setStyleScope(vnode.elm, i);
  5529. }
  5530. ancestor = ancestor.parent;
  5531. }
  5532. }
  5533. // for slot content they should also get the scopeId from the host instance.
  5534. if (isDef(i = activeInstance) &&
  5535. i !== vnode.context &&
  5536. i !== vnode.fnContext &&
  5537. isDef(i = i.$options._scopeId)
  5538. ) {
  5539. nodeOps.setStyleScope(vnode.elm, i);
  5540. }
  5541. }
  5542. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  5543. for (; startIdx <= endIdx; ++startIdx) {
  5544. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  5545. }
  5546. }
  5547. function invokeDestroyHook (vnode) {
  5548. var i, j;
  5549. var data = vnode.data;
  5550. if (isDef(data)) {
  5551. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  5552. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  5553. }
  5554. if (isDef(i = vnode.children)) {
  5555. for (j = 0; j < vnode.children.length; ++j) {
  5556. invokeDestroyHook(vnode.children[j]);
  5557. }
  5558. }
  5559. }
  5560. function removeVnodes (vnodes, startIdx, endIdx) {
  5561. for (; startIdx <= endIdx; ++startIdx) {
  5562. var ch = vnodes[startIdx];
  5563. if (isDef(ch)) {
  5564. if (isDef(ch.tag)) {
  5565. removeAndInvokeRemoveHook(ch);
  5566. invokeDestroyHook(ch);
  5567. } else { // Text node
  5568. removeNode(ch.elm);
  5569. }
  5570. }
  5571. }
  5572. }
  5573. function removeAndInvokeRemoveHook (vnode, rm) {
  5574. if (isDef(rm) || isDef(vnode.data)) {
  5575. var i;
  5576. var listeners = cbs.remove.length + 1;
  5577. if (isDef(rm)) {
  5578. // we have a recursively passed down rm callback
  5579. // increase the listeners count
  5580. rm.listeners += listeners;
  5581. } else {
  5582. // directly removing
  5583. rm = createRmCb(vnode.elm, listeners);
  5584. }
  5585. // recursively invoke hooks on child component root node
  5586. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  5587. removeAndInvokeRemoveHook(i, rm);
  5588. }
  5589. for (i = 0; i < cbs.remove.length; ++i) {
  5590. cbs.remove[i](vnode, rm);
  5591. }
  5592. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  5593. i(vnode, rm);
  5594. } else {
  5595. rm();
  5596. }
  5597. } else {
  5598. removeNode(vnode.elm);
  5599. }
  5600. }
  5601. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  5602. var oldStartIdx = 0;
  5603. var newStartIdx = 0;
  5604. var oldEndIdx = oldCh.length - 1;
  5605. var oldStartVnode = oldCh[0];
  5606. var oldEndVnode = oldCh[oldEndIdx];
  5607. var newEndIdx = newCh.length - 1;
  5608. var newStartVnode = newCh[0];
  5609. var newEndVnode = newCh[newEndIdx];
  5610. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  5611. // removeOnly is a special flag used only by <transition-group>
  5612. // to ensure removed elements stay in correct relative positions
  5613. // during leaving transitions
  5614. var canMove = !removeOnly;
  5615. {
  5616. checkDuplicateKeys(newCh);
  5617. }
  5618. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  5619. if (isUndef(oldStartVnode)) {
  5620. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  5621. } else if (isUndef(oldEndVnode)) {
  5622. oldEndVnode = oldCh[--oldEndIdx];
  5623. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  5624. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5625. oldStartVnode = oldCh[++oldStartIdx];
  5626. newStartVnode = newCh[++newStartIdx];
  5627. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  5628. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5629. oldEndVnode = oldCh[--oldEndIdx];
  5630. newEndVnode = newCh[--newEndIdx];
  5631. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  5632. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5633. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  5634. oldStartVnode = oldCh[++oldStartIdx];
  5635. newEndVnode = newCh[--newEndIdx];
  5636. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  5637. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5638. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  5639. oldEndVnode = oldCh[--oldEndIdx];
  5640. newStartVnode = newCh[++newStartIdx];
  5641. } else {
  5642. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  5643. idxInOld = isDef(newStartVnode.key)
  5644. ? oldKeyToIdx[newStartVnode.key]
  5645. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  5646. if (isUndef(idxInOld)) { // New element
  5647. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5648. } else {
  5649. vnodeToMove = oldCh[idxInOld];
  5650. if (sameVnode(vnodeToMove, newStartVnode)) {
  5651. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5652. oldCh[idxInOld] = undefined;
  5653. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  5654. } else {
  5655. // same key but different element. treat as new element
  5656. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5657. }
  5658. }
  5659. newStartVnode = newCh[++newStartIdx];
  5660. }
  5661. }
  5662. if (oldStartIdx > oldEndIdx) {
  5663. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  5664. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  5665. } else if (newStartIdx > newEndIdx) {
  5666. removeVnodes(oldCh, oldStartIdx, oldEndIdx);
  5667. }
  5668. }
  5669. function checkDuplicateKeys (children) {
  5670. var seenKeys = {};
  5671. for (var i = 0; i < children.length; i++) {
  5672. var vnode = children[i];
  5673. var key = vnode.key;
  5674. if (isDef(key)) {
  5675. if (seenKeys[key]) {
  5676. warn(
  5677. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  5678. vnode.context
  5679. );
  5680. } else {
  5681. seenKeys[key] = true;
  5682. }
  5683. }
  5684. }
  5685. }
  5686. function findIdxInOld (node, oldCh, start, end) {
  5687. for (var i = start; i < end; i++) {
  5688. var c = oldCh[i];
  5689. if (isDef(c) && sameVnode(node, c)) { return i }
  5690. }
  5691. }
  5692. function patchVnode (
  5693. oldVnode,
  5694. vnode,
  5695. insertedVnodeQueue,
  5696. ownerArray,
  5697. index,
  5698. removeOnly
  5699. ) {
  5700. if (oldVnode === vnode) {
  5701. return
  5702. }
  5703. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5704. // clone reused vnode
  5705. vnode = ownerArray[index] = cloneVNode(vnode);
  5706. }
  5707. var elm = vnode.elm = oldVnode.elm;
  5708. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  5709. if (isDef(vnode.asyncFactory.resolved)) {
  5710. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  5711. } else {
  5712. vnode.isAsyncPlaceholder = true;
  5713. }
  5714. return
  5715. }
  5716. // reuse element for static trees.
  5717. // note we only do this if the vnode is cloned -
  5718. // if the new node is not cloned it means the render functions have been
  5719. // reset by the hot-reload-api and we need to do a proper re-render.
  5720. if (isTrue(vnode.isStatic) &&
  5721. isTrue(oldVnode.isStatic) &&
  5722. vnode.key === oldVnode.key &&
  5723. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  5724. ) {
  5725. vnode.componentInstance = oldVnode.componentInstance;
  5726. return
  5727. }
  5728. var i;
  5729. var data = vnode.data;
  5730. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  5731. i(oldVnode, vnode);
  5732. }
  5733. var oldCh = oldVnode.children;
  5734. var ch = vnode.children;
  5735. if (isDef(data) && isPatchable(vnode)) {
  5736. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  5737. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  5738. }
  5739. if (isUndef(vnode.text)) {
  5740. if (isDef(oldCh) && isDef(ch)) {
  5741. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  5742. } else if (isDef(ch)) {
  5743. {
  5744. checkDuplicateKeys(ch);
  5745. }
  5746. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  5747. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  5748. } else if (isDef(oldCh)) {
  5749. removeVnodes(oldCh, 0, oldCh.length - 1);
  5750. } else if (isDef(oldVnode.text)) {
  5751. nodeOps.setTextContent(elm, '');
  5752. }
  5753. } else if (oldVnode.text !== vnode.text) {
  5754. nodeOps.setTextContent(elm, vnode.text);
  5755. }
  5756. if (isDef(data)) {
  5757. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  5758. }
  5759. }
  5760. function invokeInsertHook (vnode, queue, initial) {
  5761. // delay insert hooks for component root nodes, invoke them after the
  5762. // element is really inserted
  5763. if (isTrue(initial) && isDef(vnode.parent)) {
  5764. vnode.parent.data.pendingInsert = queue;
  5765. } else {
  5766. for (var i = 0; i < queue.length; ++i) {
  5767. queue[i].data.hook.insert(queue[i]);
  5768. }
  5769. }
  5770. }
  5771. var hydrationBailed = false;
  5772. // list of modules that can skip create hook during hydration because they
  5773. // are already rendered on the client or has no need for initialization
  5774. // Note: style is excluded because it relies on initial clone for future
  5775. // deep updates (#7063).
  5776. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  5777. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  5778. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  5779. var i;
  5780. var tag = vnode.tag;
  5781. var data = vnode.data;
  5782. var children = vnode.children;
  5783. inVPre = inVPre || (data && data.pre);
  5784. vnode.elm = elm;
  5785. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  5786. vnode.isAsyncPlaceholder = true;
  5787. return true
  5788. }
  5789. // assert node match
  5790. {
  5791. if (!assertNodeMatch(elm, vnode, inVPre)) {
  5792. return false
  5793. }
  5794. }
  5795. if (isDef(data)) {
  5796. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  5797. if (isDef(i = vnode.componentInstance)) {
  5798. // child component. it should have hydrated its own tree.
  5799. initComponent(vnode, insertedVnodeQueue);
  5800. return true
  5801. }
  5802. }
  5803. if (isDef(tag)) {
  5804. if (isDef(children)) {
  5805. // empty element, allow client to pick up and populate children
  5806. if (!elm.hasChildNodes()) {
  5807. createChildren(vnode, children, insertedVnodeQueue);
  5808. } else {
  5809. // v-html and domProps: innerHTML
  5810. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  5811. if (i !== elm.innerHTML) {
  5812. /* istanbul ignore if */
  5813. if (typeof console !== 'undefined' &&
  5814. !hydrationBailed
  5815. ) {
  5816. hydrationBailed = true;
  5817. console.warn('Parent: ', elm);
  5818. console.warn('server innerHTML: ', i);
  5819. console.warn('client innerHTML: ', elm.innerHTML);
  5820. }
  5821. return false
  5822. }
  5823. } else {
  5824. // iterate and compare children lists
  5825. var childrenMatch = true;
  5826. var childNode = elm.firstChild;
  5827. for (var i$1 = 0; i$1 < children.length; i$1++) {
  5828. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  5829. childrenMatch = false;
  5830. break
  5831. }
  5832. childNode = childNode.nextSibling;
  5833. }
  5834. // if childNode is not null, it means the actual childNodes list is
  5835. // longer than the virtual children list.
  5836. if (!childrenMatch || childNode) {
  5837. /* istanbul ignore if */
  5838. if (typeof console !== 'undefined' &&
  5839. !hydrationBailed
  5840. ) {
  5841. hydrationBailed = true;
  5842. console.warn('Parent: ', elm);
  5843. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  5844. }
  5845. return false
  5846. }
  5847. }
  5848. }
  5849. }
  5850. if (isDef(data)) {
  5851. var fullInvoke = false;
  5852. for (var key in data) {
  5853. if (!isRenderedModule(key)) {
  5854. fullInvoke = true;
  5855. invokeCreateHooks(vnode, insertedVnodeQueue);
  5856. break
  5857. }
  5858. }
  5859. if (!fullInvoke && data['class']) {
  5860. // ensure collecting deps for deep class bindings for future updates
  5861. traverse(data['class']);
  5862. }
  5863. }
  5864. } else if (elm.data !== vnode.text) {
  5865. elm.data = vnode.text;
  5866. }
  5867. return true
  5868. }
  5869. function assertNodeMatch (node, vnode, inVPre) {
  5870. if (isDef(vnode.tag)) {
  5871. return vnode.tag.indexOf('vue-component') === 0 || (
  5872. !isUnknownElement$$1(vnode, inVPre) &&
  5873. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  5874. )
  5875. } else {
  5876. return node.nodeType === (vnode.isComment ? 8 : 3)
  5877. }
  5878. }
  5879. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  5880. if (isUndef(vnode)) {
  5881. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  5882. return
  5883. }
  5884. var isInitialPatch = false;
  5885. var insertedVnodeQueue = [];
  5886. if (isUndef(oldVnode)) {
  5887. // empty mount (likely as component), create new root element
  5888. isInitialPatch = true;
  5889. createElm(vnode, insertedVnodeQueue);
  5890. } else {
  5891. var isRealElement = isDef(oldVnode.nodeType);
  5892. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  5893. // patch existing root node
  5894. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  5895. } else {
  5896. if (isRealElement) {
  5897. // mounting to a real element
  5898. // check if this is server-rendered content and if we can perform
  5899. // a successful hydration.
  5900. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  5901. oldVnode.removeAttribute(SSR_ATTR);
  5902. hydrating = true;
  5903. }
  5904. if (isTrue(hydrating)) {
  5905. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  5906. invokeInsertHook(vnode, insertedVnodeQueue, true);
  5907. return oldVnode
  5908. } else {
  5909. warn(
  5910. 'The client-side rendered virtual DOM tree is not matching ' +
  5911. 'server-rendered content. This is likely caused by incorrect ' +
  5912. 'HTML markup, for example nesting block-level elements inside ' +
  5913. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  5914. 'full client-side render.'
  5915. );
  5916. }
  5917. }
  5918. // either not server-rendered, or hydration failed.
  5919. // create an empty node and replace it
  5920. oldVnode = emptyNodeAt(oldVnode);
  5921. }
  5922. // replacing existing element
  5923. var oldElm = oldVnode.elm;
  5924. var parentElm = nodeOps.parentNode(oldElm);
  5925. // create new node
  5926. createElm(
  5927. vnode,
  5928. insertedVnodeQueue,
  5929. // extremely rare edge case: do not insert if old element is in a
  5930. // leaving transition. Only happens when combining transition +
  5931. // keep-alive + HOCs. (#4590)
  5932. oldElm._leaveCb ? null : parentElm,
  5933. nodeOps.nextSibling(oldElm)
  5934. );
  5935. // update parent placeholder node element, recursively
  5936. if (isDef(vnode.parent)) {
  5937. var ancestor = vnode.parent;
  5938. var patchable = isPatchable(vnode);
  5939. while (ancestor) {
  5940. for (var i = 0; i < cbs.destroy.length; ++i) {
  5941. cbs.destroy[i](ancestor);
  5942. }
  5943. ancestor.elm = vnode.elm;
  5944. if (patchable) {
  5945. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  5946. cbs.create[i$1](emptyNode, ancestor);
  5947. }
  5948. // #6513
  5949. // invoke insert hooks that may have been merged by create hooks.
  5950. // e.g. for directives that uses the "inserted" hook.
  5951. var insert = ancestor.data.hook.insert;
  5952. if (insert.merged) {
  5953. // start at index 1 to avoid re-invoking component mounted hook
  5954. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  5955. insert.fns[i$2]();
  5956. }
  5957. }
  5958. } else {
  5959. registerRef(ancestor);
  5960. }
  5961. ancestor = ancestor.parent;
  5962. }
  5963. }
  5964. // destroy old node
  5965. if (isDef(parentElm)) {
  5966. removeVnodes([oldVnode], 0, 0);
  5967. } else if (isDef(oldVnode.tag)) {
  5968. invokeDestroyHook(oldVnode);
  5969. }
  5970. }
  5971. }
  5972. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  5973. return vnode.elm
  5974. }
  5975. }
  5976. /* */
  5977. var directives = {
  5978. create: updateDirectives,
  5979. update: updateDirectives,
  5980. destroy: function unbindDirectives (vnode) {
  5981. updateDirectives(vnode, emptyNode);
  5982. }
  5983. };
  5984. function updateDirectives (oldVnode, vnode) {
  5985. if (oldVnode.data.directives || vnode.data.directives) {
  5986. _update(oldVnode, vnode);
  5987. }
  5988. }
  5989. function _update (oldVnode, vnode) {
  5990. var isCreate = oldVnode === emptyNode;
  5991. var isDestroy = vnode === emptyNode;
  5992. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  5993. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  5994. var dirsWithInsert = [];
  5995. var dirsWithPostpatch = [];
  5996. var key, oldDir, dir;
  5997. for (key in newDirs) {
  5998. oldDir = oldDirs[key];
  5999. dir = newDirs[key];
  6000. if (!oldDir) {
  6001. // new directive, bind
  6002. callHook$1(dir, 'bind', vnode, oldVnode);
  6003. if (dir.def && dir.def.inserted) {
  6004. dirsWithInsert.push(dir);
  6005. }
  6006. } else {
  6007. // existing directive, update
  6008. dir.oldValue = oldDir.value;
  6009. dir.oldArg = oldDir.arg;
  6010. callHook$1(dir, 'update', vnode, oldVnode);
  6011. if (dir.def && dir.def.componentUpdated) {
  6012. dirsWithPostpatch.push(dir);
  6013. }
  6014. }
  6015. }
  6016. if (dirsWithInsert.length) {
  6017. var callInsert = function () {
  6018. for (var i = 0; i < dirsWithInsert.length; i++) {
  6019. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  6020. }
  6021. };
  6022. if (isCreate) {
  6023. mergeVNodeHook(vnode, 'insert', callInsert);
  6024. } else {
  6025. callInsert();
  6026. }
  6027. }
  6028. if (dirsWithPostpatch.length) {
  6029. mergeVNodeHook(vnode, 'postpatch', function () {
  6030. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  6031. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  6032. }
  6033. });
  6034. }
  6035. if (!isCreate) {
  6036. for (key in oldDirs) {
  6037. if (!newDirs[key]) {
  6038. // no longer present, unbind
  6039. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  6040. }
  6041. }
  6042. }
  6043. }
  6044. var emptyModifiers = Object.create(null);
  6045. function normalizeDirectives$1 (
  6046. dirs,
  6047. vm
  6048. ) {
  6049. var res = Object.create(null);
  6050. if (!dirs) {
  6051. // $flow-disable-line
  6052. return res
  6053. }
  6054. var i, dir;
  6055. for (i = 0; i < dirs.length; i++) {
  6056. dir = dirs[i];
  6057. if (!dir.modifiers) {
  6058. // $flow-disable-line
  6059. dir.modifiers = emptyModifiers;
  6060. }
  6061. res[getRawDirName(dir)] = dir;
  6062. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  6063. }
  6064. // $flow-disable-line
  6065. return res
  6066. }
  6067. function getRawDirName (dir) {
  6068. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  6069. }
  6070. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  6071. var fn = dir.def && dir.def[hook];
  6072. if (fn) {
  6073. try {
  6074. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  6075. } catch (e) {
  6076. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  6077. }
  6078. }
  6079. }
  6080. var baseModules = [
  6081. ref,
  6082. directives
  6083. ];
  6084. /* */
  6085. function updateAttrs (oldVnode, vnode) {
  6086. var opts = vnode.componentOptions;
  6087. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  6088. return
  6089. }
  6090. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  6091. return
  6092. }
  6093. var key, cur, old;
  6094. var elm = vnode.elm;
  6095. var oldAttrs = oldVnode.data.attrs || {};
  6096. var attrs = vnode.data.attrs || {};
  6097. // clone observed objects, as the user probably wants to mutate it
  6098. if (isDef(attrs.__ob__)) {
  6099. attrs = vnode.data.attrs = extend({}, attrs);
  6100. }
  6101. for (key in attrs) {
  6102. cur = attrs[key];
  6103. old = oldAttrs[key];
  6104. if (old !== cur) {
  6105. setAttr(elm, key, cur, vnode.data.pre);
  6106. }
  6107. }
  6108. // #4391: in IE9, setting type can reset value for input[type=radio]
  6109. // #6666: IE/Edge forces progress value down to 1 before setting a max
  6110. /* istanbul ignore if */
  6111. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  6112. setAttr(elm, 'value', attrs.value);
  6113. }
  6114. for (key in oldAttrs) {
  6115. if (isUndef(attrs[key])) {
  6116. if (isXlink(key)) {
  6117. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6118. } else if (!isEnumeratedAttr(key)) {
  6119. elm.removeAttribute(key);
  6120. }
  6121. }
  6122. }
  6123. }
  6124. function setAttr (el, key, value, isInPre) {
  6125. if (isInPre || el.tagName.indexOf('-') > -1) {
  6126. baseSetAttr(el, key, value);
  6127. } else if (isBooleanAttr(key)) {
  6128. // set attribute for blank value
  6129. // e.g. <option disabled>Select one</option>
  6130. if (isFalsyAttrValue(value)) {
  6131. el.removeAttribute(key);
  6132. } else {
  6133. // technically allowfullscreen is a boolean attribute for <iframe>,
  6134. // but Flash expects a value of "true" when used on <embed> tag
  6135. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  6136. ? 'true'
  6137. : key;
  6138. el.setAttribute(key, value);
  6139. }
  6140. } else if (isEnumeratedAttr(key)) {
  6141. el.setAttribute(key, convertEnumeratedValue(key, value));
  6142. } else if (isXlink(key)) {
  6143. if (isFalsyAttrValue(value)) {
  6144. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  6145. } else {
  6146. el.setAttributeNS(xlinkNS, key, value);
  6147. }
  6148. } else {
  6149. baseSetAttr(el, key, value);
  6150. }
  6151. }
  6152. function baseSetAttr (el, key, value) {
  6153. if (isFalsyAttrValue(value)) {
  6154. el.removeAttribute(key);
  6155. } else {
  6156. // #7138: IE10 & 11 fires input event when setting placeholder on
  6157. // <textarea>... block the first input event and remove the blocker
  6158. // immediately.
  6159. /* istanbul ignore if */
  6160. if (
  6161. isIE && !isIE9 &&
  6162. el.tagName === 'TEXTAREA' &&
  6163. key === 'placeholder' && value !== '' && !el.__ieph
  6164. ) {
  6165. var blocker = function (e) {
  6166. e.stopImmediatePropagation();
  6167. el.removeEventListener('input', blocker);
  6168. };
  6169. el.addEventListener('input', blocker);
  6170. // $flow-disable-line
  6171. el.__ieph = true; /* IE placeholder patched */
  6172. }
  6173. el.setAttribute(key, value);
  6174. }
  6175. }
  6176. var attrs = {
  6177. create: updateAttrs,
  6178. update: updateAttrs
  6179. };
  6180. /* */
  6181. function updateClass (oldVnode, vnode) {
  6182. var el = vnode.elm;
  6183. var data = vnode.data;
  6184. var oldData = oldVnode.data;
  6185. if (
  6186. isUndef(data.staticClass) &&
  6187. isUndef(data.class) && (
  6188. isUndef(oldData) || (
  6189. isUndef(oldData.staticClass) &&
  6190. isUndef(oldData.class)
  6191. )
  6192. )
  6193. ) {
  6194. return
  6195. }
  6196. var cls = genClassForVnode(vnode);
  6197. // handle transition classes
  6198. var transitionClass = el._transitionClasses;
  6199. if (isDef(transitionClass)) {
  6200. cls = concat(cls, stringifyClass(transitionClass));
  6201. }
  6202. // set the class
  6203. if (cls !== el._prevClass) {
  6204. el.setAttribute('class', cls);
  6205. el._prevClass = cls;
  6206. }
  6207. }
  6208. var klass = {
  6209. create: updateClass,
  6210. update: updateClass
  6211. };
  6212. /* */
  6213. var validDivisionCharRE = /[\w).+\-_$\]]/;
  6214. function parseFilters (exp) {
  6215. var inSingle = false;
  6216. var inDouble = false;
  6217. var inTemplateString = false;
  6218. var inRegex = false;
  6219. var curly = 0;
  6220. var square = 0;
  6221. var paren = 0;
  6222. var lastFilterIndex = 0;
  6223. var c, prev, i, expression, filters;
  6224. for (i = 0; i < exp.length; i++) {
  6225. prev = c;
  6226. c = exp.charCodeAt(i);
  6227. if (inSingle) {
  6228. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  6229. } else if (inDouble) {
  6230. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  6231. } else if (inTemplateString) {
  6232. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  6233. } else if (inRegex) {
  6234. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  6235. } else if (
  6236. c === 0x7C && // pipe
  6237. exp.charCodeAt(i + 1) !== 0x7C &&
  6238. exp.charCodeAt(i - 1) !== 0x7C &&
  6239. !curly && !square && !paren
  6240. ) {
  6241. if (expression === undefined) {
  6242. // first filter, end of expression
  6243. lastFilterIndex = i + 1;
  6244. expression = exp.slice(0, i).trim();
  6245. } else {
  6246. pushFilter();
  6247. }
  6248. } else {
  6249. switch (c) {
  6250. case 0x22: inDouble = true; break // "
  6251. case 0x27: inSingle = true; break // '
  6252. case 0x60: inTemplateString = true; break // `
  6253. case 0x28: paren++; break // (
  6254. case 0x29: paren--; break // )
  6255. case 0x5B: square++; break // [
  6256. case 0x5D: square--; break // ]
  6257. case 0x7B: curly++; break // {
  6258. case 0x7D: curly--; break // }
  6259. }
  6260. if (c === 0x2f) { // /
  6261. var j = i - 1;
  6262. var p = (void 0);
  6263. // find first non-whitespace prev char
  6264. for (; j >= 0; j--) {
  6265. p = exp.charAt(j);
  6266. if (p !== ' ') { break }
  6267. }
  6268. if (!p || !validDivisionCharRE.test(p)) {
  6269. inRegex = true;
  6270. }
  6271. }
  6272. }
  6273. }
  6274. if (expression === undefined) {
  6275. expression = exp.slice(0, i).trim();
  6276. } else if (lastFilterIndex !== 0) {
  6277. pushFilter();
  6278. }
  6279. function pushFilter () {
  6280. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  6281. lastFilterIndex = i + 1;
  6282. }
  6283. if (filters) {
  6284. for (i = 0; i < filters.length; i++) {
  6285. expression = wrapFilter(expression, filters[i]);
  6286. }
  6287. }
  6288. return expression
  6289. }
  6290. function wrapFilter (exp, filter) {
  6291. var i = filter.indexOf('(');
  6292. if (i < 0) {
  6293. // _f: resolveFilter
  6294. return ("_f(\"" + filter + "\")(" + exp + ")")
  6295. } else {
  6296. var name = filter.slice(0, i);
  6297. var args = filter.slice(i + 1);
  6298. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  6299. }
  6300. }
  6301. /* */
  6302. /* eslint-disable no-unused-vars */
  6303. function baseWarn (msg, range) {
  6304. console.error(("[Vue compiler]: " + msg));
  6305. }
  6306. /* eslint-enable no-unused-vars */
  6307. function pluckModuleFunction (
  6308. modules,
  6309. key
  6310. ) {
  6311. return modules
  6312. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  6313. : []
  6314. }
  6315. function addProp (el, name, value, range, dynamic) {
  6316. (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  6317. el.plain = false;
  6318. }
  6319. function addAttr (el, name, value, range, dynamic) {
  6320. var attrs = dynamic
  6321. ? (el.dynamicAttrs || (el.dynamicAttrs = []))
  6322. : (el.attrs || (el.attrs = []));
  6323. attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range));
  6324. el.plain = false;
  6325. }
  6326. // add a raw attr (use this in preTransforms)
  6327. function addRawAttr (el, name, value, range) {
  6328. el.attrsMap[name] = value;
  6329. el.attrsList.push(rangeSetItem({ name: name, value: value }, range));
  6330. }
  6331. function addDirective (
  6332. el,
  6333. name,
  6334. rawName,
  6335. value,
  6336. arg,
  6337. isDynamicArg,
  6338. modifiers,
  6339. range
  6340. ) {
  6341. (el.directives || (el.directives = [])).push(rangeSetItem({
  6342. name: name,
  6343. rawName: rawName,
  6344. value: value,
  6345. arg: arg,
  6346. isDynamicArg: isDynamicArg,
  6347. modifiers: modifiers
  6348. }, range));
  6349. el.plain = false;
  6350. }
  6351. function prependModifierMarker (symbol, name, dynamic) {
  6352. return dynamic
  6353. ? ("_p(" + name + ",\"" + symbol + "\")")
  6354. : symbol + name // mark the event as captured
  6355. }
  6356. function addHandler (
  6357. el,
  6358. name,
  6359. value,
  6360. modifiers,
  6361. important,
  6362. warn,
  6363. range,
  6364. dynamic
  6365. ) {
  6366. modifiers = modifiers || emptyObject;
  6367. // warn prevent and passive modifier
  6368. /* istanbul ignore if */
  6369. if (
  6370. warn &&
  6371. modifiers.prevent && modifiers.passive
  6372. ) {
  6373. warn(
  6374. 'passive and prevent can\'t be used together. ' +
  6375. 'Passive handler can\'t prevent default event.',
  6376. range
  6377. );
  6378. }
  6379. // normalize click.right and click.middle since they don't actually fire
  6380. // this is technically browser-specific, but at least for now browsers are
  6381. // the only target envs that have right/middle clicks.
  6382. if (modifiers.right) {
  6383. if (dynamic) {
  6384. name = "(" + name + ")==='click'?'contextmenu':(" + name + ")";
  6385. } else if (name === 'click') {
  6386. name = 'contextmenu';
  6387. delete modifiers.right;
  6388. }
  6389. } else if (modifiers.middle) {
  6390. if (dynamic) {
  6391. name = "(" + name + ")==='click'?'mouseup':(" + name + ")";
  6392. } else if (name === 'click') {
  6393. name = 'mouseup';
  6394. }
  6395. }
  6396. // check capture modifier
  6397. if (modifiers.capture) {
  6398. delete modifiers.capture;
  6399. name = prependModifierMarker('!', name, dynamic);
  6400. }
  6401. if (modifiers.once) {
  6402. delete modifiers.once;
  6403. name = prependModifierMarker('~', name, dynamic);
  6404. }
  6405. /* istanbul ignore if */
  6406. if (modifiers.passive) {
  6407. delete modifiers.passive;
  6408. name = prependModifierMarker('&', name, dynamic);
  6409. }
  6410. var events;
  6411. if (modifiers.native) {
  6412. delete modifiers.native;
  6413. events = el.nativeEvents || (el.nativeEvents = {});
  6414. } else {
  6415. events = el.events || (el.events = {});
  6416. }
  6417. var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range);
  6418. if (modifiers !== emptyObject) {
  6419. newHandler.modifiers = modifiers;
  6420. }
  6421. var handlers = events[name];
  6422. /* istanbul ignore if */
  6423. if (Array.isArray(handlers)) {
  6424. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  6425. } else if (handlers) {
  6426. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  6427. } else {
  6428. events[name] = newHandler;
  6429. }
  6430. el.plain = false;
  6431. }
  6432. function getRawBindingAttr (
  6433. el,
  6434. name
  6435. ) {
  6436. return el.rawAttrsMap[':' + name] ||
  6437. el.rawAttrsMap['v-bind:' + name] ||
  6438. el.rawAttrsMap[name]
  6439. }
  6440. function getBindingAttr (
  6441. el,
  6442. name,
  6443. getStatic
  6444. ) {
  6445. var dynamicValue =
  6446. getAndRemoveAttr(el, ':' + name) ||
  6447. getAndRemoveAttr(el, 'v-bind:' + name);
  6448. if (dynamicValue != null) {
  6449. return parseFilters(dynamicValue)
  6450. } else if (getStatic !== false) {
  6451. var staticValue = getAndRemoveAttr(el, name);
  6452. if (staticValue != null) {
  6453. return JSON.stringify(staticValue)
  6454. }
  6455. }
  6456. }
  6457. // note: this only removes the attr from the Array (attrsList) so that it
  6458. // doesn't get processed by processAttrs.
  6459. // By default it does NOT remove it from the map (attrsMap) because the map is
  6460. // needed during codegen.
  6461. function getAndRemoveAttr (
  6462. el,
  6463. name,
  6464. removeFromMap
  6465. ) {
  6466. var val;
  6467. if ((val = el.attrsMap[name]) != null) {
  6468. var list = el.attrsList;
  6469. for (var i = 0, l = list.length; i < l; i++) {
  6470. if (list[i].name === name) {
  6471. list.splice(i, 1);
  6472. break
  6473. }
  6474. }
  6475. }
  6476. if (removeFromMap) {
  6477. delete el.attrsMap[name];
  6478. }
  6479. return val
  6480. }
  6481. function getAndRemoveAttrByRegex (
  6482. el,
  6483. name
  6484. ) {
  6485. var list = el.attrsList;
  6486. for (var i = 0, l = list.length; i < l; i++) {
  6487. var attr = list[i];
  6488. if (name.test(attr.name)) {
  6489. list.splice(i, 1);
  6490. return attr
  6491. }
  6492. }
  6493. }
  6494. function rangeSetItem (
  6495. item,
  6496. range
  6497. ) {
  6498. if (range) {
  6499. if (range.start != null) {
  6500. item.start = range.start;
  6501. }
  6502. if (range.end != null) {
  6503. item.end = range.end;
  6504. }
  6505. }
  6506. return item
  6507. }
  6508. /* */
  6509. /**
  6510. * Cross-platform code generation for component v-model
  6511. */
  6512. function genComponentModel (
  6513. el,
  6514. value,
  6515. modifiers
  6516. ) {
  6517. var ref = modifiers || {};
  6518. var number = ref.number;
  6519. var trim = ref.trim;
  6520. var baseValueExpression = '$$v';
  6521. var valueExpression = baseValueExpression;
  6522. if (trim) {
  6523. valueExpression =
  6524. "(typeof " + baseValueExpression + " === 'string'" +
  6525. "? " + baseValueExpression + ".trim()" +
  6526. ": " + baseValueExpression + ")";
  6527. }
  6528. if (number) {
  6529. valueExpression = "_n(" + valueExpression + ")";
  6530. }
  6531. var assignment = genAssignmentCode(value, valueExpression);
  6532. el.model = {
  6533. value: ("(" + value + ")"),
  6534. expression: JSON.stringify(value),
  6535. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  6536. };
  6537. }
  6538. /**
  6539. * Cross-platform codegen helper for generating v-model value assignment code.
  6540. */
  6541. function genAssignmentCode (
  6542. value,
  6543. assignment
  6544. ) {
  6545. var res = parseModel(value);
  6546. if (res.key === null) {
  6547. return (value + "=" + assignment)
  6548. } else {
  6549. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  6550. }
  6551. }
  6552. /**
  6553. * Parse a v-model expression into a base path and a final key segment.
  6554. * Handles both dot-path and possible square brackets.
  6555. *
  6556. * Possible cases:
  6557. *
  6558. * - test
  6559. * - test[key]
  6560. * - test[test1[key]]
  6561. * - test["a"][key]
  6562. * - xxx.test[a[a].test1[key]]
  6563. * - test.xxx.a["asa"][test1[key]]
  6564. *
  6565. */
  6566. var len, str, chr, index$1, expressionPos, expressionEndPos;
  6567. function parseModel (val) {
  6568. // Fix https://github.com/vuejs/vue/pull/7730
  6569. // allow v-model="obj.val " (trailing whitespace)
  6570. val = val.trim();
  6571. len = val.length;
  6572. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  6573. index$1 = val.lastIndexOf('.');
  6574. if (index$1 > -1) {
  6575. return {
  6576. exp: val.slice(0, index$1),
  6577. key: '"' + val.slice(index$1 + 1) + '"'
  6578. }
  6579. } else {
  6580. return {
  6581. exp: val,
  6582. key: null
  6583. }
  6584. }
  6585. }
  6586. str = val;
  6587. index$1 = expressionPos = expressionEndPos = 0;
  6588. while (!eof()) {
  6589. chr = next();
  6590. /* istanbul ignore if */
  6591. if (isStringStart(chr)) {
  6592. parseString(chr);
  6593. } else if (chr === 0x5B) {
  6594. parseBracket(chr);
  6595. }
  6596. }
  6597. return {
  6598. exp: val.slice(0, expressionPos),
  6599. key: val.slice(expressionPos + 1, expressionEndPos)
  6600. }
  6601. }
  6602. function next () {
  6603. return str.charCodeAt(++index$1)
  6604. }
  6605. function eof () {
  6606. return index$1 >= len
  6607. }
  6608. function isStringStart (chr) {
  6609. return chr === 0x22 || chr === 0x27
  6610. }
  6611. function parseBracket (chr) {
  6612. var inBracket = 1;
  6613. expressionPos = index$1;
  6614. while (!eof()) {
  6615. chr = next();
  6616. if (isStringStart(chr)) {
  6617. parseString(chr);
  6618. continue
  6619. }
  6620. if (chr === 0x5B) { inBracket++; }
  6621. if (chr === 0x5D) { inBracket--; }
  6622. if (inBracket === 0) {
  6623. expressionEndPos = index$1;
  6624. break
  6625. }
  6626. }
  6627. }
  6628. function parseString (chr) {
  6629. var stringQuote = chr;
  6630. while (!eof()) {
  6631. chr = next();
  6632. if (chr === stringQuote) {
  6633. break
  6634. }
  6635. }
  6636. }
  6637. /* */
  6638. var warn$1;
  6639. // in some cases, the event used has to be determined at runtime
  6640. // so we used some reserved tokens during compile.
  6641. var RANGE_TOKEN = '__r';
  6642. var CHECKBOX_RADIO_TOKEN = '__c';
  6643. function model (
  6644. el,
  6645. dir,
  6646. _warn
  6647. ) {
  6648. warn$1 = _warn;
  6649. var value = dir.value;
  6650. var modifiers = dir.modifiers;
  6651. var tag = el.tag;
  6652. var type = el.attrsMap.type;
  6653. {
  6654. // inputs with type="file" are read only and setting the input's
  6655. // value will throw an error.
  6656. if (tag === 'input' && type === 'file') {
  6657. warn$1(
  6658. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  6659. "File inputs are read only. Use a v-on:change listener instead.",
  6660. el.rawAttrsMap['v-model']
  6661. );
  6662. }
  6663. }
  6664. if (el.component) {
  6665. genComponentModel(el, value, modifiers);
  6666. // component v-model doesn't need extra runtime
  6667. return false
  6668. } else if (tag === 'select') {
  6669. genSelect(el, value, modifiers);
  6670. } else if (tag === 'input' && type === 'checkbox') {
  6671. genCheckboxModel(el, value, modifiers);
  6672. } else if (tag === 'input' && type === 'radio') {
  6673. genRadioModel(el, value, modifiers);
  6674. } else if (tag === 'input' || tag === 'textarea') {
  6675. genDefaultModel(el, value, modifiers);
  6676. } else if (!config.isReservedTag(tag)) {
  6677. genComponentModel(el, value, modifiers);
  6678. // component v-model doesn't need extra runtime
  6679. return false
  6680. } else {
  6681. warn$1(
  6682. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  6683. "v-model is not supported on this element type. " +
  6684. 'If you are working with contenteditable, it\'s recommended to ' +
  6685. 'wrap a library dedicated for that purpose inside a custom component.',
  6686. el.rawAttrsMap['v-model']
  6687. );
  6688. }
  6689. // ensure runtime directive metadata
  6690. return true
  6691. }
  6692. function genCheckboxModel (
  6693. el,
  6694. value,
  6695. modifiers
  6696. ) {
  6697. var number = modifiers && modifiers.number;
  6698. var valueBinding = getBindingAttr(el, 'value') || 'null';
  6699. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  6700. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  6701. addProp(el, 'checked',
  6702. "Array.isArray(" + value + ")" +
  6703. "?_i(" + value + "," + valueBinding + ")>-1" + (
  6704. trueValueBinding === 'true'
  6705. ? (":(" + value + ")")
  6706. : (":_q(" + value + "," + trueValueBinding + ")")
  6707. )
  6708. );
  6709. addHandler(el, 'change',
  6710. "var $$a=" + value + "," +
  6711. '$$el=$event.target,' +
  6712. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  6713. 'if(Array.isArray($$a)){' +
  6714. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  6715. '$$i=_i($$a,$$v);' +
  6716. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  6717. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  6718. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  6719. null, true
  6720. );
  6721. }
  6722. function genRadioModel (
  6723. el,
  6724. value,
  6725. modifiers
  6726. ) {
  6727. var number = modifiers && modifiers.number;
  6728. var valueBinding = getBindingAttr(el, 'value') || 'null';
  6729. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  6730. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  6731. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  6732. }
  6733. function genSelect (
  6734. el,
  6735. value,
  6736. modifiers
  6737. ) {
  6738. var number = modifiers && modifiers.number;
  6739. var selectedVal = "Array.prototype.filter" +
  6740. ".call($event.target.options,function(o){return o.selected})" +
  6741. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  6742. "return " + (number ? '_n(val)' : 'val') + "})";
  6743. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  6744. var code = "var $$selectedVal = " + selectedVal + ";";
  6745. code = code + " " + (genAssignmentCode(value, assignment));
  6746. addHandler(el, 'change', code, null, true);
  6747. }
  6748. function genDefaultModel (
  6749. el,
  6750. value,
  6751. modifiers
  6752. ) {
  6753. var type = el.attrsMap.type;
  6754. // warn if v-bind:value conflicts with v-model
  6755. // except for inputs with v-bind:type
  6756. {
  6757. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  6758. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  6759. if (value$1 && !typeBinding) {
  6760. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  6761. warn$1(
  6762. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  6763. 'because the latter already expands to a value binding internally',
  6764. el.rawAttrsMap[binding]
  6765. );
  6766. }
  6767. }
  6768. var ref = modifiers || {};
  6769. var lazy = ref.lazy;
  6770. var number = ref.number;
  6771. var trim = ref.trim;
  6772. var needCompositionGuard = !lazy && type !== 'range';
  6773. var event = lazy
  6774. ? 'change'
  6775. : type === 'range'
  6776. ? RANGE_TOKEN
  6777. : 'input';
  6778. var valueExpression = '$event.target.value';
  6779. if (trim) {
  6780. valueExpression = "$event.target.value.trim()";
  6781. }
  6782. if (number) {
  6783. valueExpression = "_n(" + valueExpression + ")";
  6784. }
  6785. var code = genAssignmentCode(value, valueExpression);
  6786. if (needCompositionGuard) {
  6787. code = "if($event.target.composing)return;" + code;
  6788. }
  6789. addProp(el, 'value', ("(" + value + ")"));
  6790. addHandler(el, event, code, null, true);
  6791. if (trim || number) {
  6792. addHandler(el, 'blur', '$forceUpdate()');
  6793. }
  6794. }
  6795. /* */
  6796. // normalize v-model event tokens that can only be determined at runtime.
  6797. // it's important to place the event as the first in the array because
  6798. // the whole point is ensuring the v-model callback gets called before
  6799. // user-attached handlers.
  6800. function normalizeEvents (on) {
  6801. /* istanbul ignore if */
  6802. if (isDef(on[RANGE_TOKEN])) {
  6803. // IE input[type=range] only supports `change` event
  6804. var event = isIE ? 'change' : 'input';
  6805. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  6806. delete on[RANGE_TOKEN];
  6807. }
  6808. // This was originally intended to fix #4521 but no longer necessary
  6809. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  6810. /* istanbul ignore if */
  6811. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  6812. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  6813. delete on[CHECKBOX_RADIO_TOKEN];
  6814. }
  6815. }
  6816. var target$1;
  6817. function createOnceHandler$1 (event, handler, capture) {
  6818. var _target = target$1; // save current target element in closure
  6819. return function onceHandler () {
  6820. var res = handler.apply(null, arguments);
  6821. if (res !== null) {
  6822. remove$2(event, onceHandler, capture, _target);
  6823. }
  6824. }
  6825. }
  6826. // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
  6827. // implementation and does not fire microtasks in between event propagation, so
  6828. // safe to exclude.
  6829. var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
  6830. function add$1 (
  6831. name,
  6832. handler,
  6833. capture,
  6834. passive
  6835. ) {
  6836. // async edge case #6566: inner click event triggers patch, event handler
  6837. // attached to outer element during patch, and triggered again. This
  6838. // happens because browsers fire microtask ticks between event propagation.
  6839. // the solution is simple: we save the timestamp when a handler is attached,
  6840. // and the handler would only fire if the event passed to it was fired
  6841. // AFTER it was attached.
  6842. if (useMicrotaskFix) {
  6843. var attachedTimestamp = currentFlushTimestamp;
  6844. var original = handler;
  6845. handler = original._wrapper = function (e) {
  6846. if (
  6847. // no bubbling, should always fire.
  6848. // this is just a safety net in case event.timeStamp is unreliable in
  6849. // certain weird environments...
  6850. e.target === e.currentTarget ||
  6851. // event is fired after handler attachment
  6852. e.timeStamp >= attachedTimestamp ||
  6853. // bail for environments that have buggy event.timeStamp implementations
  6854. // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState
  6855. // #9681 QtWebEngine event.timeStamp is negative value
  6856. e.timeStamp <= 0 ||
  6857. // #9448 bail if event is fired in another document in a multi-page
  6858. // electron/nw.js app, since event.timeStamp will be using a different
  6859. // starting reference
  6860. e.target.ownerDocument !== document
  6861. ) {
  6862. return original.apply(this, arguments)
  6863. }
  6864. };
  6865. }
  6866. target$1.addEventListener(
  6867. name,
  6868. handler,
  6869. supportsPassive
  6870. ? { capture: capture, passive: passive }
  6871. : capture
  6872. );
  6873. }
  6874. function remove$2 (
  6875. name,
  6876. handler,
  6877. capture,
  6878. _target
  6879. ) {
  6880. (_target || target$1).removeEventListener(
  6881. name,
  6882. handler._wrapper || handler,
  6883. capture
  6884. );
  6885. }
  6886. function updateDOMListeners (oldVnode, vnode) {
  6887. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  6888. return
  6889. }
  6890. var on = vnode.data.on || {};
  6891. var oldOn = oldVnode.data.on || {};
  6892. target$1 = vnode.elm;
  6893. normalizeEvents(on);
  6894. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  6895. target$1 = undefined;
  6896. }
  6897. var events = {
  6898. create: updateDOMListeners,
  6899. update: updateDOMListeners
  6900. };
  6901. /* */
  6902. var svgContainer;
  6903. function updateDOMProps (oldVnode, vnode) {
  6904. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  6905. return
  6906. }
  6907. var key, cur;
  6908. var elm = vnode.elm;
  6909. var oldProps = oldVnode.data.domProps || {};
  6910. var props = vnode.data.domProps || {};
  6911. // clone observed objects, as the user probably wants to mutate it
  6912. if (isDef(props.__ob__)) {
  6913. props = vnode.data.domProps = extend({}, props);
  6914. }
  6915. for (key in oldProps) {
  6916. if (!(key in props)) {
  6917. elm[key] = '';
  6918. }
  6919. }
  6920. for (key in props) {
  6921. cur = props[key];
  6922. // ignore children if the node has textContent or innerHTML,
  6923. // as these will throw away existing DOM nodes and cause removal errors
  6924. // on subsequent patches (#3360)
  6925. if (key === 'textContent' || key === 'innerHTML') {
  6926. if (vnode.children) { vnode.children.length = 0; }
  6927. if (cur === oldProps[key]) { continue }
  6928. // #6601 work around Chrome version <= 55 bug where single textNode
  6929. // replaced by innerHTML/textContent retains its parentNode property
  6930. if (elm.childNodes.length === 1) {
  6931. elm.removeChild(elm.childNodes[0]);
  6932. }
  6933. }
  6934. if (key === 'value' && elm.tagName !== 'PROGRESS') {
  6935. // store value as _value as well since
  6936. // non-string values will be stringified
  6937. elm._value = cur;
  6938. // avoid resetting cursor position when value is the same
  6939. var strCur = isUndef(cur) ? '' : String(cur);
  6940. if (shouldUpdateValue(elm, strCur)) {
  6941. elm.value = strCur;
  6942. }
  6943. } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
  6944. // IE doesn't support innerHTML for SVG elements
  6945. svgContainer = svgContainer || document.createElement('div');
  6946. svgContainer.innerHTML = "<svg>" + cur + "</svg>";
  6947. var svg = svgContainer.firstChild;
  6948. while (elm.firstChild) {
  6949. elm.removeChild(elm.firstChild);
  6950. }
  6951. while (svg.firstChild) {
  6952. elm.appendChild(svg.firstChild);
  6953. }
  6954. } else if (
  6955. // skip the update if old and new VDOM state is the same.
  6956. // `value` is handled separately because the DOM value may be temporarily
  6957. // out of sync with VDOM state due to focus, composition and modifiers.
  6958. // This #4521 by skipping the unnecessary `checked` update.
  6959. cur !== oldProps[key]
  6960. ) {
  6961. // some property updates can throw
  6962. // e.g. `value` on <progress> w/ non-finite value
  6963. try {
  6964. elm[key] = cur;
  6965. } catch (e) {}
  6966. }
  6967. }
  6968. }
  6969. // check platforms/web/util/attrs.js acceptValue
  6970. function shouldUpdateValue (elm, checkVal) {
  6971. return (!elm.composing && (
  6972. elm.tagName === 'OPTION' ||
  6973. isNotInFocusAndDirty(elm, checkVal) ||
  6974. isDirtyWithModifiers(elm, checkVal)
  6975. ))
  6976. }
  6977. function isNotInFocusAndDirty (elm, checkVal) {
  6978. // return true when textbox (.number and .trim) loses focus and its value is
  6979. // not equal to the updated value
  6980. var notInFocus = true;
  6981. // #6157
  6982. // work around IE bug when accessing document.activeElement in an iframe
  6983. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  6984. return notInFocus && elm.value !== checkVal
  6985. }
  6986. function isDirtyWithModifiers (elm, newVal) {
  6987. var value = elm.value;
  6988. var modifiers = elm._vModifiers; // injected by v-model runtime
  6989. if (isDef(modifiers)) {
  6990. if (modifiers.number) {
  6991. return toNumber(value) !== toNumber(newVal)
  6992. }
  6993. if (modifiers.trim) {
  6994. return value.trim() !== newVal.trim()
  6995. }
  6996. }
  6997. return value !== newVal
  6998. }
  6999. var domProps = {
  7000. create: updateDOMProps,
  7001. update: updateDOMProps
  7002. };
  7003. /* */
  7004. var parseStyleText = cached(function (cssText) {
  7005. var res = {};
  7006. var listDelimiter = /;(?![^(]*\))/g;
  7007. var propertyDelimiter = /:(.+)/;
  7008. cssText.split(listDelimiter).forEach(function (item) {
  7009. if (item) {
  7010. var tmp = item.split(propertyDelimiter);
  7011. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  7012. }
  7013. });
  7014. return res
  7015. });
  7016. // merge static and dynamic style data on the same vnode
  7017. function normalizeStyleData (data) {
  7018. var style = normalizeStyleBinding(data.style);
  7019. // static style is pre-processed into an object during compilation
  7020. // and is always a fresh object, so it's safe to merge into it
  7021. return data.staticStyle
  7022. ? extend(data.staticStyle, style)
  7023. : style
  7024. }
  7025. // normalize possible array / string values into Object
  7026. function normalizeStyleBinding (bindingStyle) {
  7027. if (Array.isArray(bindingStyle)) {
  7028. return toObject(bindingStyle)
  7029. }
  7030. if (typeof bindingStyle === 'string') {
  7031. return parseStyleText(bindingStyle)
  7032. }
  7033. return bindingStyle
  7034. }
  7035. /**
  7036. * parent component style should be after child's
  7037. * so that parent component's style could override it
  7038. */
  7039. function getStyle (vnode, checkChild) {
  7040. var res = {};
  7041. var styleData;
  7042. if (checkChild) {
  7043. var childNode = vnode;
  7044. while (childNode.componentInstance) {
  7045. childNode = childNode.componentInstance._vnode;
  7046. if (
  7047. childNode && childNode.data &&
  7048. (styleData = normalizeStyleData(childNode.data))
  7049. ) {
  7050. extend(res, styleData);
  7051. }
  7052. }
  7053. }
  7054. if ((styleData = normalizeStyleData(vnode.data))) {
  7055. extend(res, styleData);
  7056. }
  7057. var parentNode = vnode;
  7058. while ((parentNode = parentNode.parent)) {
  7059. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  7060. extend(res, styleData);
  7061. }
  7062. }
  7063. return res
  7064. }
  7065. /* */
  7066. var cssVarRE = /^--/;
  7067. var importantRE = /\s*!important$/;
  7068. var setProp = function (el, name, val) {
  7069. /* istanbul ignore if */
  7070. if (cssVarRE.test(name)) {
  7071. el.style.setProperty(name, val);
  7072. } else if (importantRE.test(val)) {
  7073. el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important');
  7074. } else {
  7075. var normalizedName = normalize(name);
  7076. if (Array.isArray(val)) {
  7077. // Support values array created by autoprefixer, e.g.
  7078. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  7079. // Set them one by one, and the browser will only set those it can recognize
  7080. for (var i = 0, len = val.length; i < len; i++) {
  7081. el.style[normalizedName] = val[i];
  7082. }
  7083. } else {
  7084. el.style[normalizedName] = val;
  7085. }
  7086. }
  7087. };
  7088. var vendorNames = ['Webkit', 'Moz', 'ms'];
  7089. var emptyStyle;
  7090. var normalize = cached(function (prop) {
  7091. emptyStyle = emptyStyle || document.createElement('div').style;
  7092. prop = camelize(prop);
  7093. if (prop !== 'filter' && (prop in emptyStyle)) {
  7094. return prop
  7095. }
  7096. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  7097. for (var i = 0; i < vendorNames.length; i++) {
  7098. var name = vendorNames[i] + capName;
  7099. if (name in emptyStyle) {
  7100. return name
  7101. }
  7102. }
  7103. });
  7104. function updateStyle (oldVnode, vnode) {
  7105. var data = vnode.data;
  7106. var oldData = oldVnode.data;
  7107. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  7108. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  7109. ) {
  7110. return
  7111. }
  7112. var cur, name;
  7113. var el = vnode.elm;
  7114. var oldStaticStyle = oldData.staticStyle;
  7115. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  7116. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  7117. var oldStyle = oldStaticStyle || oldStyleBinding;
  7118. var style = normalizeStyleBinding(vnode.data.style) || {};
  7119. // store normalized style under a different key for next diff
  7120. // make sure to clone it if it's reactive, since the user likely wants
  7121. // to mutate it.
  7122. vnode.data.normalizedStyle = isDef(style.__ob__)
  7123. ? extend({}, style)
  7124. : style;
  7125. var newStyle = getStyle(vnode, true);
  7126. for (name in oldStyle) {
  7127. if (isUndef(newStyle[name])) {
  7128. setProp(el, name, '');
  7129. }
  7130. }
  7131. for (name in newStyle) {
  7132. cur = newStyle[name];
  7133. if (cur !== oldStyle[name]) {
  7134. // ie9 setting to null has no effect, must use empty string
  7135. setProp(el, name, cur == null ? '' : cur);
  7136. }
  7137. }
  7138. }
  7139. var style = {
  7140. create: updateStyle,
  7141. update: updateStyle
  7142. };
  7143. /* */
  7144. var whitespaceRE = /\s+/;
  7145. /**
  7146. * Add class with compatibility for SVG since classList is not supported on
  7147. * SVG elements in IE
  7148. */
  7149. function addClass (el, cls) {
  7150. /* istanbul ignore if */
  7151. if (!cls || !(cls = cls.trim())) {
  7152. return
  7153. }
  7154. /* istanbul ignore else */
  7155. if (el.classList) {
  7156. if (cls.indexOf(' ') > -1) {
  7157. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  7158. } else {
  7159. el.classList.add(cls);
  7160. }
  7161. } else {
  7162. var cur = " " + (el.getAttribute('class') || '') + " ";
  7163. if (cur.indexOf(' ' + cls + ' ') < 0) {
  7164. el.setAttribute('class', (cur + cls).trim());
  7165. }
  7166. }
  7167. }
  7168. /**
  7169. * Remove class with compatibility for SVG since classList is not supported on
  7170. * SVG elements in IE
  7171. */
  7172. function removeClass (el, cls) {
  7173. /* istanbul ignore if */
  7174. if (!cls || !(cls = cls.trim())) {
  7175. return
  7176. }
  7177. /* istanbul ignore else */
  7178. if (el.classList) {
  7179. if (cls.indexOf(' ') > -1) {
  7180. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  7181. } else {
  7182. el.classList.remove(cls);
  7183. }
  7184. if (!el.classList.length) {
  7185. el.removeAttribute('class');
  7186. }
  7187. } else {
  7188. var cur = " " + (el.getAttribute('class') || '') + " ";
  7189. var tar = ' ' + cls + ' ';
  7190. while (cur.indexOf(tar) >= 0) {
  7191. cur = cur.replace(tar, ' ');
  7192. }
  7193. cur = cur.trim();
  7194. if (cur) {
  7195. el.setAttribute('class', cur);
  7196. } else {
  7197. el.removeAttribute('class');
  7198. }
  7199. }
  7200. }
  7201. /* */
  7202. function resolveTransition (def$$1) {
  7203. if (!def$$1) {
  7204. return
  7205. }
  7206. /* istanbul ignore else */
  7207. if (typeof def$$1 === 'object') {
  7208. var res = {};
  7209. if (def$$1.css !== false) {
  7210. extend(res, autoCssTransition(def$$1.name || 'v'));
  7211. }
  7212. extend(res, def$$1);
  7213. return res
  7214. } else if (typeof def$$1 === 'string') {
  7215. return autoCssTransition(def$$1)
  7216. }
  7217. }
  7218. var autoCssTransition = cached(function (name) {
  7219. return {
  7220. enterClass: (name + "-enter"),
  7221. enterToClass: (name + "-enter-to"),
  7222. enterActiveClass: (name + "-enter-active"),
  7223. leaveClass: (name + "-leave"),
  7224. leaveToClass: (name + "-leave-to"),
  7225. leaveActiveClass: (name + "-leave-active")
  7226. }
  7227. });
  7228. var hasTransition = inBrowser && !isIE9;
  7229. var TRANSITION = 'transition';
  7230. var ANIMATION = 'animation';
  7231. // Transition property/event sniffing
  7232. var transitionProp = 'transition';
  7233. var transitionEndEvent = 'transitionend';
  7234. var animationProp = 'animation';
  7235. var animationEndEvent = 'animationend';
  7236. if (hasTransition) {
  7237. /* istanbul ignore if */
  7238. if (window.ontransitionend === undefined &&
  7239. window.onwebkittransitionend !== undefined
  7240. ) {
  7241. transitionProp = 'WebkitTransition';
  7242. transitionEndEvent = 'webkitTransitionEnd';
  7243. }
  7244. if (window.onanimationend === undefined &&
  7245. window.onwebkitanimationend !== undefined
  7246. ) {
  7247. animationProp = 'WebkitAnimation';
  7248. animationEndEvent = 'webkitAnimationEnd';
  7249. }
  7250. }
  7251. // binding to window is necessary to make hot reload work in IE in strict mode
  7252. var raf = inBrowser
  7253. ? window.requestAnimationFrame
  7254. ? window.requestAnimationFrame.bind(window)
  7255. : setTimeout
  7256. : /* istanbul ignore next */ function (fn) { return fn(); };
  7257. function nextFrame (fn) {
  7258. raf(function () {
  7259. raf(fn);
  7260. });
  7261. }
  7262. function addTransitionClass (el, cls) {
  7263. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  7264. if (transitionClasses.indexOf(cls) < 0) {
  7265. transitionClasses.push(cls);
  7266. addClass(el, cls);
  7267. }
  7268. }
  7269. function removeTransitionClass (el, cls) {
  7270. if (el._transitionClasses) {
  7271. remove(el._transitionClasses, cls);
  7272. }
  7273. removeClass(el, cls);
  7274. }
  7275. function whenTransitionEnds (
  7276. el,
  7277. expectedType,
  7278. cb
  7279. ) {
  7280. var ref = getTransitionInfo(el, expectedType);
  7281. var type = ref.type;
  7282. var timeout = ref.timeout;
  7283. var propCount = ref.propCount;
  7284. if (!type) { return cb() }
  7285. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  7286. var ended = 0;
  7287. var end = function () {
  7288. el.removeEventListener(event, onEnd);
  7289. cb();
  7290. };
  7291. var onEnd = function (e) {
  7292. if (e.target === el) {
  7293. if (++ended >= propCount) {
  7294. end();
  7295. }
  7296. }
  7297. };
  7298. setTimeout(function () {
  7299. if (ended < propCount) {
  7300. end();
  7301. }
  7302. }, timeout + 1);
  7303. el.addEventListener(event, onEnd);
  7304. }
  7305. var transformRE = /\b(transform|all)(,|$)/;
  7306. function getTransitionInfo (el, expectedType) {
  7307. var styles = window.getComputedStyle(el);
  7308. // JSDOM may return undefined for transition properties
  7309. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  7310. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  7311. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  7312. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  7313. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  7314. var animationTimeout = getTimeout(animationDelays, animationDurations);
  7315. var type;
  7316. var timeout = 0;
  7317. var propCount = 0;
  7318. /* istanbul ignore if */
  7319. if (expectedType === TRANSITION) {
  7320. if (transitionTimeout > 0) {
  7321. type = TRANSITION;
  7322. timeout = transitionTimeout;
  7323. propCount = transitionDurations.length;
  7324. }
  7325. } else if (expectedType === ANIMATION) {
  7326. if (animationTimeout > 0) {
  7327. type = ANIMATION;
  7328. timeout = animationTimeout;
  7329. propCount = animationDurations.length;
  7330. }
  7331. } else {
  7332. timeout = Math.max(transitionTimeout, animationTimeout);
  7333. type = timeout > 0
  7334. ? transitionTimeout > animationTimeout
  7335. ? TRANSITION
  7336. : ANIMATION
  7337. : null;
  7338. propCount = type
  7339. ? type === TRANSITION
  7340. ? transitionDurations.length
  7341. : animationDurations.length
  7342. : 0;
  7343. }
  7344. var hasTransform =
  7345. type === TRANSITION &&
  7346. transformRE.test(styles[transitionProp + 'Property']);
  7347. return {
  7348. type: type,
  7349. timeout: timeout,
  7350. propCount: propCount,
  7351. hasTransform: hasTransform
  7352. }
  7353. }
  7354. function getTimeout (delays, durations) {
  7355. /* istanbul ignore next */
  7356. while (delays.length < durations.length) {
  7357. delays = delays.concat(delays);
  7358. }
  7359. return Math.max.apply(null, durations.map(function (d, i) {
  7360. return toMs(d) + toMs(delays[i])
  7361. }))
  7362. }
  7363. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  7364. // in a locale-dependent way, using a comma instead of a dot.
  7365. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  7366. // as a floor function) causing unexpected behaviors
  7367. function toMs (s) {
  7368. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  7369. }
  7370. /* */
  7371. function enter (vnode, toggleDisplay) {
  7372. var el = vnode.elm;
  7373. // call leave callback now
  7374. if (isDef(el._leaveCb)) {
  7375. el._leaveCb.cancelled = true;
  7376. el._leaveCb();
  7377. }
  7378. var data = resolveTransition(vnode.data.transition);
  7379. if (isUndef(data)) {
  7380. return
  7381. }
  7382. /* istanbul ignore if */
  7383. if (isDef(el._enterCb) || el.nodeType !== 1) {
  7384. return
  7385. }
  7386. var css = data.css;
  7387. var type = data.type;
  7388. var enterClass = data.enterClass;
  7389. var enterToClass = data.enterToClass;
  7390. var enterActiveClass = data.enterActiveClass;
  7391. var appearClass = data.appearClass;
  7392. var appearToClass = data.appearToClass;
  7393. var appearActiveClass = data.appearActiveClass;
  7394. var beforeEnter = data.beforeEnter;
  7395. var enter = data.enter;
  7396. var afterEnter = data.afterEnter;
  7397. var enterCancelled = data.enterCancelled;
  7398. var beforeAppear = data.beforeAppear;
  7399. var appear = data.appear;
  7400. var afterAppear = data.afterAppear;
  7401. var appearCancelled = data.appearCancelled;
  7402. var duration = data.duration;
  7403. // activeInstance will always be the <transition> component managing this
  7404. // transition. One edge case to check is when the <transition> is placed
  7405. // as the root node of a child component. In that case we need to check
  7406. // <transition>'s parent for appear check.
  7407. var context = activeInstance;
  7408. var transitionNode = activeInstance.$vnode;
  7409. while (transitionNode && transitionNode.parent) {
  7410. context = transitionNode.context;
  7411. transitionNode = transitionNode.parent;
  7412. }
  7413. var isAppear = !context._isMounted || !vnode.isRootInsert;
  7414. if (isAppear && !appear && appear !== '') {
  7415. return
  7416. }
  7417. var startClass = isAppear && appearClass
  7418. ? appearClass
  7419. : enterClass;
  7420. var activeClass = isAppear && appearActiveClass
  7421. ? appearActiveClass
  7422. : enterActiveClass;
  7423. var toClass = isAppear && appearToClass
  7424. ? appearToClass
  7425. : enterToClass;
  7426. var beforeEnterHook = isAppear
  7427. ? (beforeAppear || beforeEnter)
  7428. : beforeEnter;
  7429. var enterHook = isAppear
  7430. ? (typeof appear === 'function' ? appear : enter)
  7431. : enter;
  7432. var afterEnterHook = isAppear
  7433. ? (afterAppear || afterEnter)
  7434. : afterEnter;
  7435. var enterCancelledHook = isAppear
  7436. ? (appearCancelled || enterCancelled)
  7437. : enterCancelled;
  7438. var explicitEnterDuration = toNumber(
  7439. isObject(duration)
  7440. ? duration.enter
  7441. : duration
  7442. );
  7443. if (explicitEnterDuration != null) {
  7444. checkDuration(explicitEnterDuration, 'enter', vnode);
  7445. }
  7446. var expectsCSS = css !== false && !isIE9;
  7447. var userWantsControl = getHookArgumentsLength(enterHook);
  7448. var cb = el._enterCb = once(function () {
  7449. if (expectsCSS) {
  7450. removeTransitionClass(el, toClass);
  7451. removeTransitionClass(el, activeClass);
  7452. }
  7453. if (cb.cancelled) {
  7454. if (expectsCSS) {
  7455. removeTransitionClass(el, startClass);
  7456. }
  7457. enterCancelledHook && enterCancelledHook(el);
  7458. } else {
  7459. afterEnterHook && afterEnterHook(el);
  7460. }
  7461. el._enterCb = null;
  7462. });
  7463. if (!vnode.data.show) {
  7464. // remove pending leave element on enter by injecting an insert hook
  7465. mergeVNodeHook(vnode, 'insert', function () {
  7466. var parent = el.parentNode;
  7467. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  7468. if (pendingNode &&
  7469. pendingNode.tag === vnode.tag &&
  7470. pendingNode.elm._leaveCb
  7471. ) {
  7472. pendingNode.elm._leaveCb();
  7473. }
  7474. enterHook && enterHook(el, cb);
  7475. });
  7476. }
  7477. // start enter transition
  7478. beforeEnterHook && beforeEnterHook(el);
  7479. if (expectsCSS) {
  7480. addTransitionClass(el, startClass);
  7481. addTransitionClass(el, activeClass);
  7482. nextFrame(function () {
  7483. removeTransitionClass(el, startClass);
  7484. if (!cb.cancelled) {
  7485. addTransitionClass(el, toClass);
  7486. if (!userWantsControl) {
  7487. if (isValidDuration(explicitEnterDuration)) {
  7488. setTimeout(cb, explicitEnterDuration);
  7489. } else {
  7490. whenTransitionEnds(el, type, cb);
  7491. }
  7492. }
  7493. }
  7494. });
  7495. }
  7496. if (vnode.data.show) {
  7497. toggleDisplay && toggleDisplay();
  7498. enterHook && enterHook(el, cb);
  7499. }
  7500. if (!expectsCSS && !userWantsControl) {
  7501. cb();
  7502. }
  7503. }
  7504. function leave (vnode, rm) {
  7505. var el = vnode.elm;
  7506. // call enter callback now
  7507. if (isDef(el._enterCb)) {
  7508. el._enterCb.cancelled = true;
  7509. el._enterCb();
  7510. }
  7511. var data = resolveTransition(vnode.data.transition);
  7512. if (isUndef(data) || el.nodeType !== 1) {
  7513. return rm()
  7514. }
  7515. /* istanbul ignore if */
  7516. if (isDef(el._leaveCb)) {
  7517. return
  7518. }
  7519. var css = data.css;
  7520. var type = data.type;
  7521. var leaveClass = data.leaveClass;
  7522. var leaveToClass = data.leaveToClass;
  7523. var leaveActiveClass = data.leaveActiveClass;
  7524. var beforeLeave = data.beforeLeave;
  7525. var leave = data.leave;
  7526. var afterLeave = data.afterLeave;
  7527. var leaveCancelled = data.leaveCancelled;
  7528. var delayLeave = data.delayLeave;
  7529. var duration = data.duration;
  7530. var expectsCSS = css !== false && !isIE9;
  7531. var userWantsControl = getHookArgumentsLength(leave);
  7532. var explicitLeaveDuration = toNumber(
  7533. isObject(duration)
  7534. ? duration.leave
  7535. : duration
  7536. );
  7537. if (isDef(explicitLeaveDuration)) {
  7538. checkDuration(explicitLeaveDuration, 'leave', vnode);
  7539. }
  7540. var cb = el._leaveCb = once(function () {
  7541. if (el.parentNode && el.parentNode._pending) {
  7542. el.parentNode._pending[vnode.key] = null;
  7543. }
  7544. if (expectsCSS) {
  7545. removeTransitionClass(el, leaveToClass);
  7546. removeTransitionClass(el, leaveActiveClass);
  7547. }
  7548. if (cb.cancelled) {
  7549. if (expectsCSS) {
  7550. removeTransitionClass(el, leaveClass);
  7551. }
  7552. leaveCancelled && leaveCancelled(el);
  7553. } else {
  7554. rm();
  7555. afterLeave && afterLeave(el);
  7556. }
  7557. el._leaveCb = null;
  7558. });
  7559. if (delayLeave) {
  7560. delayLeave(performLeave);
  7561. } else {
  7562. performLeave();
  7563. }
  7564. function performLeave () {
  7565. // the delayed leave may have already been cancelled
  7566. if (cb.cancelled) {
  7567. return
  7568. }
  7569. // record leaving element
  7570. if (!vnode.data.show && el.parentNode) {
  7571. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  7572. }
  7573. beforeLeave && beforeLeave(el);
  7574. if (expectsCSS) {
  7575. addTransitionClass(el, leaveClass);
  7576. addTransitionClass(el, leaveActiveClass);
  7577. nextFrame(function () {
  7578. removeTransitionClass(el, leaveClass);
  7579. if (!cb.cancelled) {
  7580. addTransitionClass(el, leaveToClass);
  7581. if (!userWantsControl) {
  7582. if (isValidDuration(explicitLeaveDuration)) {
  7583. setTimeout(cb, explicitLeaveDuration);
  7584. } else {
  7585. whenTransitionEnds(el, type, cb);
  7586. }
  7587. }
  7588. }
  7589. });
  7590. }
  7591. leave && leave(el, cb);
  7592. if (!expectsCSS && !userWantsControl) {
  7593. cb();
  7594. }
  7595. }
  7596. }
  7597. // only used in dev mode
  7598. function checkDuration (val, name, vnode) {
  7599. if (typeof val !== 'number') {
  7600. warn(
  7601. "<transition> explicit " + name + " duration is not a valid number - " +
  7602. "got " + (JSON.stringify(val)) + ".",
  7603. vnode.context
  7604. );
  7605. } else if (isNaN(val)) {
  7606. warn(
  7607. "<transition> explicit " + name + " duration is NaN - " +
  7608. 'the duration expression might be incorrect.',
  7609. vnode.context
  7610. );
  7611. }
  7612. }
  7613. function isValidDuration (val) {
  7614. return typeof val === 'number' && !isNaN(val)
  7615. }
  7616. /**
  7617. * Normalize a transition hook's argument length. The hook may be:
  7618. * - a merged hook (invoker) with the original in .fns
  7619. * - a wrapped component method (check ._length)
  7620. * - a plain function (.length)
  7621. */
  7622. function getHookArgumentsLength (fn) {
  7623. if (isUndef(fn)) {
  7624. return false
  7625. }
  7626. var invokerFns = fn.fns;
  7627. if (isDef(invokerFns)) {
  7628. // invoker
  7629. return getHookArgumentsLength(
  7630. Array.isArray(invokerFns)
  7631. ? invokerFns[0]
  7632. : invokerFns
  7633. )
  7634. } else {
  7635. return (fn._length || fn.length) > 1
  7636. }
  7637. }
  7638. function _enter (_, vnode) {
  7639. if (vnode.data.show !== true) {
  7640. enter(vnode);
  7641. }
  7642. }
  7643. var transition = inBrowser ? {
  7644. create: _enter,
  7645. activate: _enter,
  7646. remove: function remove$$1 (vnode, rm) {
  7647. /* istanbul ignore else */
  7648. if (vnode.data.show !== true) {
  7649. leave(vnode, rm);
  7650. } else {
  7651. rm();
  7652. }
  7653. }
  7654. } : {};
  7655. var platformModules = [
  7656. attrs,
  7657. klass,
  7658. events,
  7659. domProps,
  7660. style,
  7661. transition
  7662. ];
  7663. /* */
  7664. // the directive module should be applied last, after all
  7665. // built-in modules have been applied.
  7666. var modules = platformModules.concat(baseModules);
  7667. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  7668. /**
  7669. * Not type checking this file because flow doesn't like attaching
  7670. * properties to Elements.
  7671. */
  7672. /* istanbul ignore if */
  7673. if (isIE9) {
  7674. // http://www.matts411.com/post/internet-explorer-9-oninput/
  7675. document.addEventListener('selectionchange', function () {
  7676. var el = document.activeElement;
  7677. if (el && el.vmodel) {
  7678. trigger(el, 'input');
  7679. }
  7680. });
  7681. }
  7682. var directive = {
  7683. inserted: function inserted (el, binding, vnode, oldVnode) {
  7684. if (vnode.tag === 'select') {
  7685. // #6903
  7686. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  7687. mergeVNodeHook(vnode, 'postpatch', function () {
  7688. directive.componentUpdated(el, binding, vnode);
  7689. });
  7690. } else {
  7691. setSelected(el, binding, vnode.context);
  7692. }
  7693. el._vOptions = [].map.call(el.options, getValue);
  7694. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  7695. el._vModifiers = binding.modifiers;
  7696. if (!binding.modifiers.lazy) {
  7697. el.addEventListener('compositionstart', onCompositionStart);
  7698. el.addEventListener('compositionend', onCompositionEnd);
  7699. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  7700. // switching focus before confirming composition choice
  7701. // this also fixes the issue where some browsers e.g. iOS Chrome
  7702. // fires "change" instead of "input" on autocomplete.
  7703. el.addEventListener('change', onCompositionEnd);
  7704. /* istanbul ignore if */
  7705. if (isIE9) {
  7706. el.vmodel = true;
  7707. }
  7708. }
  7709. }
  7710. },
  7711. componentUpdated: function componentUpdated (el, binding, vnode) {
  7712. if (vnode.tag === 'select') {
  7713. setSelected(el, binding, vnode.context);
  7714. // in case the options rendered by v-for have changed,
  7715. // it's possible that the value is out-of-sync with the rendered options.
  7716. // detect such cases and filter out values that no longer has a matching
  7717. // option in the DOM.
  7718. var prevOptions = el._vOptions;
  7719. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  7720. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  7721. // trigger change event if
  7722. // no matching option found for at least one value
  7723. var needReset = el.multiple
  7724. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  7725. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  7726. if (needReset) {
  7727. trigger(el, 'change');
  7728. }
  7729. }
  7730. }
  7731. }
  7732. };
  7733. function setSelected (el, binding, vm) {
  7734. actuallySetSelected(el, binding, vm);
  7735. /* istanbul ignore if */
  7736. if (isIE || isEdge) {
  7737. setTimeout(function () {
  7738. actuallySetSelected(el, binding, vm);
  7739. }, 0);
  7740. }
  7741. }
  7742. function actuallySetSelected (el, binding, vm) {
  7743. var value = binding.value;
  7744. var isMultiple = el.multiple;
  7745. if (isMultiple && !Array.isArray(value)) {
  7746. warn(
  7747. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  7748. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  7749. vm
  7750. );
  7751. return
  7752. }
  7753. var selected, option;
  7754. for (var i = 0, l = el.options.length; i < l; i++) {
  7755. option = el.options[i];
  7756. if (isMultiple) {
  7757. selected = looseIndexOf(value, getValue(option)) > -1;
  7758. if (option.selected !== selected) {
  7759. option.selected = selected;
  7760. }
  7761. } else {
  7762. if (looseEqual(getValue(option), value)) {
  7763. if (el.selectedIndex !== i) {
  7764. el.selectedIndex = i;
  7765. }
  7766. return
  7767. }
  7768. }
  7769. }
  7770. if (!isMultiple) {
  7771. el.selectedIndex = -1;
  7772. }
  7773. }
  7774. function hasNoMatchingOption (value, options) {
  7775. return options.every(function (o) { return !looseEqual(o, value); })
  7776. }
  7777. function getValue (option) {
  7778. return '_value' in option
  7779. ? option._value
  7780. : option.value
  7781. }
  7782. function onCompositionStart (e) {
  7783. e.target.composing = true;
  7784. }
  7785. function onCompositionEnd (e) {
  7786. // prevent triggering an input event for no reason
  7787. if (!e.target.composing) { return }
  7788. e.target.composing = false;
  7789. trigger(e.target, 'input');
  7790. }
  7791. function trigger (el, type) {
  7792. var e = document.createEvent('HTMLEvents');
  7793. e.initEvent(type, true, true);
  7794. el.dispatchEvent(e);
  7795. }
  7796. /* */
  7797. // recursively search for possible transition defined inside the component root
  7798. function locateNode (vnode) {
  7799. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  7800. ? locateNode(vnode.componentInstance._vnode)
  7801. : vnode
  7802. }
  7803. var show = {
  7804. bind: function bind (el, ref, vnode) {
  7805. var value = ref.value;
  7806. vnode = locateNode(vnode);
  7807. var transition$$1 = vnode.data && vnode.data.transition;
  7808. var originalDisplay = el.__vOriginalDisplay =
  7809. el.style.display === 'none' ? '' : el.style.display;
  7810. if (value && transition$$1) {
  7811. vnode.data.show = true;
  7812. enter(vnode, function () {
  7813. el.style.display = originalDisplay;
  7814. });
  7815. } else {
  7816. el.style.display = value ? originalDisplay : 'none';
  7817. }
  7818. },
  7819. update: function update (el, ref, vnode) {
  7820. var value = ref.value;
  7821. var oldValue = ref.oldValue;
  7822. /* istanbul ignore if */
  7823. if (!value === !oldValue) { return }
  7824. vnode = locateNode(vnode);
  7825. var transition$$1 = vnode.data && vnode.data.transition;
  7826. if (transition$$1) {
  7827. vnode.data.show = true;
  7828. if (value) {
  7829. enter(vnode, function () {
  7830. el.style.display = el.__vOriginalDisplay;
  7831. });
  7832. } else {
  7833. leave(vnode, function () {
  7834. el.style.display = 'none';
  7835. });
  7836. }
  7837. } else {
  7838. el.style.display = value ? el.__vOriginalDisplay : 'none';
  7839. }
  7840. },
  7841. unbind: function unbind (
  7842. el,
  7843. binding,
  7844. vnode,
  7845. oldVnode,
  7846. isDestroy
  7847. ) {
  7848. if (!isDestroy) {
  7849. el.style.display = el.__vOriginalDisplay;
  7850. }
  7851. }
  7852. };
  7853. var platformDirectives = {
  7854. model: directive,
  7855. show: show
  7856. };
  7857. /* */
  7858. var transitionProps = {
  7859. name: String,
  7860. appear: Boolean,
  7861. css: Boolean,
  7862. mode: String,
  7863. type: String,
  7864. enterClass: String,
  7865. leaveClass: String,
  7866. enterToClass: String,
  7867. leaveToClass: String,
  7868. enterActiveClass: String,
  7869. leaveActiveClass: String,
  7870. appearClass: String,
  7871. appearActiveClass: String,
  7872. appearToClass: String,
  7873. duration: [Number, String, Object]
  7874. };
  7875. // in case the child is also an abstract component, e.g. <keep-alive>
  7876. // we want to recursively retrieve the real component to be rendered
  7877. function getRealChild (vnode) {
  7878. var compOptions = vnode && vnode.componentOptions;
  7879. if (compOptions && compOptions.Ctor.options.abstract) {
  7880. return getRealChild(getFirstComponentChild(compOptions.children))
  7881. } else {
  7882. return vnode
  7883. }
  7884. }
  7885. function extractTransitionData (comp) {
  7886. var data = {};
  7887. var options = comp.$options;
  7888. // props
  7889. for (var key in options.propsData) {
  7890. data[key] = comp[key];
  7891. }
  7892. // events.
  7893. // extract listeners and pass them directly to the transition methods
  7894. var listeners = options._parentListeners;
  7895. for (var key$1 in listeners) {
  7896. data[camelize(key$1)] = listeners[key$1];
  7897. }
  7898. return data
  7899. }
  7900. function placeholder (h, rawChild) {
  7901. if (/\d-keep-alive$/.test(rawChild.tag)) {
  7902. return h('keep-alive', {
  7903. props: rawChild.componentOptions.propsData
  7904. })
  7905. }
  7906. }
  7907. function hasParentTransition (vnode) {
  7908. while ((vnode = vnode.parent)) {
  7909. if (vnode.data.transition) {
  7910. return true
  7911. }
  7912. }
  7913. }
  7914. function isSameChild (child, oldChild) {
  7915. return oldChild.key === child.key && oldChild.tag === child.tag
  7916. }
  7917. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  7918. var isVShowDirective = function (d) { return d.name === 'show'; };
  7919. var Transition = {
  7920. name: 'transition',
  7921. props: transitionProps,
  7922. abstract: true,
  7923. render: function render (h) {
  7924. var this$1 = this;
  7925. var children = this.$slots.default;
  7926. if (!children) {
  7927. return
  7928. }
  7929. // filter out text nodes (possible whitespaces)
  7930. children = children.filter(isNotTextNode);
  7931. /* istanbul ignore if */
  7932. if (!children.length) {
  7933. return
  7934. }
  7935. // warn multiple elements
  7936. if (children.length > 1) {
  7937. warn(
  7938. '<transition> can only be used on a single element. Use ' +
  7939. '<transition-group> for lists.',
  7940. this.$parent
  7941. );
  7942. }
  7943. var mode = this.mode;
  7944. // warn invalid mode
  7945. if (mode && mode !== 'in-out' && mode !== 'out-in'
  7946. ) {
  7947. warn(
  7948. 'invalid <transition> mode: ' + mode,
  7949. this.$parent
  7950. );
  7951. }
  7952. var rawChild = children[0];
  7953. // if this is a component root node and the component's
  7954. // parent container node also has transition, skip.
  7955. if (hasParentTransition(this.$vnode)) {
  7956. return rawChild
  7957. }
  7958. // apply transition data to child
  7959. // use getRealChild() to ignore abstract components e.g. keep-alive
  7960. var child = getRealChild(rawChild);
  7961. /* istanbul ignore if */
  7962. if (!child) {
  7963. return rawChild
  7964. }
  7965. if (this._leaving) {
  7966. return placeholder(h, rawChild)
  7967. }
  7968. // ensure a key that is unique to the vnode type and to this transition
  7969. // component instance. This key will be used to remove pending leaving nodes
  7970. // during entering.
  7971. var id = "__transition-" + (this._uid) + "-";
  7972. child.key = child.key == null
  7973. ? child.isComment
  7974. ? id + 'comment'
  7975. : id + child.tag
  7976. : isPrimitive(child.key)
  7977. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  7978. : child.key;
  7979. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  7980. var oldRawChild = this._vnode;
  7981. var oldChild = getRealChild(oldRawChild);
  7982. // mark v-show
  7983. // so that the transition module can hand over the control to the directive
  7984. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  7985. child.data.show = true;
  7986. }
  7987. if (
  7988. oldChild &&
  7989. oldChild.data &&
  7990. !isSameChild(child, oldChild) &&
  7991. !isAsyncPlaceholder(oldChild) &&
  7992. // #6687 component root is a comment node
  7993. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  7994. ) {
  7995. // replace old child transition data with fresh one
  7996. // important for dynamic transitions!
  7997. var oldData = oldChild.data.transition = extend({}, data);
  7998. // handle transition mode
  7999. if (mode === 'out-in') {
  8000. // return placeholder node and queue update when leave finishes
  8001. this._leaving = true;
  8002. mergeVNodeHook(oldData, 'afterLeave', function () {
  8003. this$1._leaving = false;
  8004. this$1.$forceUpdate();
  8005. });
  8006. return placeholder(h, rawChild)
  8007. } else if (mode === 'in-out') {
  8008. if (isAsyncPlaceholder(child)) {
  8009. return oldRawChild
  8010. }
  8011. var delayedLeave;
  8012. var performLeave = function () { delayedLeave(); };
  8013. mergeVNodeHook(data, 'afterEnter', performLeave);
  8014. mergeVNodeHook(data, 'enterCancelled', performLeave);
  8015. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  8016. }
  8017. }
  8018. return rawChild
  8019. }
  8020. };
  8021. /* */
  8022. var props = extend({
  8023. tag: String,
  8024. moveClass: String
  8025. }, transitionProps);
  8026. delete props.mode;
  8027. var TransitionGroup = {
  8028. props: props,
  8029. beforeMount: function beforeMount () {
  8030. var this$1 = this;
  8031. var update = this._update;
  8032. this._update = function (vnode, hydrating) {
  8033. var restoreActiveInstance = setActiveInstance(this$1);
  8034. // force removing pass
  8035. this$1.__patch__(
  8036. this$1._vnode,
  8037. this$1.kept,
  8038. false, // hydrating
  8039. true // removeOnly (!important, avoids unnecessary moves)
  8040. );
  8041. this$1._vnode = this$1.kept;
  8042. restoreActiveInstance();
  8043. update.call(this$1, vnode, hydrating);
  8044. };
  8045. },
  8046. render: function render (h) {
  8047. var tag = this.tag || this.$vnode.data.tag || 'span';
  8048. var map = Object.create(null);
  8049. var prevChildren = this.prevChildren = this.children;
  8050. var rawChildren = this.$slots.default || [];
  8051. var children = this.children = [];
  8052. var transitionData = extractTransitionData(this);
  8053. for (var i = 0; i < rawChildren.length; i++) {
  8054. var c = rawChildren[i];
  8055. if (c.tag) {
  8056. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  8057. children.push(c);
  8058. map[c.key] = c
  8059. ;(c.data || (c.data = {})).transition = transitionData;
  8060. } else {
  8061. var opts = c.componentOptions;
  8062. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  8063. warn(("<transition-group> children must be keyed: <" + name + ">"));
  8064. }
  8065. }
  8066. }
  8067. if (prevChildren) {
  8068. var kept = [];
  8069. var removed = [];
  8070. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  8071. var c$1 = prevChildren[i$1];
  8072. c$1.data.transition = transitionData;
  8073. c$1.data.pos = c$1.elm.getBoundingClientRect();
  8074. if (map[c$1.key]) {
  8075. kept.push(c$1);
  8076. } else {
  8077. removed.push(c$1);
  8078. }
  8079. }
  8080. this.kept = h(tag, null, kept);
  8081. this.removed = removed;
  8082. }
  8083. return h(tag, null, children)
  8084. },
  8085. updated: function updated () {
  8086. var children = this.prevChildren;
  8087. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  8088. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  8089. return
  8090. }
  8091. // we divide the work into three loops to avoid mixing DOM reads and writes
  8092. // in each iteration - which helps prevent layout thrashing.
  8093. children.forEach(callPendingCbs);
  8094. children.forEach(recordPosition);
  8095. children.forEach(applyTranslation);
  8096. // force reflow to put everything in position
  8097. // assign to this to avoid being removed in tree-shaking
  8098. // $flow-disable-line
  8099. this._reflow = document.body.offsetHeight;
  8100. children.forEach(function (c) {
  8101. if (c.data.moved) {
  8102. var el = c.elm;
  8103. var s = el.style;
  8104. addTransitionClass(el, moveClass);
  8105. s.transform = s.WebkitTransform = s.transitionDuration = '';
  8106. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  8107. if (e && e.target !== el) {
  8108. return
  8109. }
  8110. if (!e || /transform$/.test(e.propertyName)) {
  8111. el.removeEventListener(transitionEndEvent, cb);
  8112. el._moveCb = null;
  8113. removeTransitionClass(el, moveClass);
  8114. }
  8115. });
  8116. }
  8117. });
  8118. },
  8119. methods: {
  8120. hasMove: function hasMove (el, moveClass) {
  8121. /* istanbul ignore if */
  8122. if (!hasTransition) {
  8123. return false
  8124. }
  8125. /* istanbul ignore if */
  8126. if (this._hasMove) {
  8127. return this._hasMove
  8128. }
  8129. // Detect whether an element with the move class applied has
  8130. // CSS transitions. Since the element may be inside an entering
  8131. // transition at this very moment, we make a clone of it and remove
  8132. // all other transition classes applied to ensure only the move class
  8133. // is applied.
  8134. var clone = el.cloneNode();
  8135. if (el._transitionClasses) {
  8136. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  8137. }
  8138. addClass(clone, moveClass);
  8139. clone.style.display = 'none';
  8140. this.$el.appendChild(clone);
  8141. var info = getTransitionInfo(clone);
  8142. this.$el.removeChild(clone);
  8143. return (this._hasMove = info.hasTransform)
  8144. }
  8145. }
  8146. };
  8147. function callPendingCbs (c) {
  8148. /* istanbul ignore if */
  8149. if (c.elm._moveCb) {
  8150. c.elm._moveCb();
  8151. }
  8152. /* istanbul ignore if */
  8153. if (c.elm._enterCb) {
  8154. c.elm._enterCb();
  8155. }
  8156. }
  8157. function recordPosition (c) {
  8158. c.data.newPos = c.elm.getBoundingClientRect();
  8159. }
  8160. function applyTranslation (c) {
  8161. var oldPos = c.data.pos;
  8162. var newPos = c.data.newPos;
  8163. var dx = oldPos.left - newPos.left;
  8164. var dy = oldPos.top - newPos.top;
  8165. if (dx || dy) {
  8166. c.data.moved = true;
  8167. var s = c.elm.style;
  8168. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  8169. s.transitionDuration = '0s';
  8170. }
  8171. }
  8172. var platformComponents = {
  8173. Transition: Transition,
  8174. TransitionGroup: TransitionGroup
  8175. };
  8176. /* */
  8177. // install platform specific utils
  8178. Vue.config.mustUseProp = mustUseProp;
  8179. Vue.config.isReservedTag = isReservedTag;
  8180. Vue.config.isReservedAttr = isReservedAttr;
  8181. Vue.config.getTagNamespace = getTagNamespace;
  8182. Vue.config.isUnknownElement = isUnknownElement;
  8183. // install platform runtime directives & components
  8184. extend(Vue.options.directives, platformDirectives);
  8185. extend(Vue.options.components, platformComponents);
  8186. // install platform patch function
  8187. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  8188. // public mount method
  8189. Vue.prototype.$mount = function (
  8190. el,
  8191. hydrating
  8192. ) {
  8193. el = el && inBrowser ? query(el) : undefined;
  8194. return mountComponent(this, el, hydrating)
  8195. };
  8196. // devtools global hook
  8197. /* istanbul ignore next */
  8198. if (inBrowser) {
  8199. setTimeout(function () {
  8200. if (config.devtools) {
  8201. if (devtools) {
  8202. devtools.emit('init', Vue);
  8203. } else {
  8204. console[console.info ? 'info' : 'log'](
  8205. 'Download the Vue Devtools extension for a better development experience:\n' +
  8206. 'https://github.com/vuejs/vue-devtools'
  8207. );
  8208. }
  8209. }
  8210. if (config.productionTip !== false &&
  8211. typeof console !== 'undefined'
  8212. ) {
  8213. console[console.info ? 'info' : 'log'](
  8214. "You are running Vue in development mode.\n" +
  8215. "Make sure to turn on production mode when deploying for production.\n" +
  8216. "See more tips at https://vuejs.org/guide/deployment.html"
  8217. );
  8218. }
  8219. }, 0);
  8220. }
  8221. /* */
  8222. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  8223. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  8224. var buildRegex = cached(function (delimiters) {
  8225. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  8226. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  8227. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  8228. });
  8229. function parseText (
  8230. text,
  8231. delimiters
  8232. ) {
  8233. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  8234. if (!tagRE.test(text)) {
  8235. return
  8236. }
  8237. var tokens = [];
  8238. var rawTokens = [];
  8239. var lastIndex = tagRE.lastIndex = 0;
  8240. var match, index, tokenValue;
  8241. while ((match = tagRE.exec(text))) {
  8242. index = match.index;
  8243. // push text token
  8244. if (index > lastIndex) {
  8245. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  8246. tokens.push(JSON.stringify(tokenValue));
  8247. }
  8248. // tag token
  8249. var exp = parseFilters(match[1].trim());
  8250. tokens.push(("_s(" + exp + ")"));
  8251. rawTokens.push({ '@binding': exp });
  8252. lastIndex = index + match[0].length;
  8253. }
  8254. if (lastIndex < text.length) {
  8255. rawTokens.push(tokenValue = text.slice(lastIndex));
  8256. tokens.push(JSON.stringify(tokenValue));
  8257. }
  8258. return {
  8259. expression: tokens.join('+'),
  8260. tokens: rawTokens
  8261. }
  8262. }
  8263. /* */
  8264. function transformNode (el, options) {
  8265. var warn = options.warn || baseWarn;
  8266. var staticClass = getAndRemoveAttr(el, 'class');
  8267. if (staticClass) {
  8268. var res = parseText(staticClass, options.delimiters);
  8269. if (res) {
  8270. warn(
  8271. "class=\"" + staticClass + "\": " +
  8272. 'Interpolation inside attributes has been removed. ' +
  8273. 'Use v-bind or the colon shorthand instead. For example, ' +
  8274. 'instead of <div class="{{ val }}">, use <div :class="val">.',
  8275. el.rawAttrsMap['class']
  8276. );
  8277. }
  8278. }
  8279. if (staticClass) {
  8280. el.staticClass = JSON.stringify(staticClass);
  8281. }
  8282. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  8283. if (classBinding) {
  8284. el.classBinding = classBinding;
  8285. }
  8286. }
  8287. function genData (el) {
  8288. var data = '';
  8289. if (el.staticClass) {
  8290. data += "staticClass:" + (el.staticClass) + ",";
  8291. }
  8292. if (el.classBinding) {
  8293. data += "class:" + (el.classBinding) + ",";
  8294. }
  8295. return data
  8296. }
  8297. var klass$1 = {
  8298. staticKeys: ['staticClass'],
  8299. transformNode: transformNode,
  8300. genData: genData
  8301. };
  8302. /* */
  8303. function transformNode$1 (el, options) {
  8304. var warn = options.warn || baseWarn;
  8305. var staticStyle = getAndRemoveAttr(el, 'style');
  8306. if (staticStyle) {
  8307. /* istanbul ignore if */
  8308. {
  8309. var res = parseText(staticStyle, options.delimiters);
  8310. if (res) {
  8311. warn(
  8312. "style=\"" + staticStyle + "\": " +
  8313. 'Interpolation inside attributes has been removed. ' +
  8314. 'Use v-bind or the colon shorthand instead. For example, ' +
  8315. 'instead of <div style="{{ val }}">, use <div :style="val">.',
  8316. el.rawAttrsMap['style']
  8317. );
  8318. }
  8319. }
  8320. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  8321. }
  8322. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  8323. if (styleBinding) {
  8324. el.styleBinding = styleBinding;
  8325. }
  8326. }
  8327. function genData$1 (el) {
  8328. var data = '';
  8329. if (el.staticStyle) {
  8330. data += "staticStyle:" + (el.staticStyle) + ",";
  8331. }
  8332. if (el.styleBinding) {
  8333. data += "style:(" + (el.styleBinding) + "),";
  8334. }
  8335. return data
  8336. }
  8337. var style$1 = {
  8338. staticKeys: ['staticStyle'],
  8339. transformNode: transformNode$1,
  8340. genData: genData$1
  8341. };
  8342. /* */
  8343. var decoder;
  8344. var he = {
  8345. decode: function decode (html) {
  8346. decoder = decoder || document.createElement('div');
  8347. decoder.innerHTML = html;
  8348. return decoder.textContent
  8349. }
  8350. };
  8351. /* */
  8352. var isUnaryTag = makeMap(
  8353. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  8354. 'link,meta,param,source,track,wbr'
  8355. );
  8356. // Elements that you can, intentionally, leave open
  8357. // (and which close themselves)
  8358. var canBeLeftOpenTag = makeMap(
  8359. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  8360. );
  8361. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  8362. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  8363. var isNonPhrasingTag = makeMap(
  8364. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  8365. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  8366. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  8367. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  8368. 'title,tr,track'
  8369. );
  8370. /**
  8371. * Not type-checking this file because it's mostly vendor code.
  8372. */
  8373. // Regular Expressions for parsing tags and attributes
  8374. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  8375. var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  8376. var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*";
  8377. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  8378. var startTagOpen = new RegExp(("^<" + qnameCapture));
  8379. var startTagClose = /^\s*(\/?)>/;
  8380. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  8381. var doctype = /^<!DOCTYPE [^>]+>/i;
  8382. // #7298: escape - to avoid being passed as HTML comment when inlined in page
  8383. var comment = /^<!\--/;
  8384. var conditionalComment = /^<!\[/;
  8385. // Special Elements (can contain anything)
  8386. var isPlainTextElement = makeMap('script,style,textarea', true);
  8387. var reCache = {};
  8388. var decodingMap = {
  8389. '&lt;': '<',
  8390. '&gt;': '>',
  8391. '&quot;': '"',
  8392. '&amp;': '&',
  8393. '&#10;': '\n',
  8394. '&#9;': '\t',
  8395. '&#39;': "'"
  8396. };
  8397. var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g;
  8398. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g;
  8399. // #5992
  8400. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  8401. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  8402. function decodeAttr (value, shouldDecodeNewlines) {
  8403. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  8404. return value.replace(re, function (match) { return decodingMap[match]; })
  8405. }
  8406. function parseHTML (html, options) {
  8407. var stack = [];
  8408. var expectHTML = options.expectHTML;
  8409. var isUnaryTag$$1 = options.isUnaryTag || no;
  8410. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  8411. var index = 0;
  8412. var last, lastTag;
  8413. while (html) {
  8414. last = html;
  8415. // Make sure we're not in a plaintext content element like script/style
  8416. if (!lastTag || !isPlainTextElement(lastTag)) {
  8417. var textEnd = html.indexOf('<');
  8418. if (textEnd === 0) {
  8419. // Comment:
  8420. if (comment.test(html)) {
  8421. var commentEnd = html.indexOf('-->');
  8422. if (commentEnd >= 0) {
  8423. if (options.shouldKeepComment) {
  8424. options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3);
  8425. }
  8426. advance(commentEnd + 3);
  8427. continue
  8428. }
  8429. }
  8430. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  8431. if (conditionalComment.test(html)) {
  8432. var conditionalEnd = html.indexOf(']>');
  8433. if (conditionalEnd >= 0) {
  8434. advance(conditionalEnd + 2);
  8435. continue
  8436. }
  8437. }
  8438. // Doctype:
  8439. var doctypeMatch = html.match(doctype);
  8440. if (doctypeMatch) {
  8441. advance(doctypeMatch[0].length);
  8442. continue
  8443. }
  8444. // End tag:
  8445. var endTagMatch = html.match(endTag);
  8446. if (endTagMatch) {
  8447. var curIndex = index;
  8448. advance(endTagMatch[0].length);
  8449. parseEndTag(endTagMatch[1], curIndex, index);
  8450. continue
  8451. }
  8452. // Start tag:
  8453. var startTagMatch = parseStartTag();
  8454. if (startTagMatch) {
  8455. handleStartTag(startTagMatch);
  8456. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  8457. advance(1);
  8458. }
  8459. continue
  8460. }
  8461. }
  8462. var text = (void 0), rest = (void 0), next = (void 0);
  8463. if (textEnd >= 0) {
  8464. rest = html.slice(textEnd);
  8465. while (
  8466. !endTag.test(rest) &&
  8467. !startTagOpen.test(rest) &&
  8468. !comment.test(rest) &&
  8469. !conditionalComment.test(rest)
  8470. ) {
  8471. // < in plain text, be forgiving and treat it as text
  8472. next = rest.indexOf('<', 1);
  8473. if (next < 0) { break }
  8474. textEnd += next;
  8475. rest = html.slice(textEnd);
  8476. }
  8477. text = html.substring(0, textEnd);
  8478. }
  8479. if (textEnd < 0) {
  8480. text = html;
  8481. }
  8482. if (text) {
  8483. advance(text.length);
  8484. }
  8485. if (options.chars && text) {
  8486. options.chars(text, index - text.length, index);
  8487. }
  8488. } else {
  8489. var endTagLength = 0;
  8490. var stackedTag = lastTag.toLowerCase();
  8491. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  8492. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  8493. endTagLength = endTag.length;
  8494. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  8495. text = text
  8496. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  8497. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  8498. }
  8499. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  8500. text = text.slice(1);
  8501. }
  8502. if (options.chars) {
  8503. options.chars(text);
  8504. }
  8505. return ''
  8506. });
  8507. index += html.length - rest$1.length;
  8508. html = rest$1;
  8509. parseEndTag(stackedTag, index - endTagLength, index);
  8510. }
  8511. if (html === last) {
  8512. options.chars && options.chars(html);
  8513. if (!stack.length && options.warn) {
  8514. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length });
  8515. }
  8516. break
  8517. }
  8518. }
  8519. // Clean up any remaining tags
  8520. parseEndTag();
  8521. function advance (n) {
  8522. index += n;
  8523. html = html.substring(n);
  8524. }
  8525. function parseStartTag () {
  8526. var start = html.match(startTagOpen);
  8527. if (start) {
  8528. var match = {
  8529. tagName: start[1],
  8530. attrs: [],
  8531. start: index
  8532. };
  8533. advance(start[0].length);
  8534. var end, attr;
  8535. while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) {
  8536. attr.start = index;
  8537. advance(attr[0].length);
  8538. attr.end = index;
  8539. match.attrs.push(attr);
  8540. }
  8541. if (end) {
  8542. match.unarySlash = end[1];
  8543. advance(end[0].length);
  8544. match.end = index;
  8545. return match
  8546. }
  8547. }
  8548. }
  8549. function handleStartTag (match) {
  8550. var tagName = match.tagName;
  8551. var unarySlash = match.unarySlash;
  8552. if (expectHTML) {
  8553. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  8554. parseEndTag(lastTag);
  8555. }
  8556. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  8557. parseEndTag(tagName);
  8558. }
  8559. }
  8560. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  8561. var l = match.attrs.length;
  8562. var attrs = new Array(l);
  8563. for (var i = 0; i < l; i++) {
  8564. var args = match.attrs[i];
  8565. var value = args[3] || args[4] || args[5] || '';
  8566. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  8567. ? options.shouldDecodeNewlinesForHref
  8568. : options.shouldDecodeNewlines;
  8569. attrs[i] = {
  8570. name: args[1],
  8571. value: decodeAttr(value, shouldDecodeNewlines)
  8572. };
  8573. if (options.outputSourceRange) {
  8574. attrs[i].start = args.start + args[0].match(/^\s*/).length;
  8575. attrs[i].end = args.end;
  8576. }
  8577. }
  8578. if (!unary) {
  8579. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end });
  8580. lastTag = tagName;
  8581. }
  8582. if (options.start) {
  8583. options.start(tagName, attrs, unary, match.start, match.end);
  8584. }
  8585. }
  8586. function parseEndTag (tagName, start, end) {
  8587. var pos, lowerCasedTagName;
  8588. if (start == null) { start = index; }
  8589. if (end == null) { end = index; }
  8590. // Find the closest opened tag of the same type
  8591. if (tagName) {
  8592. lowerCasedTagName = tagName.toLowerCase();
  8593. for (pos = stack.length - 1; pos >= 0; pos--) {
  8594. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  8595. break
  8596. }
  8597. }
  8598. } else {
  8599. // If no tag name is provided, clean shop
  8600. pos = 0;
  8601. }
  8602. if (pos >= 0) {
  8603. // Close all the open elements, up the stack
  8604. for (var i = stack.length - 1; i >= pos; i--) {
  8605. if (i > pos || !tagName &&
  8606. options.warn
  8607. ) {
  8608. options.warn(
  8609. ("tag <" + (stack[i].tag) + "> has no matching end tag."),
  8610. { start: stack[i].start, end: stack[i].end }
  8611. );
  8612. }
  8613. if (options.end) {
  8614. options.end(stack[i].tag, start, end);
  8615. }
  8616. }
  8617. // Remove the open elements from the stack
  8618. stack.length = pos;
  8619. lastTag = pos && stack[pos - 1].tag;
  8620. } else if (lowerCasedTagName === 'br') {
  8621. if (options.start) {
  8622. options.start(tagName, [], true, start, end);
  8623. }
  8624. } else if (lowerCasedTagName === 'p') {
  8625. if (options.start) {
  8626. options.start(tagName, [], false, start, end);
  8627. }
  8628. if (options.end) {
  8629. options.end(tagName, start, end);
  8630. }
  8631. }
  8632. }
  8633. }
  8634. /* */
  8635. var onRE = /^@|^v-on:/;
  8636. var dirRE = /^v-|^@|^:|^#/;
  8637. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  8638. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  8639. var stripParensRE = /^\(|\)$/g;
  8640. var dynamicArgRE = /^\[.*\]$/;
  8641. var argRE = /:(.*)$/;
  8642. var bindRE = /^:|^\.|^v-bind:/;
  8643. var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g;
  8644. var slotRE = /^v-slot(:|$)|^#/;
  8645. var lineBreakRE = /[\r\n]/;
  8646. var whitespaceRE$1 = /[ \f\t\r\n]+/g;
  8647. var invalidAttributeRE = /[\s"'<>\/=]/;
  8648. var decodeHTMLCached = cached(he.decode);
  8649. var emptySlotScopeToken = "_empty_";
  8650. // configurable state
  8651. var warn$2;
  8652. var delimiters;
  8653. var transforms;
  8654. var preTransforms;
  8655. var postTransforms;
  8656. var platformIsPreTag;
  8657. var platformMustUseProp;
  8658. var platformGetTagNamespace;
  8659. var maybeComponent;
  8660. function createASTElement (
  8661. tag,
  8662. attrs,
  8663. parent
  8664. ) {
  8665. return {
  8666. type: 1,
  8667. tag: tag,
  8668. attrsList: attrs,
  8669. attrsMap: makeAttrsMap(attrs),
  8670. rawAttrsMap: {},
  8671. parent: parent,
  8672. children: []
  8673. }
  8674. }
  8675. /**
  8676. * Convert HTML string to AST.
  8677. */
  8678. function parse (
  8679. template,
  8680. options
  8681. ) {
  8682. warn$2 = options.warn || baseWarn;
  8683. platformIsPreTag = options.isPreTag || no;
  8684. platformMustUseProp = options.mustUseProp || no;
  8685. platformGetTagNamespace = options.getTagNamespace || no;
  8686. var isReservedTag = options.isReservedTag || no;
  8687. maybeComponent = function (el) { return !!(
  8688. el.component ||
  8689. el.attrsMap[':is'] ||
  8690. el.attrsMap['v-bind:is'] ||
  8691. !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag))
  8692. ); };
  8693. transforms = pluckModuleFunction(options.modules, 'transformNode');
  8694. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  8695. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  8696. delimiters = options.delimiters;
  8697. var stack = [];
  8698. var preserveWhitespace = options.preserveWhitespace !== false;
  8699. var whitespaceOption = options.whitespace;
  8700. var root;
  8701. var currentParent;
  8702. var inVPre = false;
  8703. var inPre = false;
  8704. var warned = false;
  8705. function warnOnce (msg, range) {
  8706. if (!warned) {
  8707. warned = true;
  8708. warn$2(msg, range);
  8709. }
  8710. }
  8711. function closeElement (element) {
  8712. trimEndingWhitespace(element);
  8713. if (!inVPre && !element.processed) {
  8714. element = processElement(element, options);
  8715. }
  8716. // tree management
  8717. if (!stack.length && element !== root) {
  8718. // allow root elements with v-if, v-else-if and v-else
  8719. if (root.if && (element.elseif || element.else)) {
  8720. {
  8721. checkRootConstraints(element);
  8722. }
  8723. addIfCondition(root, {
  8724. exp: element.elseif,
  8725. block: element
  8726. });
  8727. } else {
  8728. warnOnce(
  8729. "Component template should contain exactly one root element. " +
  8730. "If you are using v-if on multiple elements, " +
  8731. "use v-else-if to chain them instead.",
  8732. { start: element.start }
  8733. );
  8734. }
  8735. }
  8736. if (currentParent && !element.forbidden) {
  8737. if (element.elseif || element.else) {
  8738. processIfConditions(element, currentParent);
  8739. } else {
  8740. if (element.slotScope) {
  8741. // scoped slot
  8742. // keep it in the children list so that v-else(-if) conditions can
  8743. // find it as the prev node.
  8744. var name = element.slotTarget || '"default"'
  8745. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  8746. }
  8747. currentParent.children.push(element);
  8748. element.parent = currentParent;
  8749. }
  8750. }
  8751. // final children cleanup
  8752. // filter out scoped slots
  8753. element.children = element.children.filter(function (c) { return !(c).slotScope; });
  8754. // remove trailing whitespace node again
  8755. trimEndingWhitespace(element);
  8756. // check pre state
  8757. if (element.pre) {
  8758. inVPre = false;
  8759. }
  8760. if (platformIsPreTag(element.tag)) {
  8761. inPre = false;
  8762. }
  8763. // apply post-transforms
  8764. for (var i = 0; i < postTransforms.length; i++) {
  8765. postTransforms[i](element, options);
  8766. }
  8767. }
  8768. function trimEndingWhitespace (el) {
  8769. // remove trailing whitespace node
  8770. if (!inPre) {
  8771. var lastNode;
  8772. while (
  8773. (lastNode = el.children[el.children.length - 1]) &&
  8774. lastNode.type === 3 &&
  8775. lastNode.text === ' '
  8776. ) {
  8777. el.children.pop();
  8778. }
  8779. }
  8780. }
  8781. function checkRootConstraints (el) {
  8782. if (el.tag === 'slot' || el.tag === 'template') {
  8783. warnOnce(
  8784. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  8785. 'contain multiple nodes.',
  8786. { start: el.start }
  8787. );
  8788. }
  8789. if (el.attrsMap.hasOwnProperty('v-for')) {
  8790. warnOnce(
  8791. 'Cannot use v-for on stateful component root element because ' +
  8792. 'it renders multiple elements.',
  8793. el.rawAttrsMap['v-for']
  8794. );
  8795. }
  8796. }
  8797. parseHTML(template, {
  8798. warn: warn$2,
  8799. expectHTML: options.expectHTML,
  8800. isUnaryTag: options.isUnaryTag,
  8801. canBeLeftOpenTag: options.canBeLeftOpenTag,
  8802. shouldDecodeNewlines: options.shouldDecodeNewlines,
  8803. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  8804. shouldKeepComment: options.comments,
  8805. outputSourceRange: options.outputSourceRange,
  8806. start: function start (tag, attrs, unary, start$1, end) {
  8807. // check namespace.
  8808. // inherit parent ns if there is one
  8809. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  8810. // handle IE svg bug
  8811. /* istanbul ignore if */
  8812. if (isIE && ns === 'svg') {
  8813. attrs = guardIESVGBug(attrs);
  8814. }
  8815. var element = createASTElement(tag, attrs, currentParent);
  8816. if (ns) {
  8817. element.ns = ns;
  8818. }
  8819. {
  8820. if (options.outputSourceRange) {
  8821. element.start = start$1;
  8822. element.end = end;
  8823. element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) {
  8824. cumulated[attr.name] = attr;
  8825. return cumulated
  8826. }, {});
  8827. }
  8828. attrs.forEach(function (attr) {
  8829. if (invalidAttributeRE.test(attr.name)) {
  8830. warn$2(
  8831. "Invalid dynamic argument expression: attribute names cannot contain " +
  8832. "spaces, quotes, <, >, / or =.",
  8833. {
  8834. start: attr.start + attr.name.indexOf("["),
  8835. end: attr.start + attr.name.length
  8836. }
  8837. );
  8838. }
  8839. });
  8840. }
  8841. if (isForbiddenTag(element) && !isServerRendering()) {
  8842. element.forbidden = true;
  8843. warn$2(
  8844. 'Templates should only be responsible for mapping the state to the ' +
  8845. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  8846. "<" + tag + ">" + ', as they will not be parsed.',
  8847. { start: element.start }
  8848. );
  8849. }
  8850. // apply pre-transforms
  8851. for (var i = 0; i < preTransforms.length; i++) {
  8852. element = preTransforms[i](element, options) || element;
  8853. }
  8854. if (!inVPre) {
  8855. processPre(element);
  8856. if (element.pre) {
  8857. inVPre = true;
  8858. }
  8859. }
  8860. if (platformIsPreTag(element.tag)) {
  8861. inPre = true;
  8862. }
  8863. if (inVPre) {
  8864. processRawAttrs(element);
  8865. } else if (!element.processed) {
  8866. // structural directives
  8867. processFor(element);
  8868. processIf(element);
  8869. processOnce(element);
  8870. }
  8871. if (!root) {
  8872. root = element;
  8873. {
  8874. checkRootConstraints(root);
  8875. }
  8876. }
  8877. if (!unary) {
  8878. currentParent = element;
  8879. stack.push(element);
  8880. } else {
  8881. closeElement(element);
  8882. }
  8883. },
  8884. end: function end (tag, start, end$1) {
  8885. var element = stack[stack.length - 1];
  8886. // pop stack
  8887. stack.length -= 1;
  8888. currentParent = stack[stack.length - 1];
  8889. if (options.outputSourceRange) {
  8890. element.end = end$1;
  8891. }
  8892. closeElement(element);
  8893. },
  8894. chars: function chars (text, start, end) {
  8895. if (!currentParent) {
  8896. {
  8897. if (text === template) {
  8898. warnOnce(
  8899. 'Component template requires a root element, rather than just text.',
  8900. { start: start }
  8901. );
  8902. } else if ((text = text.trim())) {
  8903. warnOnce(
  8904. ("text \"" + text + "\" outside root element will be ignored."),
  8905. { start: start }
  8906. );
  8907. }
  8908. }
  8909. return
  8910. }
  8911. // IE textarea placeholder bug
  8912. /* istanbul ignore if */
  8913. if (isIE &&
  8914. currentParent.tag === 'textarea' &&
  8915. currentParent.attrsMap.placeholder === text
  8916. ) {
  8917. return
  8918. }
  8919. var children = currentParent.children;
  8920. if (inPre || text.trim()) {
  8921. text = isTextTag(currentParent) ? text : decodeHTMLCached(text);
  8922. } else if (!children.length) {
  8923. // remove the whitespace-only node right after an opening tag
  8924. text = '';
  8925. } else if (whitespaceOption) {
  8926. if (whitespaceOption === 'condense') {
  8927. // in condense mode, remove the whitespace node if it contains
  8928. // line break, otherwise condense to a single space
  8929. text = lineBreakRE.test(text) ? '' : ' ';
  8930. } else {
  8931. text = ' ';
  8932. }
  8933. } else {
  8934. text = preserveWhitespace ? ' ' : '';
  8935. }
  8936. if (text) {
  8937. if (!inPre && whitespaceOption === 'condense') {
  8938. // condense consecutive whitespaces into single space
  8939. text = text.replace(whitespaceRE$1, ' ');
  8940. }
  8941. var res;
  8942. var child;
  8943. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  8944. child = {
  8945. type: 2,
  8946. expression: res.expression,
  8947. tokens: res.tokens,
  8948. text: text
  8949. };
  8950. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  8951. child = {
  8952. type: 3,
  8953. text: text
  8954. };
  8955. }
  8956. if (child) {
  8957. if (options.outputSourceRange) {
  8958. child.start = start;
  8959. child.end = end;
  8960. }
  8961. children.push(child);
  8962. }
  8963. }
  8964. },
  8965. comment: function comment (text, start, end) {
  8966. // adding anything as a sibling to the root node is forbidden
  8967. // comments should still be allowed, but ignored
  8968. if (currentParent) {
  8969. var child = {
  8970. type: 3,
  8971. text: text,
  8972. isComment: true
  8973. };
  8974. if (options.outputSourceRange) {
  8975. child.start = start;
  8976. child.end = end;
  8977. }
  8978. currentParent.children.push(child);
  8979. }
  8980. }
  8981. });
  8982. return root
  8983. }
  8984. function processPre (el) {
  8985. if (getAndRemoveAttr(el, 'v-pre') != null) {
  8986. el.pre = true;
  8987. }
  8988. }
  8989. function processRawAttrs (el) {
  8990. var list = el.attrsList;
  8991. var len = list.length;
  8992. if (len) {
  8993. var attrs = el.attrs = new Array(len);
  8994. for (var i = 0; i < len; i++) {
  8995. attrs[i] = {
  8996. name: list[i].name,
  8997. value: JSON.stringify(list[i].value)
  8998. };
  8999. if (list[i].start != null) {
  9000. attrs[i].start = list[i].start;
  9001. attrs[i].end = list[i].end;
  9002. }
  9003. }
  9004. } else if (!el.pre) {
  9005. // non root node in pre blocks with no attributes
  9006. el.plain = true;
  9007. }
  9008. }
  9009. function processElement (
  9010. element,
  9011. options
  9012. ) {
  9013. processKey(element);
  9014. // determine whether this is a plain element after
  9015. // removing structural attributes
  9016. element.plain = (
  9017. !element.key &&
  9018. !element.scopedSlots &&
  9019. !element.attrsList.length
  9020. );
  9021. processRef(element);
  9022. processSlotContent(element);
  9023. processSlotOutlet(element);
  9024. processComponent(element);
  9025. for (var i = 0; i < transforms.length; i++) {
  9026. element = transforms[i](element, options) || element;
  9027. }
  9028. processAttrs(element);
  9029. return element
  9030. }
  9031. function processKey (el) {
  9032. var exp = getBindingAttr(el, 'key');
  9033. if (exp) {
  9034. {
  9035. if (el.tag === 'template') {
  9036. warn$2(
  9037. "<template> cannot be keyed. Place the key on real elements instead.",
  9038. getRawBindingAttr(el, 'key')
  9039. );
  9040. }
  9041. if (el.for) {
  9042. var iterator = el.iterator2 || el.iterator1;
  9043. var parent = el.parent;
  9044. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  9045. warn$2(
  9046. "Do not use v-for index as key on <transition-group> children, " +
  9047. "this is the same as not using keys.",
  9048. getRawBindingAttr(el, 'key'),
  9049. true /* tip */
  9050. );
  9051. }
  9052. }
  9053. }
  9054. el.key = exp;
  9055. }
  9056. }
  9057. function processRef (el) {
  9058. var ref = getBindingAttr(el, 'ref');
  9059. if (ref) {
  9060. el.ref = ref;
  9061. el.refInFor = checkInFor(el);
  9062. }
  9063. }
  9064. function processFor (el) {
  9065. var exp;
  9066. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  9067. var res = parseFor(exp);
  9068. if (res) {
  9069. extend(el, res);
  9070. } else {
  9071. warn$2(
  9072. ("Invalid v-for expression: " + exp),
  9073. el.rawAttrsMap['v-for']
  9074. );
  9075. }
  9076. }
  9077. }
  9078. function parseFor (exp) {
  9079. var inMatch = exp.match(forAliasRE);
  9080. if (!inMatch) { return }
  9081. var res = {};
  9082. res.for = inMatch[2].trim();
  9083. var alias = inMatch[1].trim().replace(stripParensRE, '');
  9084. var iteratorMatch = alias.match(forIteratorRE);
  9085. if (iteratorMatch) {
  9086. res.alias = alias.replace(forIteratorRE, '').trim();
  9087. res.iterator1 = iteratorMatch[1].trim();
  9088. if (iteratorMatch[2]) {
  9089. res.iterator2 = iteratorMatch[2].trim();
  9090. }
  9091. } else {
  9092. res.alias = alias;
  9093. }
  9094. return res
  9095. }
  9096. function processIf (el) {
  9097. var exp = getAndRemoveAttr(el, 'v-if');
  9098. if (exp) {
  9099. el.if = exp;
  9100. addIfCondition(el, {
  9101. exp: exp,
  9102. block: el
  9103. });
  9104. } else {
  9105. if (getAndRemoveAttr(el, 'v-else') != null) {
  9106. el.else = true;
  9107. }
  9108. var elseif = getAndRemoveAttr(el, 'v-else-if');
  9109. if (elseif) {
  9110. el.elseif = elseif;
  9111. }
  9112. }
  9113. }
  9114. function processIfConditions (el, parent) {
  9115. var prev = findPrevElement(parent.children);
  9116. if (prev && prev.if) {
  9117. addIfCondition(prev, {
  9118. exp: el.elseif,
  9119. block: el
  9120. });
  9121. } else {
  9122. warn$2(
  9123. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  9124. "used on element <" + (el.tag) + "> without corresponding v-if.",
  9125. el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else']
  9126. );
  9127. }
  9128. }
  9129. function findPrevElement (children) {
  9130. var i = children.length;
  9131. while (i--) {
  9132. if (children[i].type === 1) {
  9133. return children[i]
  9134. } else {
  9135. if (children[i].text !== ' ') {
  9136. warn$2(
  9137. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  9138. "will be ignored.",
  9139. children[i]
  9140. );
  9141. }
  9142. children.pop();
  9143. }
  9144. }
  9145. }
  9146. function addIfCondition (el, condition) {
  9147. if (!el.ifConditions) {
  9148. el.ifConditions = [];
  9149. }
  9150. el.ifConditions.push(condition);
  9151. }
  9152. function processOnce (el) {
  9153. var once$$1 = getAndRemoveAttr(el, 'v-once');
  9154. if (once$$1 != null) {
  9155. el.once = true;
  9156. }
  9157. }
  9158. // handle content being passed to a component as slot,
  9159. // e.g. <template slot="xxx">, <div slot-scope="xxx">
  9160. function processSlotContent (el) {
  9161. var slotScope;
  9162. if (el.tag === 'template') {
  9163. slotScope = getAndRemoveAttr(el, 'scope');
  9164. /* istanbul ignore if */
  9165. if (slotScope) {
  9166. warn$2(
  9167. "the \"scope\" attribute for scoped slots have been deprecated and " +
  9168. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  9169. "can also be used on plain elements in addition to <template> to " +
  9170. "denote scoped slots.",
  9171. el.rawAttrsMap['scope'],
  9172. true
  9173. );
  9174. }
  9175. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  9176. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  9177. /* istanbul ignore if */
  9178. if (el.attrsMap['v-for']) {
  9179. warn$2(
  9180. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  9181. "(v-for takes higher priority). Use a wrapper <template> for the " +
  9182. "scoped slot to make it clearer.",
  9183. el.rawAttrsMap['slot-scope'],
  9184. true
  9185. );
  9186. }
  9187. el.slotScope = slotScope;
  9188. }
  9189. // slot="xxx"
  9190. var slotTarget = getBindingAttr(el, 'slot');
  9191. if (slotTarget) {
  9192. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  9193. el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']);
  9194. // preserve slot as an attribute for native shadow DOM compat
  9195. // only for non-scoped slots.
  9196. if (el.tag !== 'template' && !el.slotScope) {
  9197. addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'));
  9198. }
  9199. }
  9200. // 2.6 v-slot syntax
  9201. {
  9202. if (el.tag === 'template') {
  9203. // v-slot on <template>
  9204. var slotBinding = getAndRemoveAttrByRegex(el, slotRE);
  9205. if (slotBinding) {
  9206. {
  9207. if (el.slotTarget || el.slotScope) {
  9208. warn$2(
  9209. "Unexpected mixed usage of different slot syntaxes.",
  9210. el
  9211. );
  9212. }
  9213. if (el.parent && !maybeComponent(el.parent)) {
  9214. warn$2(
  9215. "<template v-slot> can only appear at the root level inside " +
  9216. "the receiving component",
  9217. el
  9218. );
  9219. }
  9220. }
  9221. var ref = getSlotName(slotBinding);
  9222. var name = ref.name;
  9223. var dynamic = ref.dynamic;
  9224. el.slotTarget = name;
  9225. el.slotTargetDynamic = dynamic;
  9226. el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf
  9227. }
  9228. } else {
  9229. // v-slot on component, denotes default slot
  9230. var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE);
  9231. if (slotBinding$1) {
  9232. {
  9233. if (!maybeComponent(el)) {
  9234. warn$2(
  9235. "v-slot can only be used on components or <template>.",
  9236. slotBinding$1
  9237. );
  9238. }
  9239. if (el.slotScope || el.slotTarget) {
  9240. warn$2(
  9241. "Unexpected mixed usage of different slot syntaxes.",
  9242. el
  9243. );
  9244. }
  9245. if (el.scopedSlots) {
  9246. warn$2(
  9247. "To avoid scope ambiguity, the default slot should also use " +
  9248. "<template> syntax when there are other named slots.",
  9249. slotBinding$1
  9250. );
  9251. }
  9252. }
  9253. // add the component's children to its default slot
  9254. var slots = el.scopedSlots || (el.scopedSlots = {});
  9255. var ref$1 = getSlotName(slotBinding$1);
  9256. var name$1 = ref$1.name;
  9257. var dynamic$1 = ref$1.dynamic;
  9258. var slotContainer = slots[name$1] = createASTElement('template', [], el);
  9259. slotContainer.slotTarget = name$1;
  9260. slotContainer.slotTargetDynamic = dynamic$1;
  9261. slotContainer.children = el.children.filter(function (c) {
  9262. if (!c.slotScope) {
  9263. c.parent = slotContainer;
  9264. return true
  9265. }
  9266. });
  9267. slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken;
  9268. // remove children as they are returned from scopedSlots now
  9269. el.children = [];
  9270. // mark el non-plain so data gets generated
  9271. el.plain = false;
  9272. }
  9273. }
  9274. }
  9275. }
  9276. function getSlotName (binding) {
  9277. var name = binding.name.replace(slotRE, '');
  9278. if (!name) {
  9279. if (binding.name[0] !== '#') {
  9280. name = 'default';
  9281. } else {
  9282. warn$2(
  9283. "v-slot shorthand syntax requires a slot name.",
  9284. binding
  9285. );
  9286. }
  9287. }
  9288. return dynamicArgRE.test(name)
  9289. // dynamic [name]
  9290. ? { name: name.slice(1, -1), dynamic: true }
  9291. // static name
  9292. : { name: ("\"" + name + "\""), dynamic: false }
  9293. }
  9294. // handle <slot/> outlets
  9295. function processSlotOutlet (el) {
  9296. if (el.tag === 'slot') {
  9297. el.slotName = getBindingAttr(el, 'name');
  9298. if (el.key) {
  9299. warn$2(
  9300. "`key` does not work on <slot> because slots are abstract outlets " +
  9301. "and can possibly expand into multiple elements. " +
  9302. "Use the key on a wrapping element instead.",
  9303. getRawBindingAttr(el, 'key')
  9304. );
  9305. }
  9306. }
  9307. }
  9308. function processComponent (el) {
  9309. var binding;
  9310. if ((binding = getBindingAttr(el, 'is'))) {
  9311. el.component = binding;
  9312. }
  9313. if (getAndRemoveAttr(el, 'inline-template') != null) {
  9314. el.inlineTemplate = true;
  9315. }
  9316. }
  9317. function processAttrs (el) {
  9318. var list = el.attrsList;
  9319. var i, l, name, rawName, value, modifiers, syncGen, isDynamic;
  9320. for (i = 0, l = list.length; i < l; i++) {
  9321. name = rawName = list[i].name;
  9322. value = list[i].value;
  9323. if (dirRE.test(name)) {
  9324. // mark element as dynamic
  9325. el.hasBindings = true;
  9326. // modifiers
  9327. modifiers = parseModifiers(name.replace(dirRE, ''));
  9328. // support .foo shorthand syntax for the .prop modifier
  9329. if (modifiers) {
  9330. name = name.replace(modifierRE, '');
  9331. }
  9332. if (bindRE.test(name)) { // v-bind
  9333. name = name.replace(bindRE, '');
  9334. value = parseFilters(value);
  9335. isDynamic = dynamicArgRE.test(name);
  9336. if (isDynamic) {
  9337. name = name.slice(1, -1);
  9338. }
  9339. if (
  9340. value.trim().length === 0
  9341. ) {
  9342. warn$2(
  9343. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  9344. );
  9345. }
  9346. if (modifiers) {
  9347. if (modifiers.prop && !isDynamic) {
  9348. name = camelize(name);
  9349. if (name === 'innerHtml') { name = 'innerHTML'; }
  9350. }
  9351. if (modifiers.camel && !isDynamic) {
  9352. name = camelize(name);
  9353. }
  9354. if (modifiers.sync) {
  9355. syncGen = genAssignmentCode(value, "$event");
  9356. if (!isDynamic) {
  9357. addHandler(
  9358. el,
  9359. ("update:" + (camelize(name))),
  9360. syncGen,
  9361. null,
  9362. false,
  9363. warn$2,
  9364. list[i]
  9365. );
  9366. if (hyphenate(name) !== camelize(name)) {
  9367. addHandler(
  9368. el,
  9369. ("update:" + (hyphenate(name))),
  9370. syncGen,
  9371. null,
  9372. false,
  9373. warn$2,
  9374. list[i]
  9375. );
  9376. }
  9377. } else {
  9378. // handler w/ dynamic event name
  9379. addHandler(
  9380. el,
  9381. ("\"update:\"+(" + name + ")"),
  9382. syncGen,
  9383. null,
  9384. false,
  9385. warn$2,
  9386. list[i],
  9387. true // dynamic
  9388. );
  9389. }
  9390. }
  9391. }
  9392. if ((modifiers && modifiers.prop) || (
  9393. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  9394. )) {
  9395. addProp(el, name, value, list[i], isDynamic);
  9396. } else {
  9397. addAttr(el, name, value, list[i], isDynamic);
  9398. }
  9399. } else if (onRE.test(name)) { // v-on
  9400. name = name.replace(onRE, '');
  9401. isDynamic = dynamicArgRE.test(name);
  9402. if (isDynamic) {
  9403. name = name.slice(1, -1);
  9404. }
  9405. addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic);
  9406. } else { // normal directives
  9407. name = name.replace(dirRE, '');
  9408. // parse arg
  9409. var argMatch = name.match(argRE);
  9410. var arg = argMatch && argMatch[1];
  9411. isDynamic = false;
  9412. if (arg) {
  9413. name = name.slice(0, -(arg.length + 1));
  9414. if (dynamicArgRE.test(arg)) {
  9415. arg = arg.slice(1, -1);
  9416. isDynamic = true;
  9417. }
  9418. }
  9419. addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]);
  9420. if (name === 'model') {
  9421. checkForAliasModel(el, value);
  9422. }
  9423. }
  9424. } else {
  9425. // literal attribute
  9426. {
  9427. var res = parseText(value, delimiters);
  9428. if (res) {
  9429. warn$2(
  9430. name + "=\"" + value + "\": " +
  9431. 'Interpolation inside attributes has been removed. ' +
  9432. 'Use v-bind or the colon shorthand instead. For example, ' +
  9433. 'instead of <div id="{{ val }}">, use <div :id="val">.',
  9434. list[i]
  9435. );
  9436. }
  9437. }
  9438. addAttr(el, name, JSON.stringify(value), list[i]);
  9439. // #6887 firefox doesn't update muted state if set via attribute
  9440. // even immediately after element creation
  9441. if (!el.component &&
  9442. name === 'muted' &&
  9443. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  9444. addProp(el, name, 'true', list[i]);
  9445. }
  9446. }
  9447. }
  9448. }
  9449. function checkInFor (el) {
  9450. var parent = el;
  9451. while (parent) {
  9452. if (parent.for !== undefined) {
  9453. return true
  9454. }
  9455. parent = parent.parent;
  9456. }
  9457. return false
  9458. }
  9459. function parseModifiers (name) {
  9460. var match = name.match(modifierRE);
  9461. if (match) {
  9462. var ret = {};
  9463. match.forEach(function (m) { ret[m.slice(1)] = true; });
  9464. return ret
  9465. }
  9466. }
  9467. function makeAttrsMap (attrs) {
  9468. var map = {};
  9469. for (var i = 0, l = attrs.length; i < l; i++) {
  9470. if (
  9471. map[attrs[i].name] && !isIE && !isEdge
  9472. ) {
  9473. warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]);
  9474. }
  9475. map[attrs[i].name] = attrs[i].value;
  9476. }
  9477. return map
  9478. }
  9479. // for script (e.g. type="x/template") or style, do not decode content
  9480. function isTextTag (el) {
  9481. return el.tag === 'script' || el.tag === 'style'
  9482. }
  9483. function isForbiddenTag (el) {
  9484. return (
  9485. el.tag === 'style' ||
  9486. (el.tag === 'script' && (
  9487. !el.attrsMap.type ||
  9488. el.attrsMap.type === 'text/javascript'
  9489. ))
  9490. )
  9491. }
  9492. var ieNSBug = /^xmlns:NS\d+/;
  9493. var ieNSPrefix = /^NS\d+:/;
  9494. /* istanbul ignore next */
  9495. function guardIESVGBug (attrs) {
  9496. var res = [];
  9497. for (var i = 0; i < attrs.length; i++) {
  9498. var attr = attrs[i];
  9499. if (!ieNSBug.test(attr.name)) {
  9500. attr.name = attr.name.replace(ieNSPrefix, '');
  9501. res.push(attr);
  9502. }
  9503. }
  9504. return res
  9505. }
  9506. function checkForAliasModel (el, value) {
  9507. var _el = el;
  9508. while (_el) {
  9509. if (_el.for && _el.alias === value) {
  9510. warn$2(
  9511. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  9512. "You are binding v-model directly to a v-for iteration alias. " +
  9513. "This will not be able to modify the v-for source array because " +
  9514. "writing to the alias is like modifying a function local variable. " +
  9515. "Consider using an array of objects and use v-model on an object property instead.",
  9516. el.rawAttrsMap['v-model']
  9517. );
  9518. }
  9519. _el = _el.parent;
  9520. }
  9521. }
  9522. /* */
  9523. function preTransformNode (el, options) {
  9524. if (el.tag === 'input') {
  9525. var map = el.attrsMap;
  9526. if (!map['v-model']) {
  9527. return
  9528. }
  9529. var typeBinding;
  9530. if (map[':type'] || map['v-bind:type']) {
  9531. typeBinding = getBindingAttr(el, 'type');
  9532. }
  9533. if (!map.type && !typeBinding && map['v-bind']) {
  9534. typeBinding = "(" + (map['v-bind']) + ").type";
  9535. }
  9536. if (typeBinding) {
  9537. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  9538. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  9539. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  9540. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  9541. // 1. checkbox
  9542. var branch0 = cloneASTElement(el);
  9543. // process for on the main node
  9544. processFor(branch0);
  9545. addRawAttr(branch0, 'type', 'checkbox');
  9546. processElement(branch0, options);
  9547. branch0.processed = true; // prevent it from double-processed
  9548. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  9549. addIfCondition(branch0, {
  9550. exp: branch0.if,
  9551. block: branch0
  9552. });
  9553. // 2. add radio else-if condition
  9554. var branch1 = cloneASTElement(el);
  9555. getAndRemoveAttr(branch1, 'v-for', true);
  9556. addRawAttr(branch1, 'type', 'radio');
  9557. processElement(branch1, options);
  9558. addIfCondition(branch0, {
  9559. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  9560. block: branch1
  9561. });
  9562. // 3. other
  9563. var branch2 = cloneASTElement(el);
  9564. getAndRemoveAttr(branch2, 'v-for', true);
  9565. addRawAttr(branch2, ':type', typeBinding);
  9566. processElement(branch2, options);
  9567. addIfCondition(branch0, {
  9568. exp: ifCondition,
  9569. block: branch2
  9570. });
  9571. if (hasElse) {
  9572. branch0.else = true;
  9573. } else if (elseIfCondition) {
  9574. branch0.elseif = elseIfCondition;
  9575. }
  9576. return branch0
  9577. }
  9578. }
  9579. }
  9580. function cloneASTElement (el) {
  9581. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  9582. }
  9583. var model$1 = {
  9584. preTransformNode: preTransformNode
  9585. };
  9586. var modules$1 = [
  9587. klass$1,
  9588. style$1,
  9589. model$1
  9590. ];
  9591. /* */
  9592. function text (el, dir) {
  9593. if (dir.value) {
  9594. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir);
  9595. }
  9596. }
  9597. /* */
  9598. function html (el, dir) {
  9599. if (dir.value) {
  9600. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir);
  9601. }
  9602. }
  9603. var directives$1 = {
  9604. model: model,
  9605. text: text,
  9606. html: html
  9607. };
  9608. /* */
  9609. var baseOptions = {
  9610. expectHTML: true,
  9611. modules: modules$1,
  9612. directives: directives$1,
  9613. isPreTag: isPreTag,
  9614. isUnaryTag: isUnaryTag,
  9615. mustUseProp: mustUseProp,
  9616. canBeLeftOpenTag: canBeLeftOpenTag,
  9617. isReservedTag: isReservedTag,
  9618. getTagNamespace: getTagNamespace,
  9619. staticKeys: genStaticKeys(modules$1)
  9620. };
  9621. /* */
  9622. var isStaticKey;
  9623. var isPlatformReservedTag;
  9624. var genStaticKeysCached = cached(genStaticKeys$1);
  9625. /**
  9626. * Goal of the optimizer: walk the generated template AST tree
  9627. * and detect sub-trees that are purely static, i.e. parts of
  9628. * the DOM that never needs to change.
  9629. *
  9630. * Once we detect these sub-trees, we can:
  9631. *
  9632. * 1. Hoist them into constants, so that we no longer need to
  9633. * create fresh nodes for them on each re-render;
  9634. * 2. Completely skip them in the patching process.
  9635. */
  9636. function optimize (root, options) {
  9637. if (!root) { return }
  9638. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  9639. isPlatformReservedTag = options.isReservedTag || no;
  9640. // first pass: mark all non-static nodes.
  9641. markStatic$1(root);
  9642. // second pass: mark static roots.
  9643. markStaticRoots(root, false);
  9644. }
  9645. function genStaticKeys$1 (keys) {
  9646. return makeMap(
  9647. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' +
  9648. (keys ? ',' + keys : '')
  9649. )
  9650. }
  9651. function markStatic$1 (node) {
  9652. node.static = isStatic(node);
  9653. if (node.type === 1) {
  9654. // do not make component slot content static. this avoids
  9655. // 1. components not able to mutate slot nodes
  9656. // 2. static slot content fails for hot-reloading
  9657. if (
  9658. !isPlatformReservedTag(node.tag) &&
  9659. node.tag !== 'slot' &&
  9660. node.attrsMap['inline-template'] == null
  9661. ) {
  9662. return
  9663. }
  9664. for (var i = 0, l = node.children.length; i < l; i++) {
  9665. var child = node.children[i];
  9666. markStatic$1(child);
  9667. if (!child.static) {
  9668. node.static = false;
  9669. }
  9670. }
  9671. if (node.ifConditions) {
  9672. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  9673. var block = node.ifConditions[i$1].block;
  9674. markStatic$1(block);
  9675. if (!block.static) {
  9676. node.static = false;
  9677. }
  9678. }
  9679. }
  9680. }
  9681. }
  9682. function markStaticRoots (node, isInFor) {
  9683. if (node.type === 1) {
  9684. if (node.static || node.once) {
  9685. node.staticInFor = isInFor;
  9686. }
  9687. // For a node to qualify as a static root, it should have children that
  9688. // are not just static text. Otherwise the cost of hoisting out will
  9689. // outweigh the benefits and it's better off to just always render it fresh.
  9690. if (node.static && node.children.length && !(
  9691. node.children.length === 1 &&
  9692. node.children[0].type === 3
  9693. )) {
  9694. node.staticRoot = true;
  9695. return
  9696. } else {
  9697. node.staticRoot = false;
  9698. }
  9699. if (node.children) {
  9700. for (var i = 0, l = node.children.length; i < l; i++) {
  9701. markStaticRoots(node.children[i], isInFor || !!node.for);
  9702. }
  9703. }
  9704. if (node.ifConditions) {
  9705. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  9706. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  9707. }
  9708. }
  9709. }
  9710. }
  9711. function isStatic (node) {
  9712. if (node.type === 2) { // expression
  9713. return false
  9714. }
  9715. if (node.type === 3) { // text
  9716. return true
  9717. }
  9718. return !!(node.pre || (
  9719. !node.hasBindings && // no dynamic bindings
  9720. !node.if && !node.for && // not v-if or v-for or v-else
  9721. !isBuiltInTag(node.tag) && // not a built-in
  9722. isPlatformReservedTag(node.tag) && // not a component
  9723. !isDirectChildOfTemplateFor(node) &&
  9724. Object.keys(node).every(isStaticKey)
  9725. ))
  9726. }
  9727. function isDirectChildOfTemplateFor (node) {
  9728. while (node.parent) {
  9729. node = node.parent;
  9730. if (node.tag !== 'template') {
  9731. return false
  9732. }
  9733. if (node.for) {
  9734. return true
  9735. }
  9736. }
  9737. return false
  9738. }
  9739. /* */
  9740. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/;
  9741. var fnInvokeRE = /\([^)]*?\);*$/;
  9742. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  9743. // KeyboardEvent.keyCode aliases
  9744. var keyCodes = {
  9745. esc: 27,
  9746. tab: 9,
  9747. enter: 13,
  9748. space: 32,
  9749. up: 38,
  9750. left: 37,
  9751. right: 39,
  9752. down: 40,
  9753. 'delete': [8, 46]
  9754. };
  9755. // KeyboardEvent.key aliases
  9756. var keyNames = {
  9757. // #7880: IE11 and Edge use `Esc` for Escape key name.
  9758. esc: ['Esc', 'Escape'],
  9759. tab: 'Tab',
  9760. enter: 'Enter',
  9761. // #9112: IE11 uses `Spacebar` for Space key name.
  9762. space: [' ', 'Spacebar'],
  9763. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  9764. up: ['Up', 'ArrowUp'],
  9765. left: ['Left', 'ArrowLeft'],
  9766. right: ['Right', 'ArrowRight'],
  9767. down: ['Down', 'ArrowDown'],
  9768. // #9112: IE11 uses `Del` for Delete key name.
  9769. 'delete': ['Backspace', 'Delete', 'Del']
  9770. };
  9771. // #4868: modifiers that prevent the execution of the listener
  9772. // need to explicitly return null so that we can determine whether to remove
  9773. // the listener for .once
  9774. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  9775. var modifierCode = {
  9776. stop: '$event.stopPropagation();',
  9777. prevent: '$event.preventDefault();',
  9778. self: genGuard("$event.target !== $event.currentTarget"),
  9779. ctrl: genGuard("!$event.ctrlKey"),
  9780. shift: genGuard("!$event.shiftKey"),
  9781. alt: genGuard("!$event.altKey"),
  9782. meta: genGuard("!$event.metaKey"),
  9783. left: genGuard("'button' in $event && $event.button !== 0"),
  9784. middle: genGuard("'button' in $event && $event.button !== 1"),
  9785. right: genGuard("'button' in $event && $event.button !== 2")
  9786. };
  9787. function genHandlers (
  9788. events,
  9789. isNative
  9790. ) {
  9791. var prefix = isNative ? 'nativeOn:' : 'on:';
  9792. var staticHandlers = "";
  9793. var dynamicHandlers = "";
  9794. for (var name in events) {
  9795. var handlerCode = genHandler(events[name]);
  9796. if (events[name] && events[name].dynamic) {
  9797. dynamicHandlers += name + "," + handlerCode + ",";
  9798. } else {
  9799. staticHandlers += "\"" + name + "\":" + handlerCode + ",";
  9800. }
  9801. }
  9802. staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}";
  9803. if (dynamicHandlers) {
  9804. return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])"
  9805. } else {
  9806. return prefix + staticHandlers
  9807. }
  9808. }
  9809. function genHandler (handler) {
  9810. if (!handler) {
  9811. return 'function(){}'
  9812. }
  9813. if (Array.isArray(handler)) {
  9814. return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]")
  9815. }
  9816. var isMethodPath = simplePathRE.test(handler.value);
  9817. var isFunctionExpression = fnExpRE.test(handler.value);
  9818. var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, ''));
  9819. if (!handler.modifiers) {
  9820. if (isMethodPath || isFunctionExpression) {
  9821. return handler.value
  9822. }
  9823. return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement
  9824. } else {
  9825. var code = '';
  9826. var genModifierCode = '';
  9827. var keys = [];
  9828. for (var key in handler.modifiers) {
  9829. if (modifierCode[key]) {
  9830. genModifierCode += modifierCode[key];
  9831. // left/right
  9832. if (keyCodes[key]) {
  9833. keys.push(key);
  9834. }
  9835. } else if (key === 'exact') {
  9836. var modifiers = (handler.modifiers);
  9837. genModifierCode += genGuard(
  9838. ['ctrl', 'shift', 'alt', 'meta']
  9839. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  9840. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  9841. .join('||')
  9842. );
  9843. } else {
  9844. keys.push(key);
  9845. }
  9846. }
  9847. if (keys.length) {
  9848. code += genKeyFilter(keys);
  9849. }
  9850. // Make sure modifiers like prevent and stop get executed after key filtering
  9851. if (genModifierCode) {
  9852. code += genModifierCode;
  9853. }
  9854. var handlerCode = isMethodPath
  9855. ? ("return " + (handler.value) + ".apply(null, arguments)")
  9856. : isFunctionExpression
  9857. ? ("return (" + (handler.value) + ").apply(null, arguments)")
  9858. : isFunctionInvocation
  9859. ? ("return " + (handler.value))
  9860. : handler.value;
  9861. return ("function($event){" + code + handlerCode + "}")
  9862. }
  9863. }
  9864. function genKeyFilter (keys) {
  9865. return (
  9866. // make sure the key filters only apply to KeyboardEvents
  9867. // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake
  9868. // key events that do not have keyCode property...
  9869. "if(!$event.type.indexOf('key')&&" +
  9870. (keys.map(genFilterCode).join('&&')) + ")return null;"
  9871. )
  9872. }
  9873. function genFilterCode (key) {
  9874. var keyVal = parseInt(key, 10);
  9875. if (keyVal) {
  9876. return ("$event.keyCode!==" + keyVal)
  9877. }
  9878. var keyCode = keyCodes[key];
  9879. var keyName = keyNames[key];
  9880. return (
  9881. "_k($event.keyCode," +
  9882. (JSON.stringify(key)) + "," +
  9883. (JSON.stringify(keyCode)) + "," +
  9884. "$event.key," +
  9885. "" + (JSON.stringify(keyName)) +
  9886. ")"
  9887. )
  9888. }
  9889. /* */
  9890. function on (el, dir) {
  9891. if (dir.modifiers) {
  9892. warn("v-on without argument does not support modifiers.");
  9893. }
  9894. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  9895. }
  9896. /* */
  9897. function bind$1 (el, dir) {
  9898. el.wrapData = function (code) {
  9899. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  9900. };
  9901. }
  9902. /* */
  9903. var baseDirectives = {
  9904. on: on,
  9905. bind: bind$1,
  9906. cloak: noop
  9907. };
  9908. /* */
  9909. var CodegenState = function CodegenState (options) {
  9910. this.options = options;
  9911. this.warn = options.warn || baseWarn;
  9912. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  9913. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  9914. this.directives = extend(extend({}, baseDirectives), options.directives);
  9915. var isReservedTag = options.isReservedTag || no;
  9916. this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); };
  9917. this.onceId = 0;
  9918. this.staticRenderFns = [];
  9919. this.pre = false;
  9920. };
  9921. function generate (
  9922. ast,
  9923. options
  9924. ) {
  9925. var state = new CodegenState(options);
  9926. // fix #11483, Root level <script> tags should not be rendered.
  9927. var code = ast ? (ast.tag === 'script' ? 'null' : genElement(ast, state)) : '_c("div")';
  9928. return {
  9929. render: ("with(this){return " + code + "}"),
  9930. staticRenderFns: state.staticRenderFns
  9931. }
  9932. }
  9933. function genElement (el, state) {
  9934. if (el.parent) {
  9935. el.pre = el.pre || el.parent.pre;
  9936. }
  9937. if (el.staticRoot && !el.staticProcessed) {
  9938. return genStatic(el, state)
  9939. } else if (el.once && !el.onceProcessed) {
  9940. return genOnce(el, state)
  9941. } else if (el.for && !el.forProcessed) {
  9942. return genFor(el, state)
  9943. } else if (el.if && !el.ifProcessed) {
  9944. return genIf(el, state)
  9945. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  9946. return genChildren(el, state) || 'void 0'
  9947. } else if (el.tag === 'slot') {
  9948. return genSlot(el, state)
  9949. } else {
  9950. // component or element
  9951. var code;
  9952. if (el.component) {
  9953. code = genComponent(el.component, el, state);
  9954. } else {
  9955. var data;
  9956. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  9957. data = genData$2(el, state);
  9958. }
  9959. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  9960. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  9961. }
  9962. // module transforms
  9963. for (var i = 0; i < state.transforms.length; i++) {
  9964. code = state.transforms[i](el, code);
  9965. }
  9966. return code
  9967. }
  9968. }
  9969. // hoist static sub-trees out
  9970. function genStatic (el, state) {
  9971. el.staticProcessed = true;
  9972. // Some elements (templates) need to behave differently inside of a v-pre
  9973. // node. All pre nodes are static roots, so we can use this as a location to
  9974. // wrap a state change and reset it upon exiting the pre node.
  9975. var originalPreState = state.pre;
  9976. if (el.pre) {
  9977. state.pre = el.pre;
  9978. }
  9979. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  9980. state.pre = originalPreState;
  9981. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  9982. }
  9983. // v-once
  9984. function genOnce (el, state) {
  9985. el.onceProcessed = true;
  9986. if (el.if && !el.ifProcessed) {
  9987. return genIf(el, state)
  9988. } else if (el.staticInFor) {
  9989. var key = '';
  9990. var parent = el.parent;
  9991. while (parent) {
  9992. if (parent.for) {
  9993. key = parent.key;
  9994. break
  9995. }
  9996. parent = parent.parent;
  9997. }
  9998. if (!key) {
  9999. state.warn(
  10000. "v-once can only be used inside v-for that is keyed. ",
  10001. el.rawAttrsMap['v-once']
  10002. );
  10003. return genElement(el, state)
  10004. }
  10005. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  10006. } else {
  10007. return genStatic(el, state)
  10008. }
  10009. }
  10010. function genIf (
  10011. el,
  10012. state,
  10013. altGen,
  10014. altEmpty
  10015. ) {
  10016. el.ifProcessed = true; // avoid recursion
  10017. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  10018. }
  10019. function genIfConditions (
  10020. conditions,
  10021. state,
  10022. altGen,
  10023. altEmpty
  10024. ) {
  10025. if (!conditions.length) {
  10026. return altEmpty || '_e()'
  10027. }
  10028. var condition = conditions.shift();
  10029. if (condition.exp) {
  10030. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  10031. } else {
  10032. return ("" + (genTernaryExp(condition.block)))
  10033. }
  10034. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  10035. function genTernaryExp (el) {
  10036. return altGen
  10037. ? altGen(el, state)
  10038. : el.once
  10039. ? genOnce(el, state)
  10040. : genElement(el, state)
  10041. }
  10042. }
  10043. function genFor (
  10044. el,
  10045. state,
  10046. altGen,
  10047. altHelper
  10048. ) {
  10049. var exp = el.for;
  10050. var alias = el.alias;
  10051. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  10052. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  10053. if (state.maybeComponent(el) &&
  10054. el.tag !== 'slot' &&
  10055. el.tag !== 'template' &&
  10056. !el.key
  10057. ) {
  10058. state.warn(
  10059. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  10060. "v-for should have explicit keys. " +
  10061. "See https://vuejs.org/guide/list.html#key for more info.",
  10062. el.rawAttrsMap['v-for'],
  10063. true /* tip */
  10064. );
  10065. }
  10066. el.forProcessed = true; // avoid recursion
  10067. return (altHelper || '_l') + "((" + exp + ")," +
  10068. "function(" + alias + iterator1 + iterator2 + "){" +
  10069. "return " + ((altGen || genElement)(el, state)) +
  10070. '})'
  10071. }
  10072. function genData$2 (el, state) {
  10073. var data = '{';
  10074. // directives first.
  10075. // directives may mutate the el's other properties before they are generated.
  10076. var dirs = genDirectives(el, state);
  10077. if (dirs) { data += dirs + ','; }
  10078. // key
  10079. if (el.key) {
  10080. data += "key:" + (el.key) + ",";
  10081. }
  10082. // ref
  10083. if (el.ref) {
  10084. data += "ref:" + (el.ref) + ",";
  10085. }
  10086. if (el.refInFor) {
  10087. data += "refInFor:true,";
  10088. }
  10089. // pre
  10090. if (el.pre) {
  10091. data += "pre:true,";
  10092. }
  10093. // record original tag name for components using "is" attribute
  10094. if (el.component) {
  10095. data += "tag:\"" + (el.tag) + "\",";
  10096. }
  10097. // module data generation functions
  10098. for (var i = 0; i < state.dataGenFns.length; i++) {
  10099. data += state.dataGenFns[i](el);
  10100. }
  10101. // attributes
  10102. if (el.attrs) {
  10103. data += "attrs:" + (genProps(el.attrs)) + ",";
  10104. }
  10105. // DOM props
  10106. if (el.props) {
  10107. data += "domProps:" + (genProps(el.props)) + ",";
  10108. }
  10109. // event handlers
  10110. if (el.events) {
  10111. data += (genHandlers(el.events, false)) + ",";
  10112. }
  10113. if (el.nativeEvents) {
  10114. data += (genHandlers(el.nativeEvents, true)) + ",";
  10115. }
  10116. // slot target
  10117. // only for non-scoped slots
  10118. if (el.slotTarget && !el.slotScope) {
  10119. data += "slot:" + (el.slotTarget) + ",";
  10120. }
  10121. // scoped slots
  10122. if (el.scopedSlots) {
  10123. data += (genScopedSlots(el, el.scopedSlots, state)) + ",";
  10124. }
  10125. // component v-model
  10126. if (el.model) {
  10127. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  10128. }
  10129. // inline-template
  10130. if (el.inlineTemplate) {
  10131. var inlineTemplate = genInlineTemplate(el, state);
  10132. if (inlineTemplate) {
  10133. data += inlineTemplate + ",";
  10134. }
  10135. }
  10136. data = data.replace(/,$/, '') + '}';
  10137. // v-bind dynamic argument wrap
  10138. // v-bind with dynamic arguments must be applied using the same v-bind object
  10139. // merge helper so that class/style/mustUseProp attrs are handled correctly.
  10140. if (el.dynamicAttrs) {
  10141. data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")";
  10142. }
  10143. // v-bind data wrap
  10144. if (el.wrapData) {
  10145. data = el.wrapData(data);
  10146. }
  10147. // v-on data wrap
  10148. if (el.wrapListeners) {
  10149. data = el.wrapListeners(data);
  10150. }
  10151. return data
  10152. }
  10153. function genDirectives (el, state) {
  10154. var dirs = el.directives;
  10155. if (!dirs) { return }
  10156. var res = 'directives:[';
  10157. var hasRuntime = false;
  10158. var i, l, dir, needRuntime;
  10159. for (i = 0, l = dirs.length; i < l; i++) {
  10160. dir = dirs[i];
  10161. needRuntime = true;
  10162. var gen = state.directives[dir.name];
  10163. if (gen) {
  10164. // compile-time directive that manipulates AST.
  10165. // returns true if it also needs a runtime counterpart.
  10166. needRuntime = !!gen(el, dir, state.warn);
  10167. }
  10168. if (needRuntime) {
  10169. hasRuntime = true;
  10170. res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:" + (dir.isDynamicArg ? dir.arg : ("\"" + (dir.arg) + "\""))) : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
  10171. }
  10172. }
  10173. if (hasRuntime) {
  10174. return res.slice(0, -1) + ']'
  10175. }
  10176. }
  10177. function genInlineTemplate (el, state) {
  10178. var ast = el.children[0];
  10179. if (el.children.length !== 1 || ast.type !== 1) {
  10180. state.warn(
  10181. 'Inline-template components must have exactly one child element.',
  10182. { start: el.start }
  10183. );
  10184. }
  10185. if (ast && ast.type === 1) {
  10186. var inlineRenderFns = generate(ast, state.options);
  10187. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  10188. }
  10189. }
  10190. function genScopedSlots (
  10191. el,
  10192. slots,
  10193. state
  10194. ) {
  10195. // by default scoped slots are considered "stable", this allows child
  10196. // components with only scoped slots to skip forced updates from parent.
  10197. // but in some cases we have to bail-out of this optimization
  10198. // for example if the slot contains dynamic names, has v-if or v-for on them...
  10199. var needsForceUpdate = el.for || Object.keys(slots).some(function (key) {
  10200. var slot = slots[key];
  10201. return (
  10202. slot.slotTargetDynamic ||
  10203. slot.if ||
  10204. slot.for ||
  10205. containsSlotChild(slot) // is passing down slot from parent which may be dynamic
  10206. )
  10207. });
  10208. // #9534: if a component with scoped slots is inside a conditional branch,
  10209. // it's possible for the same component to be reused but with different
  10210. // compiled slot content. To avoid that, we generate a unique key based on
  10211. // the generated code of all the slot contents.
  10212. var needsKey = !!el.if;
  10213. // OR when it is inside another scoped slot or v-for (the reactivity may be
  10214. // disconnected due to the intermediate scope variable)
  10215. // #9438, #9506
  10216. // TODO: this can be further optimized by properly analyzing in-scope bindings
  10217. // and skip force updating ones that do not actually use scope variables.
  10218. if (!needsForceUpdate) {
  10219. var parent = el.parent;
  10220. while (parent) {
  10221. if (
  10222. (parent.slotScope && parent.slotScope !== emptySlotScopeToken) ||
  10223. parent.for
  10224. ) {
  10225. needsForceUpdate = true;
  10226. break
  10227. }
  10228. if (parent.if) {
  10229. needsKey = true;
  10230. }
  10231. parent = parent.parent;
  10232. }
  10233. }
  10234. var generatedSlots = Object.keys(slots)
  10235. .map(function (key) { return genScopedSlot(slots[key], state); })
  10236. .join(',');
  10237. return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,false," + (hash(generatedSlots))) : "") + ")")
  10238. }
  10239. function hash(str) {
  10240. var hash = 5381;
  10241. var i = str.length;
  10242. while(i) {
  10243. hash = (hash * 33) ^ str.charCodeAt(--i);
  10244. }
  10245. return hash >>> 0
  10246. }
  10247. function containsSlotChild (el) {
  10248. if (el.type === 1) {
  10249. if (el.tag === 'slot') {
  10250. return true
  10251. }
  10252. return el.children.some(containsSlotChild)
  10253. }
  10254. return false
  10255. }
  10256. function genScopedSlot (
  10257. el,
  10258. state
  10259. ) {
  10260. var isLegacySyntax = el.attrsMap['slot-scope'];
  10261. if (el.if && !el.ifProcessed && !isLegacySyntax) {
  10262. return genIf(el, state, genScopedSlot, "null")
  10263. }
  10264. if (el.for && !el.forProcessed) {
  10265. return genFor(el, state, genScopedSlot)
  10266. }
  10267. var slotScope = el.slotScope === emptySlotScopeToken
  10268. ? ""
  10269. : String(el.slotScope);
  10270. var fn = "function(" + slotScope + "){" +
  10271. "return " + (el.tag === 'template'
  10272. ? el.if && isLegacySyntax
  10273. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  10274. : genChildren(el, state) || 'undefined'
  10275. : genElement(el, state)) + "}";
  10276. // reverse proxy v-slot without scope on this.$slots
  10277. var reverseProxy = slotScope ? "" : ",proxy:true";
  10278. return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
  10279. }
  10280. function genChildren (
  10281. el,
  10282. state,
  10283. checkSkip,
  10284. altGenElement,
  10285. altGenNode
  10286. ) {
  10287. var children = el.children;
  10288. if (children.length) {
  10289. var el$1 = children[0];
  10290. // optimize single v-for
  10291. if (children.length === 1 &&
  10292. el$1.for &&
  10293. el$1.tag !== 'template' &&
  10294. el$1.tag !== 'slot'
  10295. ) {
  10296. var normalizationType = checkSkip
  10297. ? state.maybeComponent(el$1) ? ",1" : ",0"
  10298. : "";
  10299. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  10300. }
  10301. var normalizationType$1 = checkSkip
  10302. ? getNormalizationType(children, state.maybeComponent)
  10303. : 0;
  10304. var gen = altGenNode || genNode;
  10305. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  10306. }
  10307. }
  10308. // determine the normalization needed for the children array.
  10309. // 0: no normalization needed
  10310. // 1: simple normalization needed (possible 1-level deep nested array)
  10311. // 2: full normalization needed
  10312. function getNormalizationType (
  10313. children,
  10314. maybeComponent
  10315. ) {
  10316. var res = 0;
  10317. for (var i = 0; i < children.length; i++) {
  10318. var el = children[i];
  10319. if (el.type !== 1) {
  10320. continue
  10321. }
  10322. if (needsNormalization(el) ||
  10323. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  10324. res = 2;
  10325. break
  10326. }
  10327. if (maybeComponent(el) ||
  10328. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  10329. res = 1;
  10330. }
  10331. }
  10332. return res
  10333. }
  10334. function needsNormalization (el) {
  10335. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  10336. }
  10337. function genNode (node, state) {
  10338. if (node.type === 1) {
  10339. return genElement(node, state)
  10340. } else if (node.type === 3 && node.isComment) {
  10341. return genComment(node)
  10342. } else {
  10343. return genText(node)
  10344. }
  10345. }
  10346. function genText (text) {
  10347. return ("_v(" + (text.type === 2
  10348. ? text.expression // no need for () because already wrapped in _s()
  10349. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  10350. }
  10351. function genComment (comment) {
  10352. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  10353. }
  10354. function genSlot (el, state) {
  10355. var slotName = el.slotName || '"default"';
  10356. var children = genChildren(el, state);
  10357. var res = "_t(" + slotName + (children ? (",function(){return " + children + "}") : '');
  10358. var attrs = el.attrs || el.dynamicAttrs
  10359. ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
  10360. // slot props are camelized
  10361. name: camelize(attr.name),
  10362. value: attr.value,
  10363. dynamic: attr.dynamic
  10364. }); }))
  10365. : null;
  10366. var bind$$1 = el.attrsMap['v-bind'];
  10367. if ((attrs || bind$$1) && !children) {
  10368. res += ",null";
  10369. }
  10370. if (attrs) {
  10371. res += "," + attrs;
  10372. }
  10373. if (bind$$1) {
  10374. res += (attrs ? '' : ',null') + "," + bind$$1;
  10375. }
  10376. return res + ')'
  10377. }
  10378. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  10379. function genComponent (
  10380. componentName,
  10381. el,
  10382. state
  10383. ) {
  10384. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  10385. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  10386. }
  10387. function genProps (props) {
  10388. var staticProps = "";
  10389. var dynamicProps = "";
  10390. for (var i = 0; i < props.length; i++) {
  10391. var prop = props[i];
  10392. var value = transformSpecialNewlines(prop.value);
  10393. if (prop.dynamic) {
  10394. dynamicProps += (prop.name) + "," + value + ",";
  10395. } else {
  10396. staticProps += "\"" + (prop.name) + "\":" + value + ",";
  10397. }
  10398. }
  10399. staticProps = "{" + (staticProps.slice(0, -1)) + "}";
  10400. if (dynamicProps) {
  10401. return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])")
  10402. } else {
  10403. return staticProps
  10404. }
  10405. }
  10406. // #3895, #4268
  10407. function transformSpecialNewlines (text) {
  10408. return text
  10409. .replace(/\u2028/g, '\\u2028')
  10410. .replace(/\u2029/g, '\\u2029')
  10411. }
  10412. /* */
  10413. // these keywords should not appear inside expressions, but operators like
  10414. // typeof, instanceof and in are allowed
  10415. var prohibitedKeywordRE = new RegExp('\\b' + (
  10416. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  10417. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  10418. 'extends,finally,continue,debugger,function,arguments'
  10419. ).split(',').join('\\b|\\b') + '\\b');
  10420. // these unary operators should not be used as property/method names
  10421. var unaryOperatorsRE = new RegExp('\\b' + (
  10422. 'delete,typeof,void'
  10423. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  10424. // strip strings in expressions
  10425. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  10426. // detect problematic expressions in a template
  10427. function detectErrors (ast, warn) {
  10428. if (ast) {
  10429. checkNode(ast, warn);
  10430. }
  10431. }
  10432. function checkNode (node, warn) {
  10433. if (node.type === 1) {
  10434. for (var name in node.attrsMap) {
  10435. if (dirRE.test(name)) {
  10436. var value = node.attrsMap[name];
  10437. if (value) {
  10438. var range = node.rawAttrsMap[name];
  10439. if (name === 'v-for') {
  10440. checkFor(node, ("v-for=\"" + value + "\""), warn, range);
  10441. } else if (name === 'v-slot' || name[0] === '#') {
  10442. checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range);
  10443. } else if (onRE.test(name)) {
  10444. checkEvent(value, (name + "=\"" + value + "\""), warn, range);
  10445. } else {
  10446. checkExpression(value, (name + "=\"" + value + "\""), warn, range);
  10447. }
  10448. }
  10449. }
  10450. }
  10451. if (node.children) {
  10452. for (var i = 0; i < node.children.length; i++) {
  10453. checkNode(node.children[i], warn);
  10454. }
  10455. }
  10456. } else if (node.type === 2) {
  10457. checkExpression(node.expression, node.text, warn, node);
  10458. }
  10459. }
  10460. function checkEvent (exp, text, warn, range) {
  10461. var stripped = exp.replace(stripStringRE, '');
  10462. var keywordMatch = stripped.match(unaryOperatorsRE);
  10463. if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') {
  10464. warn(
  10465. "avoid using JavaScript unary operator as property name: " +
  10466. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()),
  10467. range
  10468. );
  10469. }
  10470. checkExpression(exp, text, warn, range);
  10471. }
  10472. function checkFor (node, text, warn, range) {
  10473. checkExpression(node.for || '', text, warn, range);
  10474. checkIdentifier(node.alias, 'v-for alias', text, warn, range);
  10475. checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range);
  10476. checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range);
  10477. }
  10478. function checkIdentifier (
  10479. ident,
  10480. type,
  10481. text,
  10482. warn,
  10483. range
  10484. ) {
  10485. if (typeof ident === 'string') {
  10486. try {
  10487. new Function(("var " + ident + "=_"));
  10488. } catch (e) {
  10489. warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range);
  10490. }
  10491. }
  10492. }
  10493. function checkExpression (exp, text, warn, range) {
  10494. try {
  10495. new Function(("return " + exp));
  10496. } catch (e) {
  10497. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  10498. if (keywordMatch) {
  10499. warn(
  10500. "avoid using JavaScript keyword as property name: " +
  10501. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()),
  10502. range
  10503. );
  10504. } else {
  10505. warn(
  10506. "invalid expression: " + (e.message) + " in\n\n" +
  10507. " " + exp + "\n\n" +
  10508. " Raw expression: " + (text.trim()) + "\n",
  10509. range
  10510. );
  10511. }
  10512. }
  10513. }
  10514. function checkFunctionParameterExpression (exp, text, warn, range) {
  10515. try {
  10516. new Function(exp, '');
  10517. } catch (e) {
  10518. warn(
  10519. "invalid function parameter expression: " + (e.message) + " in\n\n" +
  10520. " " + exp + "\n\n" +
  10521. " Raw expression: " + (text.trim()) + "\n",
  10522. range
  10523. );
  10524. }
  10525. }
  10526. /* */
  10527. var range = 2;
  10528. function generateCodeFrame (
  10529. source,
  10530. start,
  10531. end
  10532. ) {
  10533. if ( start === void 0 ) start = 0;
  10534. if ( end === void 0 ) end = source.length;
  10535. var lines = source.split(/\r?\n/);
  10536. var count = 0;
  10537. var res = [];
  10538. for (var i = 0; i < lines.length; i++) {
  10539. count += lines[i].length + 1;
  10540. if (count >= start) {
  10541. for (var j = i - range; j <= i + range || end > count; j++) {
  10542. if (j < 0 || j >= lines.length) { continue }
  10543. res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j])));
  10544. var lineLength = lines[j].length;
  10545. if (j === i) {
  10546. // push underline
  10547. var pad = start - (count - lineLength) + 1;
  10548. var length = end > count ? lineLength - pad : end - start;
  10549. res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length));
  10550. } else if (j > i) {
  10551. if (end > count) {
  10552. var length$1 = Math.min(end - count, lineLength);
  10553. res.push(" | " + repeat$1("^", length$1));
  10554. }
  10555. count += lineLength + 1;
  10556. }
  10557. }
  10558. break
  10559. }
  10560. }
  10561. return res.join('\n')
  10562. }
  10563. function repeat$1 (str, n) {
  10564. var result = '';
  10565. if (n > 0) {
  10566. while (true) { // eslint-disable-line
  10567. if (n & 1) { result += str; }
  10568. n >>>= 1;
  10569. if (n <= 0) { break }
  10570. str += str;
  10571. }
  10572. }
  10573. return result
  10574. }
  10575. /* */
  10576. function createFunction (code, errors) {
  10577. try {
  10578. return new Function(code)
  10579. } catch (err) {
  10580. errors.push({ err: err, code: code });
  10581. return noop
  10582. }
  10583. }
  10584. function createCompileToFunctionFn (compile) {
  10585. var cache = Object.create(null);
  10586. return function compileToFunctions (
  10587. template,
  10588. options,
  10589. vm
  10590. ) {
  10591. options = extend({}, options);
  10592. var warn$$1 = options.warn || warn;
  10593. delete options.warn;
  10594. /* istanbul ignore if */
  10595. {
  10596. // detect possible CSP restriction
  10597. try {
  10598. new Function('return 1');
  10599. } catch (e) {
  10600. if (e.toString().match(/unsafe-eval|CSP/)) {
  10601. warn$$1(
  10602. 'It seems you are using the standalone build of Vue.js in an ' +
  10603. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  10604. 'The template compiler cannot work in this environment. Consider ' +
  10605. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  10606. 'templates into render functions.'
  10607. );
  10608. }
  10609. }
  10610. }
  10611. // check cache
  10612. var key = options.delimiters
  10613. ? String(options.delimiters) + template
  10614. : template;
  10615. if (cache[key]) {
  10616. return cache[key]
  10617. }
  10618. // compile
  10619. var compiled = compile(template, options);
  10620. // check compilation errors/tips
  10621. {
  10622. if (compiled.errors && compiled.errors.length) {
  10623. if (options.outputSourceRange) {
  10624. compiled.errors.forEach(function (e) {
  10625. warn$$1(
  10626. "Error compiling template:\n\n" + (e.msg) + "\n\n" +
  10627. generateCodeFrame(template, e.start, e.end),
  10628. vm
  10629. );
  10630. });
  10631. } else {
  10632. warn$$1(
  10633. "Error compiling template:\n\n" + template + "\n\n" +
  10634. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  10635. vm
  10636. );
  10637. }
  10638. }
  10639. if (compiled.tips && compiled.tips.length) {
  10640. if (options.outputSourceRange) {
  10641. compiled.tips.forEach(function (e) { return tip(e.msg, vm); });
  10642. } else {
  10643. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  10644. }
  10645. }
  10646. }
  10647. // turn code into functions
  10648. var res = {};
  10649. var fnGenErrors = [];
  10650. res.render = createFunction(compiled.render, fnGenErrors);
  10651. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  10652. return createFunction(code, fnGenErrors)
  10653. });
  10654. // check function generation errors.
  10655. // this should only happen if there is a bug in the compiler itself.
  10656. // mostly for codegen development use
  10657. /* istanbul ignore if */
  10658. {
  10659. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  10660. warn$$1(
  10661. "Failed to generate render function:\n\n" +
  10662. fnGenErrors.map(function (ref) {
  10663. var err = ref.err;
  10664. var code = ref.code;
  10665. return ((err.toString()) + " in\n\n" + code + "\n");
  10666. }).join('\n'),
  10667. vm
  10668. );
  10669. }
  10670. }
  10671. return (cache[key] = res)
  10672. }
  10673. }
  10674. /* */
  10675. function createCompilerCreator (baseCompile) {
  10676. return function createCompiler (baseOptions) {
  10677. function compile (
  10678. template,
  10679. options
  10680. ) {
  10681. var finalOptions = Object.create(baseOptions);
  10682. var errors = [];
  10683. var tips = [];
  10684. var warn = function (msg, range, tip) {
  10685. (tip ? tips : errors).push(msg);
  10686. };
  10687. if (options) {
  10688. if (options.outputSourceRange) {
  10689. // $flow-disable-line
  10690. var leadingSpaceLength = template.match(/^\s*/)[0].length;
  10691. warn = function (msg, range, tip) {
  10692. var data = { msg: msg };
  10693. if (range) {
  10694. if (range.start != null) {
  10695. data.start = range.start + leadingSpaceLength;
  10696. }
  10697. if (range.end != null) {
  10698. data.end = range.end + leadingSpaceLength;
  10699. }
  10700. }
  10701. (tip ? tips : errors).push(data);
  10702. };
  10703. }
  10704. // merge custom modules
  10705. if (options.modules) {
  10706. finalOptions.modules =
  10707. (baseOptions.modules || []).concat(options.modules);
  10708. }
  10709. // merge custom directives
  10710. if (options.directives) {
  10711. finalOptions.directives = extend(
  10712. Object.create(baseOptions.directives || null),
  10713. options.directives
  10714. );
  10715. }
  10716. // copy other options
  10717. for (var key in options) {
  10718. if (key !== 'modules' && key !== 'directives') {
  10719. finalOptions[key] = options[key];
  10720. }
  10721. }
  10722. }
  10723. finalOptions.warn = warn;
  10724. var compiled = baseCompile(template.trim(), finalOptions);
  10725. {
  10726. detectErrors(compiled.ast, warn);
  10727. }
  10728. compiled.errors = errors;
  10729. compiled.tips = tips;
  10730. return compiled
  10731. }
  10732. return {
  10733. compile: compile,
  10734. compileToFunctions: createCompileToFunctionFn(compile)
  10735. }
  10736. }
  10737. }
  10738. /* */
  10739. // `createCompilerCreator` allows creating compilers that use alternative
  10740. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  10741. // Here we just export a default compiler using the default parts.
  10742. var createCompiler = createCompilerCreator(function baseCompile (
  10743. template,
  10744. options
  10745. ) {
  10746. var ast = parse(template.trim(), options);
  10747. if (options.optimize !== false) {
  10748. optimize(ast, options);
  10749. }
  10750. var code = generate(ast, options);
  10751. return {
  10752. ast: ast,
  10753. render: code.render,
  10754. staticRenderFns: code.staticRenderFns
  10755. }
  10756. });
  10757. /* */
  10758. var ref$1 = createCompiler(baseOptions);
  10759. var compile = ref$1.compile;
  10760. var compileToFunctions = ref$1.compileToFunctions;
  10761. /* */
  10762. // check whether current browser encodes a char inside attribute values
  10763. var div;
  10764. function getShouldDecode (href) {
  10765. div = div || document.createElement('div');
  10766. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  10767. return div.innerHTML.indexOf('&#10;') > 0
  10768. }
  10769. // #3663: IE encodes newlines inside attribute values while other browsers don't
  10770. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  10771. // #6828: chrome encodes content in a[href]
  10772. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  10773. /* */
  10774. var idToTemplate = cached(function (id) {
  10775. var el = query(id);
  10776. return el && el.innerHTML
  10777. });
  10778. var mount = Vue.prototype.$mount;
  10779. Vue.prototype.$mount = function (
  10780. el,
  10781. hydrating
  10782. ) {
  10783. el = el && query(el);
  10784. /* istanbul ignore if */
  10785. if (el === document.body || el === document.documentElement) {
  10786. warn(
  10787. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  10788. );
  10789. return this
  10790. }
  10791. var options = this.$options;
  10792. // resolve template/el and convert to render function
  10793. if (!options.render) {
  10794. var template = options.template;
  10795. if (template) {
  10796. if (typeof template === 'string') {
  10797. if (template.charAt(0) === '#') {
  10798. template = idToTemplate(template);
  10799. /* istanbul ignore if */
  10800. if (!template) {
  10801. warn(
  10802. ("Template element not found or is empty: " + (options.template)),
  10803. this
  10804. );
  10805. }
  10806. }
  10807. } else if (template.nodeType) {
  10808. template = template.innerHTML;
  10809. } else {
  10810. {
  10811. warn('invalid template option:' + template, this);
  10812. }
  10813. return this
  10814. }
  10815. } else if (el) {
  10816. template = getOuterHTML(el);
  10817. }
  10818. if (template) {
  10819. /* istanbul ignore if */
  10820. if (config.performance && mark) {
  10821. mark('compile');
  10822. }
  10823. var ref = compileToFunctions(template, {
  10824. outputSourceRange: "development" !== 'production',
  10825. shouldDecodeNewlines: shouldDecodeNewlines,
  10826. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  10827. delimiters: options.delimiters,
  10828. comments: options.comments
  10829. }, this);
  10830. var render = ref.render;
  10831. var staticRenderFns = ref.staticRenderFns;
  10832. options.render = render;
  10833. options.staticRenderFns = staticRenderFns;
  10834. /* istanbul ignore if */
  10835. if (config.performance && mark) {
  10836. mark('compile end');
  10837. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  10838. }
  10839. }
  10840. }
  10841. return mount.call(this, el, hydrating)
  10842. };
  10843. /**
  10844. * Get outerHTML of elements, taking care
  10845. * of SVG elements in IE as well.
  10846. */
  10847. function getOuterHTML (el) {
  10848. if (el.outerHTML) {
  10849. return el.outerHTML
  10850. } else {
  10851. var container = document.createElement('div');
  10852. container.appendChild(el.cloneNode(true));
  10853. return container.innerHTML
  10854. }
  10855. }
  10856. Vue.compile = compileToFunctions;
  10857. module.exports = Vue;