vendor: 14,494 bytes, lines 1-543
1/*! 2 * Vue.js v2.6.10 3 * (c) 2014-2019 Evan You 4 * Released under the MIT License. 5 */ 6 7(function (global, factory) { 8 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 9 typeof define === 'function' && define.amd ? define(factory) : 10 (global = global || self, global.Vue = factory()); 11}(this, function () { 'use strict'; 12 13 /* */ 14 15 var emptyObject = Object.freeze({}); 16 17 // These helpers produce better VM code in JS engines due to their 18 // explicitness and function inlining. 19 function isUndef (v) { 20 return v === undefined || v === null 21 } 22 23 function isDef (v) { 24 return v !== undefined && v !== null 25 } 26 27 function isTrue (v) { 28 return v === true 29 } 30 31 function isFalse (v) { 32 return v === false 33 } 34 35 /** 36 * Check if value is primitive. 37 */ 38 function isPrimitive (value) { 39 return ( 40 typeof value === 'string' || 41 typeof value === 'number' || 42 // $flow-disable-line 43 typeof value === 'symbol' || 44 typeof value === 'boolean' 45 ) 46 } 47 48 /** 49 * Quick object check - this is primarily used to tell 50 * Objects from primitive values when we know the value 51 * is a JSON-compliant type. 52 */ 53 function isObject (obj) { 54 return obj !== null && typeof obj === 'object' 55 } 56 57 /** 58 * Get the raw type string of a value, e.g., [object Object]. 59 */ 60 var _toString = Object.prototype.toString; 61 62 function toRawType (value) { 63 return _toString.call(value).slice(8, -1) 64 } 65 66 /** 67 * Strict object type check. Only returns true 68 * for plain JavaScript objects. 69 */ 70 function isPlainObject (obj) { 71 return _toString.call(obj) === '[object Object]' 72 } 73 74 function isRegExp (v) { 75 return _toString.call(v) === '[object RegExp]' 76 } 77 78 /** 79 * Check if val is a valid array index. 80 */ 81 function isValidArrayIndex (val) { 82 var n = parseFloat(String(val)); 83 return n >= 0 && Math.floor(n) === n && isFinite(val) 84 } 85 86 function isPromise (val) { 87 return ( 88 isDef(val) && 89 typeof val.then === 'function' && 90 typeof val.catch === 'function' 91 ) 92 } 93 94 /** 95 * Convert a value to a string that is actually rendered. 96 */ 97 function toString (val) { 98 return val == null 99 ? '' 100 : Array.isArray(val) || (isPlainObject(val) && val.toString === _toString) 101 ? JSON.stringify(val, null, 2) 102 : String(val) 103 } 104 105 /** 106 * Convert an input value to a number for persistence. 107 * If the conversion fails, return original string. 108 */ 109 function toNumber (val) { 110 var n = parseFloat(val); 111 return isNaN(n) ? val : n 112 } 113 114 /** 115 * Make a map and return a function for checking if a key 116 * is in that map. 117 */ 118 function makeMap ( 119 str, 120 expectsLowerCase 121 ) { 122 var map = Object.create(null); 123 var list = str.split(','); 124 for (var i = 0; i < list.length; i++) { 125 map[list[i]] = true; 126 } 127 return expectsLowerCase 128 ? function (val) { return map[val.toLowerCase()]; } 129 : function (val) { return map[val]; } 130 } 131 132 /** 133 * Check if a tag is a built-in tag. 134 */ 135 var isBuiltInTag = makeMap('slot,component', true); 136 137 /** 138 * Check if an attribute is a reserved attribute. 139 */ 140 var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); 141 142 /** 143 * Remove an item from an array. 144 */ 145 function remove (arr, item) { 146 if (arr.length) { 147 var index = arr.indexOf(item); 148 if (index > -1) { 149 return arr.splice(index, 1) 150 } 151 } 152 } 153 154 /** 155 * Check whether an object has the property. 156 */ 157 var hasOwnProperty = Object.prototype.hasOwnProperty; 158 function hasOwn (obj, key) { 159 return hasOwnProperty.call(obj, key) 160 } 161 162 /** 163 * Create a cached version of a pure function. 164 */ 165 function cached (fn) { 166 var cache = Object.create(null); 167 return (function cachedFn (str) { 168 var hit = cache[str]; 169 return hit || (cache[str] = fn(str)) 170 }) 171 } 172 173 /** 174 * Camelize a hyphen-delimited string. 175 */ 176 var camelizeRE = /-(\w)/g; 177 var camelize = cached(function (str) { 178 return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) 179 }); 180 181 /** 182 * Capitalize a string. 183 */ 184 var capitalize = cached(function (str) { 185 return str.charAt(0).toUpperCase() + str.slice(1) 186 }); 187 188 /** 189 * Hyphenate a camelCase string. 190 */ 191 var hyphenateRE = /\B([A-Z])/g; 192 var hyphenate = cached(function (str) { 193 return str.replace(hyphenateRE, '-$1').toLowerCase() 194 }); 195 196 /** 197 * Simple bind polyfill for environments that do not support it, 198 * e.g., PhantomJS 1.x. Technically, we don't need this anymore 199 * since native bind is now performant enough in most browsers. 200 * But removing it would mean breaking code that was able to run in 201 * PhantomJS 1.x, so this must be kept for backward compatibility. 202 */ 203 204 /* istanbul ignore next */ 205 function polyfillBind (fn, ctx) { 206 function boundFn (a) { 207 var l = arguments.length; 208 return l 209 ? l > 1 210 ? fn.apply(ctx, arguments) 211 : fn.call(ctx, a) 212 : fn.call(ctx) 213 } 214 215 boundFn._length = fn.length; 216 return boundFn 217 } 218 219 function nativeBind (fn, ctx) { 220 return fn.bind(ctx) 221 } 222 223 var bind = Function.prototype.bind 224 ? nativeBind 225 : polyfillBind; 226 227 /** 228 * Convert an Array-like object to a real Array. 229 */ 230 function toArray (list, start) { 231 start = start || 0; 232 var i = list.length - start; 233 var ret = new Array(i); 234 while (i--) { 235 ret[i] = list[i + start]; 236 } 237 return ret 238 } 239 240 /** 241 * Mix properties into target object. 242 */ 243 function extend (to, _from) { 244 for (var key in _from) { 245 to[key] = _from[key]; 246 } 247 return to 248 } 249 250 /** 251 * Merge an Array of Objects into a single Object. 252 */ 253 function toObject (arr) { 254 var res = {}; 255 for (var i = 0; i < arr.length; i++) { 256 if (arr[i]) { 257 extend(res, arr[i]); 258 } 259 } 260 return res 261 } 262 263 /* eslint-disable no-unused-vars */ 264 265 /** 266 * Perform no operation. 267 * Stubbing args to make Flow happy without leaving useless transpiled code 268 * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/). 269 */ 270 function noop (a, b, c) {} 271 272 /** 273 * Always return false. 274 */ 275 var no = function (a, b, c) { return false; }; 276 277 /* eslint-enable no-unused-vars */ 278 279 /** 280 * Return the same value. 281 */ 282 var identity = function (_) { return _; }; 283 284 /** 285 * Generate a string containing static keys from compiler modules. 286 */ 287 function genStaticKeys (modules) { 288 return modules.reduce(function (keys, m) { 289 return keys.concat(m.staticKeys || []) 290 }, []).join(',') 291 } 292 293 /** 294 * Check if two values are loosely equal - that is, 295 * if they are plain objects, do they have the same shape? 296 */ 297 function looseEqual (a, b) { 298 if (a === b) { return true } 299 var isObjectA = isObject(a); 300 var isObjectB = isObject(b); 301 if (isObjectA && isObjectB) { 302 try { 303 var isArrayA = Array.isArray(a); 304 var isArrayB = Array.isArray(b); 305 if (isArrayA && isArrayB) { 306 return a.length === b.length && a.every(function (e, i) { 307 return looseEqual(e, b[i]) 308 }) 309 } else if (a instanceof Date && b instanceof Date) { 310 return a.getTime() === b.getTime() 311 } else if (!isArrayA && !isArrayB) { 312 var keysA = Object.keys(a); 313 var keysB = Object.keys(b); 314 return keysA.length === keysB.length && keysA.every(function (key) { 315 return looseEqual(a[key], b[key]) 316 }) 317 } else { 318 /* istanbul ignore next */ 319 return false 320 } 321 } catch (e) { 322 /* istanbul ignore next */ 323 return false 324 } 325 } else if (!isObjectA && !isObjectB) { 326 return String(a) === String(b) 327 } else { 328 return false 329 } 330 } 331 332 /** 333 * Return the first index at which a loosely equal value can be 334 * found in the array (if value is a plain object, the array must 335 * contain an object of the same shape), or -1 if it is not present. 336 */ 337 function looseIndexOf (arr, val) { 338 for (var i = 0; i < arr.length; i++) { 339 if (looseEqual(arr[i], val)) { return i } 340 } 341 return -1 342 } 343 344 /** 345 * Ensure a function is called only once. 346 */ 347 function once (fn) { 348 var called = false; 349 return function () { 350 if (!called) { 351 called = true; 352 fn.apply(this, arguments); 353 } 354 } 355 } 356 357 var SSR_ATTR = 'data-server-rendered'; 358 359 var ASSET_TYPES = [ 360 'component', 361 'directive', 362 'filter' 363 ]; 364 365 var LIFECYCLE_HOOKS = [ 366 'beforeCreate', 367 'created', 368 'beforeMount', 369 'mounted', 370 'beforeUpdate', 371 'updated', 372 'beforeDestroy', 373 'destroyed', 374 'activated', 375 'deactivated', 376 'errorCaptured', 377 'serverPrefetch' 378 ]; 379 380 /* */ 381 382 383 384 var config = ({ 385 /** 386 * Option merge strategies (used in core/util/options) 387 */ 388 // $flow-disable-line 389 optionMergeStrategies: Object.create(null), 390 391 /** 392 * Whether to suppress warnings. 393 */ 394 silent: false, 395 396 /** 397 * Show production mode tip message on boot? 398 */ 399 productionTip: "development" !== 'production', 400 401 /** 402 * Whether to enable devtools 403 */ 404 devtools: "development" !== 'production', 405 406 /** 407 * Whether to record perf 408 */ 409 performance: false, 410 411 /** 412 * Error handler for watcher errors 413 */ 414 errorHandler: null, 415 416 /** 417 * Warn handler for watcher warns 418 */ 419 warnHandler: null, 420 421 /** 422 * Ignore certain custom elements 423 */ 424 ignoredElements: [], 425 426 /** 427 * Custom user key aliases for v-on 428 */ 429 // $flow-disable-line 430 keyCodes: Object.create(null), 431 432 /** 433 * Check if a tag is reserved so that it cannot be registered as a 434 * component. This is platform-dependent and may be overwritten. 435 */ 436 isReservedTag: no, 437 438 /** 439 * Check if an attribute is reserved so that it cannot be used as a component 440 * prop. This is platform-dependent and may be overwritten. 441 */ 442 isReservedAttr: no, 443 444 /** 445 * Check if a tag is an unknown element. 446 * Platform-dependent. 447 */ 448 isUnknownElement: no, 449 450 /** 451 * Get the namespace of an element 452 */ 453 getTagNamespace: noop, 454 455 /** 456 * Parse the real tag name for the specific platform. 457 */ 458 parsePlatformTagName: identity, 459 460 /** 461 * Check if an attribute must be bound using property, e.g. value 462 * Platform-dependent. 463 */ 464 mustUseProp: no, 465 466 /** 467 * Perform updates asynchronously. Intended to be used by Vue Test Utils 468 * This will significantly reduce performance if set to false. 469 */ 470 async: true, 471 472 /** 473 * Exposed for legacy reasons 474 */ 475 _lifecycleHooks: LIFECYCLE_HOOKS 476 }); 477 478 /* */ 479 480 /** 481 * unicode letters used for parsing html tags, component names and property paths. 482 * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname 483 * skipping \u10000-\uEFFFF due to it freezing up PhantomJS 484 */ 485 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/; 486 487 /** 488 * Check if a string starts with $ or _ 489 */ 490 function isReserved (str) { 491 var c = (str + '').charCodeAt(0); 492 return c === 0x24 || c === 0x5F 493 } 494 495 /** 496 * Define a property. 497 */ 498 function def (obj, key, val, enumerable) { 499 Object.defineProperty(obj, key, { 500 value: val, 501 enumerable: !!enumerable, 502 writable: true, 503 configurable: true 504 }); 505 } 506 507 /** 508 * Parse simple path. 509 */ 510 var bailRE = new RegExp(("[^" + (unicodeRegExp.source) + ".$_\\d]")); 511 function parsePath (path) { 512 if (bailRE.test(path)) { 513 return 514 } 515 var segments = path.split('.'); 516 return function (obj) { 517 for (var i = 0; i < segments.length; i++) { 518 if (!obj) { return } 519 obj = obj[segments[i]]; 520 } 521 return obj 522 } 523 } 524 525 /* */ 526 527 // can we use __proto__? 528 var hasProto = '__proto__' in {}; 529 530 // Browser environment sniffing 531 var inBrowser = typeof window !== 'undefined'; 532 var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; 533 var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase(); 534 var UA = inBrowser && window.navigator.userAgent.toLowerCase(); 535 var isIE = UA && /msie|trident/.test(UA); 536 var isIE9 = UA && UA.indexOf('msie 9.0') > 0; 537 var isEdge = UA && UA.indexOf('edge/') > 0; 538 var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android'); 539 var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios'); 540 var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; 541 var isPhantomJS = UA && /phantomjs/.test(UA); 542 var isFF = UA && UA.match(/firefox\/(\d+)/); 543
vendor: 6,218 bytes, lines 544-729
544 // Firefox has a "watch" function on Object.prototype... 545 var nativeWatch = ({}).watch; 546 547 var supportsPassive = false; 548 if (inBrowser) { 549 try { 550 var opts = {}; 551 Object.defineProperty(opts, 'passive', ({ 552 get: function get () { 553 /* istanbul ignore next */ 554 supportsPassive = true; 555 } 556 })); // https://github.com/facebook/flow/issues/285 557 window.addEventListener('test-passive', null, opts); 558 } catch (e) {} 559 } 560 561 // this needs to be lazy-evaled because vue may be required before 562 // vue-server-renderer can set VUE_ENV 563 var _isServer; 564 var isServerRendering = function () { 565 if (_isServer === undefined) { 566 /* istanbul ignore if */ 567 if (!inBrowser && !inWeex && typeof global !== 'undefined') { 568 // detect presence of vue-server-renderer and avoid 569 // Webpack shimming the process 570 _isServer = global['process'] && global['process'].env.VUE_ENV === 'server'; 571 } else { 572 _isServer = false; 573 } 574 } 575 return _isServer 576 }; 577 578 // detect devtools 579 var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; 580 581 /* istanbul ignore next */ 582 function isNative (Ctor) { 583 return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) 584 } 585 586 var hasSymbol = 587 typeof Symbol !== 'undefined' && isNative(Symbol) && 588 typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); 589 590 var _Set; 591 /* istanbul ignore if */ // $flow-disable-line 592 if (typeof Set !== 'undefined' && isNative(Set)) { 593 // use native Set when available. 594 _Set = Set; 595 } else { 596 // a non-standard Set polyfill that only works with primitive keys. 597 _Set = /*@__PURE__*/(function () { 598 function Set () { 599 this.set = Object.create(null); 600 } 601 Set.prototype.has = function has (key) { 602 return this.set[key] === true 603 }; 604 Set.prototype.add = function add (key) { 605 this.set[key] = true; 606 }; 607 Set.prototype.clear = function clear () { 608 this.set = Object.create(null); 609 }; 610 611 return Set; 612 }()); 613 } 614 615 /* */ 616 617 var warn = noop; 618 var tip = noop; 619 var generateComponentTrace = (noop); // work around flow check 620 var formatComponentName = (noop); 621 622 { 623 var hasConsole = typeof console !== 'undefined'; 624 var classifyRE = /(?:^|[-_])(\w)/g; 625 var classify = function (str) { return str 626 .replace(classifyRE, function (c) { return c.toUpperCase(); }) 627 .replace(/[-_]/g, ''); }; 628 629 warn = function (msg, vm) { 630 var trace = vm ? generateComponentTrace(vm) : ''; 631 632 if (config.warnHandler) { 633 config.warnHandler.call(null, msg, vm, trace); 634 } else if (hasConsole && (!config.silent)) { 635 console.error(("[Vue warn]: " + msg + trace)); 636 } 637 }; 638 639 tip = function (msg, vm) { 640 if (hasConsole && (!config.silent)) { 641 console.warn("[Vue tip]: " + msg + ( 642 vm ? generateComponentTrace(vm) : '' 643 )); 644 } 645 }; 646 647 formatComponentName = function (vm, includeFile) { 648 if (vm.$root === vm) { 649 return '<Root>' 650 } 651 var options = typeof vm === 'function' && vm.cid != null 652 ? vm.options 653 : vm._isVue 654 ? vm.$options || vm.constructor.options 655 : vm; 656 var name = options.name || options._componentTag; 657 var file = options.__file; 658 if (!name && file) { 659 var match = file.match(/([^/\\]+)\.vue$/); 660 name = match && match[1]; 661 } 662 663 return ( 664 (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") + 665 (file && includeFile !== false ? (" at " + file) : '') 666 ) 667 }; 668 669 var repeat = function (str, n) { 670 var res = ''; 671 while (n) { 672 if (n % 2 === 1) { res += str; } 673 if (n > 1) { str += str; } 674 n >>= 1; 675 } 676 return res 677 }; 678 679 generateComponentTrace = function (vm) { 680 if (vm._isVue && vm.$parent) { 681 var tree = []; 682 var currentRecursiveSequence = 0; 683 while (vm) { 684 if (tree.length > 0) { 685 var last = tree[tree.length - 1]; 686 if (last.constructor === vm.constructor) { 687 currentRecursiveSequence++; 688 vm = vm.$parent; 689 continue 690 } else if (currentRecursiveSequence > 0) { 691 tree[tree.length - 1] = [last, currentRecursiveSequence]; 692 currentRecursiveSequence = 0; 693 } 694 } 695 tree.push(vm); 696 vm = vm.$parent; 697 } 698 return '\n\nfound in\n\n' + tree 699 .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm) 700 ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)") 701 : formatComponentName(vm))); }) 702 .join('\n') 703 } else { 704 return ("\n\n(found in " + (formatComponentName(vm)) + ")") 705 } 706 }; 707 } 708 709 /* */ 710 711 var uid = 0; 712 713 /** 714 * A dep is an observable that can have multiple 715 * directives subscribing to it. 716 */ 717 var Dep = function Dep () { 718 this.id = uid++; 719 this.subs = []; 720 }; 721 722 Dep.prototype.addSub = function addSub (sub) { 723 this.subs.push(sub); 724 }; 725 726 Dep.prototype.removeSub = function removeSub (sub) { 727 remove(this.subs, sub); 728 }; 729
vendor: 26,088 bytes, lines 730-1621
730 Dep.prototype.depend = function depend () { 731 if (Dep.target) { 732 Dep.target.addDep(this); 733 } 734 }; 735 736 Dep.prototype.notify = function notify () { 737 // stabilize the subscriber list first 738 var subs = this.subs.slice(); 739 if (!config.async) { 740 // subs aren't sorted in scheduler if not running async 741 // we need to sort them now to make sure they fire in correct 742 // order 743 subs.sort(function (a, b) { return a.id - b.id; }); 744 } 745 for (var i = 0, l = subs.length; i < l; i++) { 746 subs[i].update(); 747 } 748 }; 749 750 // The current target watcher being evaluated. 751 // This is globally unique because only one watcher 752 // can be evaluated at a time. 753 Dep.target = null; 754 var targetStack = []; 755 756 function pushTarget (target) { 757 targetStack.push(target); 758 Dep.target = target; 759 } 760 761 function popTarget () { 762 targetStack.pop(); 763 Dep.target = targetStack[targetStack.length - 1]; 764 } 765 766 /* */ 767 768 var VNode = function VNode ( 769 tag, 770 data, 771 children, 772 text, 773 elm, 774 context, 775 componentOptions, 776 asyncFactory 777 ) { 778 this.tag = tag; 779 this.data = data; 780 this.children = children; 781 this.text = text; 782 this.elm = elm; 783 this.ns = undefined; 784 this.context = context; 785 this.fnContext = undefined; 786 this.fnOptions = undefined; 787 this.fnScopeId = undefined; 788 this.key = data && data.key; 789 this.componentOptions = componentOptions; 790 this.componentInstance = undefined; 791 this.parent = undefined; 792 this.raw = false; 793 this.isStatic = false; 794 this.isRootInsert = true; 795 this.isComment = false; 796 this.isCloned = false; 797 this.isOnce = false; 798 this.asyncFactory = asyncFactory; 799 this.asyncMeta = undefined; 800 this.isAsyncPlaceholder = false; 801 }; 802 803 var prototypeAccessors = { child: { configurable: true } }; 804 805 // DEPRECATED: alias for componentInstance for backwards compat. 806 /* istanbul ignore next */ 807 prototypeAccessors.child.get = function () { 808 return this.componentInstance 809 }; 810 811 Object.defineProperties( VNode.prototype, prototypeAccessors ); 812 813 var createEmptyVNode = function (text) { 814 if ( text === void 0 ) text = ''; 815 816 var node = new VNode(); 817 node.text = text; 818 node.isComment = true; 819 return node 820 }; 821 822 function createTextVNode (val) { 823 return new VNode(undefined, undefined, undefined, String(val)) 824 } 825 826 // optimized shallow clone 827 // used for static nodes and slot nodes because they may be reused across 828 // multiple renders, cloning them avoids errors when DOM manipulations rely 829 // on their elm reference. 830 function cloneVNode (vnode) { 831 var cloned = new VNode( 832 vnode.tag, 833 vnode.data, 834 // #7975 835 // clone children array to avoid mutating original in case of cloning 836 // a child. 837 vnode.children && vnode.children.slice(), 838 vnode.text, 839 vnode.elm, 840 vnode.context, 841 vnode.componentOptions, 842 vnode.asyncFactory 843 ); 844 cloned.ns = vnode.ns; 845 cloned.isStatic = vnode.isStatic; 846 cloned.key = vnode.key; 847 cloned.isComment = vnode.isComment; 848 cloned.fnContext = vnode.fnContext; 849 cloned.fnOptions = vnode.fnOptions; 850 cloned.fnScopeId = vnode.fnScopeId; 851 cloned.asyncMeta = vnode.asyncMeta; 852 cloned.isCloned = true; 853 return cloned 854 } 855 856 /* 857 * not type checking this file because flow doesn't play well with 858 * dynamically accessing methods on Array prototype 859 */ 860 861 var arrayProto = Array.prototype; 862 var arrayMethods = Object.create(arrayProto); 863 864 var methodsToPatch = [ 865 'push', 866 'pop', 867 'shift', 868 'unshift', 869 'splice', 870 'sort', 871 'reverse' 872 ]; 873 874 /** 875 * Intercept mutating methods and emit events 876 */ 877 methodsToPatch.forEach(function (method) { 878 // cache original method 879 var original = arrayProto[method]; 880 def(arrayMethods, method, function mutator () { 881 var args = [], len = arguments.length; 882 while ( len-- ) args[ len ] = arguments[ len ]; 883 884 var result = original.apply(this, args); 885 var ob = this.__ob__; 886 var inserted; 887 switch (method) { 888 case 'push': 889 case 'unshift': 890 inserted = args; 891 break 892 case 'splice': 893 inserted = args.slice(2); 894 break 895 } 896 if (inserted) { ob.observeArray(inserted); } 897 // notify change 898 ob.dep.notify(); 899 return result 900 }); 901 }); 902 903 /* */ 904 905 var arrayKeys = Object.getOwnPropertyNames(arrayMethods); 906 907 /** 908 * In some cases we may want to disable observation inside a component's 909 * update computation. 910 */ 911 var shouldObserve = true; 912 913 function toggleObserving (value) { 914 shouldObserve = value; 915 } 916 917 /** 918 * Observer class that is attached to each observed 919 * object. Once attached, the observer converts the target 920 * object's property keys into getter/setters that 921 * collect dependencies and dispatch updates. 922 */ 923 var Observer = function Observer (value) { 924 this.value = value; 925 this.dep = new Dep(); 926 this.vmCount = 0; 927 def(value, '__ob__', this); 928 if (Array.isArray(value)) { 929 if (hasProto) { 930 protoAugment(value, arrayMethods); 931 } else { 932 copyAugment(value, arrayMethods, arrayKeys); 933 } 934 this.observeArray(value); 935 } else { 936 this.walk(value); 937 } 938 }; 939 940 /** 941 * Walk through all properties and convert them into 942 * getter/setters. This method should only be called when 943 * value type is Object. 944 */ 945 Observer.prototype.walk = function walk (obj) { 946 var keys = Object.keys(obj); 947 for (var i = 0; i < keys.length; i++) { 948 defineReactive$$1(obj, keys[i]); 949 } 950 }; 951 952 /** 953 * Observe a list of Array items. 954 */ 955 Observer.prototype.observeArray = function observeArray (items) { 956 for (var i = 0, l = items.length; i < l; i++) { 957 observe(items[i]); 958 } 959 }; 960 961 // helpers 962 963 /** 964 * Augment a target Object or Array by intercepting 965 * the prototype chain using __proto__ 966 */ 967 function protoAugment (target, src) { 968 /* eslint-disable no-proto */ 969 target.__proto__ = src; 970 /* eslint-enable no-proto */ 971 } 972 973 /** 974 * Augment a target Object or Array by defining 975 * hidden properties. 976 */ 977 /* istanbul ignore next */ 978 function copyAugment (target, src, keys) { 979 for (var i = 0, l = keys.length; i < l; i++) { 980 var key = keys[i]; 981 def(target, key, src[key]); 982 } 983 } 984 985 /** 986 * Attempt to create an observer instance for a value, 987 * returns the new observer if successfully observed, 988 * or the existing observer if the value already has one. 989 */ 990 function observe (value, asRootData) { 991 if (!isObject(value) || value instanceof VNode) { 992 return 993 } 994 var ob; 995 if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { 996 ob = value.__ob__; 997 } else if ( 998 shouldObserve && 999 !isServerRendering() && 1000 (Array.isArray(value) || isPlainObject(value)) && 1001 Object.isExtensible(value) && 1002 !value._isVue 1003 ) { 1004 ob = new Observer(value); 1005 } 1006 if (asRootData && ob) { 1007 ob.vmCount++; 1008 } 1009 return ob 1010 } 1011 1012 /** 1013 * Define a reactive property on an Object. 1014 */ 1015 function defineReactive$$1 ( 1016 obj, 1017 key, 1018 val, 1019 customSetter, 1020 shallow 1021 ) { 1022 var dep = new Dep(); 1023 1024 var property = Object.getOwnPropertyDescriptor(obj, key); 1025 if (property && property.configurable === false) { 1026 return 1027 } 1028 1029 // cater for pre-defined getter/setters 1030 var getter = property && property.get; 1031 var setter = property && property.set; 1032 if ((!getter || setter) && arguments.length === 2) { 1033 val = obj[key]; 1034 } 1035 1036 var childOb = !shallow && observe(val); 1037 Object.defineProperty(obj, key, { 1038 enumerable: true, 1039 configurable: true, 1040 get: function reactiveGetter () { 1041 var value = getter ? getter.call(obj) : val; 1042 if (Dep.target) { 1043 dep.depend(); 1044 if (childOb) { 1045 childOb.dep.depend(); 1046 if (Array.isArray(value)) { 1047 dependArray(value); 1048 } 1049 } 1050 } 1051 return value 1052 }, 1053 set: function reactiveSetter (newVal) { 1054 var value = getter ? getter.call(obj) : val; 1055 /* eslint-disable no-self-compare */ 1056 if (newVal === value || (newVal !== newVal && value !== value)) { 1057 return 1058 } 1059 /* eslint-enable no-self-compare */ 1060 if (customSetter) { 1061 customSetter(); 1062 } 1063 // #7981: for accessor properties without setter 1064 if (getter && !setter) { return } 1065 if (setter) { 1066 setter.call(obj, newVal); 1067 } else { 1068 val = newVal; 1069 } 1070 childOb = !shallow && observe(newVal); 1071 dep.notify(); 1072 } 1073 }); 1074 } 1075 1076 /** 1077 * Set a property on an object. Adds the new property and 1078 * triggers change notification if the property doesn't 1079 * already exist. 1080 */ 1081 function set (target, key, val) { 1082 if (isUndef(target) || isPrimitive(target) 1083 ) { 1084 warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target)))); 1085 } 1086 if (Array.isArray(target) && isValidArrayIndex(key)) { 1087 target.length = Math.max(target.length, key); 1088 target.splice(key, 1, val); 1089 return val 1090 } 1091 if (key in target && !(key in Object.prototype)) { 1092 target[key] = val; 1093 return val 1094 } 1095 var ob = (target).__ob__; 1096 if (target._isVue || (ob && ob.vmCount)) { 1097 warn( 1098 'Avoid adding reactive properties to a Vue instance or its root $data ' + 1099 'at runtime - declare it upfront in the data option.' 1100 ); 1101 return val 1102 } 1103 if (!ob) { 1104 target[key] = val; 1105 return val 1106 } 1107 defineReactive$$1(ob.value, key, val); 1108 ob.dep.notify(); 1109 return val 1110 } 1111 1112 /** 1113 * Delete a property and trigger change if necessary. 1114 */ 1115 function del (target, key) { 1116 if (isUndef(target) || isPrimitive(target) 1117 ) { 1118 warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target)))); 1119 } 1120 if (Array.isArray(target) && isValidArrayIndex(key)) { 1121 target.splice(key, 1); 1122 return 1123 } 1124 var ob = (target).__ob__; 1125 if (target._isVue || (ob && ob.vmCount)) { 1126 warn( 1127 'Avoid deleting properties on a Vue instance or its root $data ' + 1128 '- just set it to null.' 1129 ); 1130 return 1131 } 1132 if (!hasOwn(target, key)) { 1133 return 1134 } 1135 delete target[key]; 1136 if (!ob) { 1137 return 1138 } 1139 ob.dep.notify(); 1140 } 1141 1142 /** 1143 * Collect dependencies on array elements when the array is touched, since 1144 * we cannot intercept array element access like property getters. 1145 */ 1146 function dependArray (value) { 1147 for (var e = (void 0), i = 0, l = value.length; i < l; i++) { 1148 e = value[i]; 1149 e && e.__ob__ && e.__ob__.dep.depend(); 1150 if (Array.isArray(e)) { 1151 dependArray(e); 1152 } 1153 } 1154 } 1155 1156 /* */ 1157 1158 /** 1159 * Option overwriting strategies are functions that handle 1160 * how to merge a parent option value and a child option 1161 * value into the final value. 1162 */ 1163 var strats = config.optionMergeStrategies; 1164 1165 /** 1166 * Options with restrictions 1167 */ 1168 { 1169 strats.el = strats.propsData = function (parent, child, vm, key) { 1170 if (!vm) { 1171 warn( 1172 "option \"" + key + "\" can only be used during instance " + 1173 'creation with the `new` keyword.' 1174 ); 1175 } 1176 return defaultStrat(parent, child) 1177 }; 1178 } 1179 1180 /** 1181 * Helper that recursively merges two data objects together. 1182 */ 1183 function mergeData (to, from) { 1184 if (!from) { return to } 1185 var key, toVal, fromVal; 1186 1187 var keys = hasSymbol 1188 ? Reflect.ownKeys(from) 1189 : Object.keys(from); 1190 1191 for (var i = 0; i < keys.length; i++) { 1192 key = keys[i]; 1193 // in case the object is already observed... 1194 if (key === '__ob__') { continue } 1195 toVal = to[key]; 1196 fromVal = from[key]; 1197 if (!hasOwn(to, key)) { 1198 set(to, key, fromVal); 1199 } else if ( 1200 toVal !== fromVal && 1201 isPlainObject(toVal) && 1202 isPlainObject(fromVal) 1203 ) { 1204 mergeData(toVal, fromVal); 1205 } 1206 } 1207 return to 1208 } 1209 1210 /** 1211 * Data 1212 */ 1213 function mergeDataOrFn ( 1214 parentVal, 1215 childVal, 1216 vm 1217 ) { 1218 if (!vm) { 1219 // in a Vue.extend merge, both should be functions 1220 if (!childVal) { 1221 return parentVal 1222 } 1223 if (!parentVal) { 1224 return childVal 1225 } 1226 // when parentVal & childVal are both present, 1227 // we need to return a function that returns the 1228 // merged result of both functions... no need to 1229 // check if parentVal is a function here because 1230 // it has to be a function to pass previous merges. 1231 return function mergedDataFn () { 1232 return mergeData( 1233 typeof childVal === 'function' ? childVal.call(this, this) : childVal, 1234 typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal 1235 ) 1236 } 1237 } else { 1238 return function mergedInstanceDataFn () { 1239 // instance merge 1240 var instanceData = typeof childVal === 'function' 1241 ? childVal.call(vm, vm) 1242 : childVal; 1243 var defaultData = typeof parentVal === 'function' 1244 ? parentVal.call(vm, vm) 1245 : parentVal; 1246 if (instanceData) { 1247 return mergeData(instanceData, defaultData) 1248 } else { 1249 return defaultData 1250 } 1251 } 1252 } 1253 } 1254 1255 strats.data = function ( 1256 parentVal, 1257 childVal, 1258 vm 1259 ) { 1260 if (!vm) { 1261 if (childVal && typeof childVal !== 'function') { 1262 warn( 1263 'The "data" option should be a function ' + 1264 'that returns a per-instance value in component ' + 1265 'definitions.', 1266 vm 1267 ); 1268 1269 return parentVal 1270 } 1271 return mergeDataOrFn(parentVal, childVal) 1272 } 1273 1274 return mergeDataOrFn(parentVal, childVal, vm) 1275 }; 1276 1277 /** 1278 * Hooks and props are merged as arrays. 1279 */ 1280 function mergeHook ( 1281 parentVal, 1282 childVal 1283 ) { 1284 var res = childVal 1285 ? parentVal 1286 ? parentVal.concat(childVal) 1287 : Array.isArray(childVal) 1288 ? childVal 1289 : [childVal] 1290 : parentVal; 1291 return res 1292 ? dedupeHooks(res) 1293 : res 1294 } 1295 1296 function dedupeHooks (hooks) { 1297 var res = []; 1298 for (var i = 0; i < hooks.length; i++) { 1299 if (res.indexOf(hooks[i]) === -1) { 1300 res.push(hooks[i]); 1301 } 1302 } 1303 return res 1304 } 1305 1306 LIFECYCLE_HOOKS.forEach(function (hook) { 1307 strats[hook] = mergeHook; 1308 }); 1309 1310 /** 1311 * Assets 1312 * 1313 * When a vm is present (instance creation), we need to do 1314 * a three-way merge between constructor options, instance 1315 * options and parent options. 1316 */ 1317 function mergeAssets ( 1318 parentVal, 1319 childVal, 1320 vm, 1321 key 1322 ) { 1323 var res = Object.create(parentVal || null); 1324 if (childVal) { 1325 assertObjectType(key, childVal, vm); 1326 return extend(res, childVal) 1327 } else { 1328 return res 1329 } 1330 } 1331 1332 ASSET_TYPES.forEach(function (type) { 1333 strats[type + 's'] = mergeAssets; 1334 }); 1335 1336 /** 1337 * Watchers. 1338 * 1339 * Watchers hashes should not overwrite one 1340 * another, so we merge them as arrays. 1341 */ 1342 strats.watch = function ( 1343 parentVal, 1344 childVal, 1345 vm, 1346 key 1347 ) { 1348 // work around Firefox's Object.prototype.watch... 1349 if (parentVal === nativeWatch) { parentVal = undefined; } 1350 if (childVal === nativeWatch) { childVal = undefined; } 1351 /* istanbul ignore if */ 1352 if (!childVal) { return Object.create(parentVal || null) } 1353 { 1354 assertObjectType(key, childVal, vm); 1355 } 1356 if (!parentVal) { return childVal } 1357 var ret = {}; 1358 extend(ret, parentVal); 1359 for (var key$1 in childVal) { 1360 var parent = ret[key$1]; 1361 var child = childVal[key$1]; 1362 if (parent && !Array.isArray(parent)) { 1363 parent = [parent]; 1364 } 1365 ret[key$1] = parent 1366 ? parent.concat(child) 1367 : Array.isArray(child) ? child : [child]; 1368 } 1369 return ret 1370 }; 1371 1372 /** 1373 * Other object hashes. 1374 */ 1375 strats.props = 1376 strats.methods = 1377 strats.inject = 1378 strats.computed = function ( 1379 parentVal, 1380 childVal, 1381 vm, 1382 key 1383 ) { 1384 if (childVal && "development" !== 'production') { 1385 assertObjectType(key, childVal, vm); 1386 } 1387 if (!parentVal) { return childVal } 1388 var ret = Object.create(null); 1389 extend(ret, parentVal); 1390 if (childVal) { extend(ret, childVal); } 1391 return ret 1392 }; 1393 strats.provide = mergeDataOrFn; 1394 1395 /** 1396 * Default strategy. 1397 */ 1398 var defaultStrat = function (parentVal, childVal) { 1399 return childVal === undefined 1400 ? parentVal 1401 : childVal 1402 }; 1403 1404 /** 1405 * Validate component names 1406 */ 1407 function checkComponents (options) { 1408 for (var key in options.components) { 1409 validateComponentName(key); 1410 } 1411 } 1412 1413 function validateComponentName (name) { 1414 if (!new RegExp(("^[a-zA-Z][\\-\\.0-9_" + (unicodeRegExp.source) + "]*$")).test(name)) { 1415 warn( 1416 'Invalid component name: "' + name + '". Component names ' + 1417 'should conform to valid custom element name in html5 specification.' 1418 ); 1419 } 1420 if (isBuiltInTag(name) || config.isReservedTag(name)) { 1421 warn( 1422 'Do not use built-in or reserved HTML elements as component ' + 1423 'id: ' + name 1424 ); 1425 } 1426 } 1427 1428 /** 1429 * Ensure all props option syntax are normalized into the 1430 * Object-based format. 1431 */ 1432 function normalizeProps (options, vm) { 1433 var props = options.props; 1434 if (!props) { return } 1435 var res = {}; 1436 var i, val, name; 1437 if (Array.isArray(props)) { 1438 i = props.length; 1439 while (i--) { 1440 val = props[i]; 1441 if (typeof val === 'string') { 1442 name = camelize(val); 1443 res[name] = { type: null }; 1444 } else { 1445 warn('props must be strings when using array syntax.'); 1446 } 1447 } 1448 } else if (isPlainObject(props)) { 1449 for (var key in props) { 1450 val = props[key]; 1451 name = camelize(key); 1452 res[name] = isPlainObject(val) 1453 ? val 1454 : { type: val }; 1455 } 1456 } else { 1457 warn( 1458 "Invalid value for option \"props\": expected an Array or an Object, " + 1459 "but got " + (toRawType(props)) + ".", 1460 vm 1461 ); 1462 } 1463 options.props = res; 1464 } 1465 1466 /** 1467 * Normalize all injections into Object-based format 1468 */ 1469 function normalizeInject (options, vm) { 1470 var inject = options.inject; 1471 if (!inject) { return } 1472 var normalized = options.inject = {}; 1473 if (Array.isArray(inject)) { 1474 for (var i = 0; i < inject.length; i++) { 1475 normalized[inject[i]] = { from: inject[i] }; 1476 } 1477 } else if (isPlainObject(inject)) { 1478 for (var key in inject) { 1479 var val = inject[key]; 1480 normalized[key] = isPlainObject(val) 1481 ? extend({ from: key }, val) 1482 : { from: val }; 1483 } 1484 } else { 1485 warn( 1486 "Invalid value for option \"inject\": expected an Array or an Object, " + 1487 "but got " + (toRawType(inject)) + ".", 1488 vm 1489 ); 1490 } 1491 } 1492 1493 /** 1494 * Normalize raw function directives into object format. 1495 */ 1496 function normalizeDirectives (options) { 1497 var dirs = options.directives; 1498 if (dirs) { 1499 for (var key in dirs) { 1500 var def$$1 = dirs[key]; 1501 if (typeof def$$1 === 'function') { 1502 dirs[key] = { bind: def$$1, update: def$$1 }; 1503 } 1504 } 1505 } 1506 } 1507 1508 function assertObjectType (name, value, vm) { 1509 if (!isPlainObject(value)) { 1510 warn( 1511 "Invalid value for option \"" + name + "\": expected an Object, " + 1512 "but got " + (toRawType(value)) + ".", 1513 vm 1514 ); 1515 } 1516 } 1517 1518 /** 1519 * Merge two option objects into a new one. 1520 * Core utility used in both instantiation and inheritance. 1521 */ 1522 function mergeOptions ( 1523 parent, 1524 child, 1525 vm 1526 ) { 1527 { 1528 checkComponents(child); 1529 } 1530 1531 if (typeof child === 'function') { 1532 child = child.options; 1533 } 1534 1535 normalizeProps(child, vm); 1536 normalizeInject(child, vm); 1537 normalizeDirectives(child); 1538 1539 // Apply extends and mixins on the child options, 1540 // but only if it is a raw options object that isn't 1541 // the result of another mergeOptions call. 1542 // Only merged options has the _base property. 1543 if (!child._base) { 1544 if (child.extends) { 1545 parent = mergeOptions(parent, child.extends, vm); 1546 } 1547 if (child.mixins) { 1548 for (var i = 0, l = child.mixins.length; i < l; i++) { 1549 parent = mergeOptions(parent, child.mixins[i], vm); 1550 } 1551 } 1552 } 1553 1554 var options = {}; 1555 var key; 1556 for (key in parent) { 1557 mergeField(key); 1558 } 1559 for (key in child) { 1560 if (!hasOwn(parent, key)) { 1561 mergeField(key); 1562 } 1563 } 1564 function mergeField (key) { 1565 var strat = strats[key] || defaultStrat; 1566 options[key] = strat(parent[key], child[key], vm, key); 1567 } 1568 return options 1569 } 1570 1571 /** 1572 * Resolve an asset. 1573 * This function is used because child instances need access 1574 * to assets defined in its ancestor chain. 1575 */ 1576 function resolveAsset ( 1577 options, 1578 type, 1579 id, 1580 warnMissing 1581 ) { 1582 /* istanbul ignore if */ 1583 if (typeof id !== 'string') { 1584 return 1585 } 1586 var assets = options[type]; 1587 // check local registration variations first 1588 if (hasOwn(assets, id)) { return assets[id] } 1589 var camelizedId = camelize(id); 1590 if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } 1591 var PascalCaseId = capitalize(camelizedId); 1592 if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } 1593 // fallback to prototype chain 1594 var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; 1595 if (warnMissing && !res) { 1596 warn( 1597 'Failed to resolve ' + type.slice(0, -1) + ': ' + id, 1598 options 1599 ); 1600 } 1601 return res 1602 } 1603 1604 /* */ 1605 1606 1607 1608 function validateProp ( 1609 key, 1610 propOptions, 1611 propsData, 1612 vm 1613 ) { 1614 var prop = propOptions[key]; 1615 var absent = !hasOwn(propsData, key); 1616 var value = propsData[key]; 1617 // boolean casting 1618 var booleanIndex = getTypeIndex(Boolean, prop.type); 1619 if (booleanIndex > -1) { 1620 if (absent && !hasOwn(prop, 'default')) { 1621 value = false;
vendor: 7,832 bytes, lines 1622-1863
1622 } else if (value === '' || value === hyphenate(key)) { 1623 // only cast empty string / same name to boolean if 1624 // boolean has higher priority 1625 var stringIndex = getTypeIndex(String, prop.type); 1626 if (stringIndex < 0 || booleanIndex < stringIndex) { 1627 value = true; 1628 } 1629 } 1630 } 1631 // check default value 1632 if (value === undefined) { 1633 value = getPropDefaultValue(vm, prop, key); 1634 // since the default value is a fresh copy, 1635 // make sure to observe it. 1636 var prevShouldObserve = shouldObserve; 1637 toggleObserving(true); 1638 observe(value); 1639 toggleObserving(prevShouldObserve); 1640 } 1641 { 1642 assertProp(prop, key, value, vm, absent); 1643 } 1644 return value 1645 } 1646 1647 /** 1648 * Get the default value of a prop. 1649 */ 1650 function getPropDefaultValue (vm, prop, key) { 1651 // no default, return undefined 1652 if (!hasOwn(prop, 'default')) { 1653 return undefined 1654 } 1655 var def = prop.default; 1656 // warn against non-factory defaults for Object & Array 1657 if (isObject(def)) { 1658 warn( 1659 'Invalid default value for prop "' + key + '": ' + 1660 'Props with type Object/Array must use a factory function ' + 1661 'to return the default value.', 1662 vm 1663 ); 1664 } 1665 // the raw prop value was also undefined from previous render, 1666 // return previous default value to avoid unnecessary watcher trigger 1667 if (vm && vm.$options.propsData && 1668 vm.$options.propsData[key] === undefined && 1669 vm._props[key] !== undefined 1670 ) { 1671 return vm._props[key] 1672 } 1673 // call factory function for non-Function types 1674 // a value is Function if its prototype is function even across different execution context 1675 return typeof def === 'function' && getType(prop.type) !== 'Function' 1676 ? def.call(vm) 1677 : def 1678 } 1679 1680 /** 1681 * Assert whether a prop is valid. 1682 */ 1683 function assertProp ( 1684 prop, 1685 name, 1686 value, 1687 vm, 1688 absent 1689 ) { 1690 if (prop.required && absent) { 1691 warn( 1692 'Missing required prop: "' + name + '"', 1693 vm 1694 ); 1695 return 1696 } 1697 if (value == null && !prop.required) { 1698 return 1699 } 1700 var type = prop.type; 1701 var valid = !type || type === true; 1702 var expectedTypes = []; 1703 if (type) { 1704 if (!Array.isArray(type)) { 1705 type = [type]; 1706 } 1707 for (var i = 0; i < type.length && !valid; i++) { 1708 var assertedType = assertType(value, type[i]); 1709 expectedTypes.push(assertedType.expectedType || ''); 1710 valid = assertedType.valid; 1711 } 1712 } 1713 1714 if (!valid) { 1715 warn( 1716 getInvalidTypeMessage(name, value, expectedTypes), 1717 vm 1718 ); 1719 return 1720 } 1721 var validator = prop.validator; 1722 if (validator) { 1723 if (!validator(value)) { 1724 warn( 1725 'Invalid prop: custom validator check failed for prop "' + name + '".', 1726 vm 1727 ); 1728 } 1729 } 1730 } 1731 1732 var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/; 1733 1734 function assertType (value, type) { 1735 var valid; 1736 var expectedType = getType(type); 1737 if (simpleCheckRE.test(expectedType)) { 1738 var t = typeof value; 1739 valid = t === expectedType.toLowerCase(); 1740 // for primitive wrapper objects 1741 if (!valid && t === 'object') { 1742 valid = value instanceof type; 1743 } 1744 } else if (expectedType === 'Object') { 1745 valid = isPlainObject(value); 1746 } else if (expectedType === 'Array') { 1747 valid = Array.isArray(value); 1748 } else { 1749 valid = value instanceof type; 1750 } 1751 return { 1752 valid: valid, 1753 expectedType: expectedType 1754 } 1755 } 1756 1757 /** 1758 * Use function string name to check built-in types, 1759 * because a simple equality check will fail when running 1760 * across different vms / iframes. 1761 */ 1762 function getType (fn) { 1763 var match = fn && fn.toString().match(/^\s*function (\w+)/); 1764 return match ? match[1] : '' 1765 } 1766 1767 function isSameType (a, b) { 1768 return getType(a) === getType(b) 1769 } 1770 1771 function getTypeIndex (type, expectedTypes) { 1772 if (!Array.isArray(expectedTypes)) { 1773 return isSameType(expectedTypes, type) ? 0 : -1 1774 } 1775 for (var i = 0, len = expectedTypes.length; i < len; i++) { 1776 if (isSameType(expectedTypes[i], type)) { 1777 return i 1778 } 1779 } 1780 return -1 1781 } 1782 1783 function getInvalidTypeMessage (name, value, expectedTypes) { 1784 var message = "Invalid prop: type check failed for prop \"" + name + "\"." + 1785 " Expected " + (expectedTypes.map(capitalize).join(', ')); 1786 var expectedType = expectedTypes[0]; 1787 var receivedType = toRawType(value); 1788 var expectedValue = styleValue(value, expectedType); 1789 var receivedValue = styleValue(value, receivedType); 1790 // check if we need to specify expected value 1791 if (expectedTypes.length === 1 && 1792 isExplicable(expectedType) && 1793 !isBoolean(expectedType, receivedType)) { 1794 message += " with value " + expectedValue; 1795 } 1796 message += ", got " + receivedType + " "; 1797 // check if we need to specify received value 1798 if (isExplicable(receivedType)) { 1799 message += "with value " + receivedValue + "."; 1800 } 1801 return message 1802 } 1803 1804 function styleValue (value, type) { 1805 if (type === 'String') { 1806 return ("\"" + value + "\"") 1807 } else if (type === 'Number') { 1808 return ("" + (Number(value))) 1809 } else { 1810 return ("" + value) 1811 } 1812 } 1813 1814 function isExplicable (value) { 1815 var explicitTypes = ['string', 'number', 'boolean']; 1816 return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; }) 1817 } 1818 1819 function isBoolean () { 1820 var args = [], len = arguments.length; 1821 while ( len-- ) args[ len ] = arguments[ len ]; 1822 1823 return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; }) 1824 } 1825 1826 /* */ 1827 1828 function handleError (err, vm, info) { 1829 // Deactivate deps tracking while processing error handler to avoid possible infinite rendering. 1830 // See: https://github.com/vuejs/vuex/issues/1505 1831 pushTarget(); 1832 try { 1833 if (vm) { 1834 var cur = vm; 1835 while ((cur = cur.$parent)) { 1836 var hooks = cur.$options.errorCaptured; 1837 if (hooks) { 1838 for (var i = 0; i < hooks.length; i++) { 1839 try { 1840 var capture = hooks[i].call(cur, err, vm, info) === false; 1841 if (capture) { return } 1842 } catch (e) { 1843 globalHandleError(e, cur, 'errorCaptured hook'); 1844 } 1845 } 1846 } 1847 } 1848 } 1849 globalHandleError(err, vm, info); 1850 } finally { 1851 popTarget(); 1852 } 1853 } 1854 1855 function invokeWithErrorHandling ( 1856 handler, 1857 context, 1858 args, 1859 vm, 1860 info 1861 ) { 1862 var res; 1863 try {
vendor: 4,212 bytes, lines 1864-1965
1864 res = args ? handler.apply(context, args) : handler.call(context); 1865 if (res && !res._isVue && isPromise(res) && !res._handled) { 1866 res.catch(function (e) { return handleError(e, vm, info + " (Promise/async)"); }); 1867 // issue #9511 1868 // avoid catch triggering multiple times when nested calls 1869 res._handled = true; 1870 } 1871 } catch (e) { 1872 handleError(e, vm, info); 1873 } 1874 return res 1875 } 1876 1877 function globalHandleError (err, vm, info) { 1878 if (config.errorHandler) { 1879 try { 1880 return config.errorHandler.call(null, err, vm, info) 1881 } catch (e) { 1882 // if the user intentionally throws the original error in the handler, 1883 // do not log it twice 1884 if (e !== err) { 1885 logError(e, null, 'config.errorHandler'); 1886 } 1887 } 1888 } 1889 logError(err, vm, info); 1890 } 1891 1892 function logError (err, vm, info) { 1893 { 1894 warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm); 1895 } 1896 /* istanbul ignore else */ 1897 if ((inBrowser || inWeex) && typeof console !== 'undefined') { 1898 console.error(err); 1899 } else { 1900 throw err 1901 } 1902 } 1903 1904 /* */ 1905 1906 var isUsingMicroTask = false; 1907 1908 var callbacks = []; 1909 var pending = false; 1910 1911 function flushCallbacks () { 1912 pending = false; 1913 var copies = callbacks.slice(0); 1914 callbacks.length = 0; 1915 for (var i = 0; i < copies.length; i++) { 1916 copies[i](); 1917 } 1918 } 1919 1920 // Here we have async deferring wrappers using microtasks. 1921 // In 2.5 we used (macro) tasks (in combination with microtasks). 1922 // However, it has subtle problems when state is changed right before repaint 1923 // (e.g. #6813, out-in transitions). 1924 // Also, using (macro) tasks in event handler would cause some weird behaviors 1925 // that cannot be circumvented (e.g. #7109, #7153, #7546, #7834, #8109). 1926 // So we now use microtasks everywhere, again. 1927 // A major drawback of this tradeoff is that there are some scenarios 1928 // where microtasks have too high a priority and fire in between supposedly 1929 // sequential events (e.g. #4521, #6690, which have workarounds) 1930 // or even between bubbling of the same event (#6566). 1931 var timerFunc; 1932 1933 // The nextTick behavior leverages the microtask queue, which can be accessed 1934 // via either native Promise.then or MutationObserver. 1935 // MutationObserver has wider support, however it is seriously bugged in 1936 // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It 1937 // completely stops working after triggering a few times... so, if native 1938 // Promise is available, we will use it: 1939 /* istanbul ignore next, $flow-disable-line */ 1940 if (typeof Promise !== 'undefined' && isNative(Promise)) { 1941 var p = Promise.resolve(); 1942 timerFunc = function () { 1943 p.then(flushCallbacks); 1944 // In problematic UIWebViews, Promise.then doesn't completely break, but 1945 // it can get stuck in a weird state where callbacks are pushed into the 1946 // microtask queue but the queue isn't being flushed, until the browser 1947 // needs to do some other work, e.g. handle a timer. Therefore we can 1948 // "force" the microtask queue to be flushed by adding an empty timer. 1949 if (isIOS) { setTimeout(noop); } 1950 }; 1951 isUsingMicroTask = true; 1952 } else if (!isIE && typeof MutationObserver !== 'undefined' && ( 1953 isNative(MutationObserver) || 1954 // PhantomJS and iOS 7.x 1955 MutationObserver.toString() === '[object MutationObserverConstructor]' 1956 )) { 1957 // Use MutationObserver where native Promise is not available, 1958 // e.g. PhantomJS, iOS7, Android 4.4 1959 // (#6466 MutationObserver is unreliable in IE11) 1960 var counter = 1; 1961 var observer = new MutationObserver(flushCallbacks); 1962 var textNode = document.createTextNode(String(counter)); 1963 observer.observe(textNode, { 1964 characterData: true 1965 });
1966 timerFunc = function () { 1967 counter = (counter + 1) % 2; 1968 textNode.data = String(counter); 1969 }; 1970 isUsingMicroTask = true; 1971 } else if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) { 1972 // Fallback to setImmediate. 1973 // Techinically it leverages the (macro) task queue, 1974 // but it is still a better choice than setTimeout. 1975 timerFunc = function () { 1976 setImmediate(flushCallbacks); 1977 }; 1978 } else { 1979 // Fallback to setTimeout. 1980 timerFunc = function () { 1981 setTimeout(flushCallbacks, 0); 1982 }; 1983 } 1984 1985 function nextTick (cb, ctx) { 1986 var _resolve; 1987 callbacks.push(function () { 1988 if (cb) { 1989 try { 1990 cb.call(ctx); 1991 } catch (e) { 1992 handleError(e, ctx, 'nextTick'); 1993 } 1994 } else if (_resolve) { 1995 _resolve(ctx); 1996 } 1997 }); 1998 if (!pending) { 1999 pending = true; 2000 timerFunc(); 2001 } 2002 // $flow-disable-line 2003 if (!cb && typeof Promise !== 'undefined') { 2004 return new Promise(function (resolve) { 2005 _resolve = resolve; 2006 }) 2007 } 2008 } 2009 2010 /* */ 2011 2012 var mark; 2013 var measure; 2014 2015 { 2016 var perf = inBrowser && window.performance; 2017 /* istanbul ignore if */ 2018 if ( 2019 perf && 2020 perf.mark && 2021 perf.measure && 2022 perf.clearMarks && 2023 perf.clearMeasures 2024 ) { 2025 mark = function (tag) { return perf.mark(tag); }; 2026 measure = function (name, startTag, endTag) { 2027 perf.measure(name, startTag, endTag); 2028 perf.clearMarks(startTag); 2029 perf.clearMarks(endTag); 2030 // perf.clearMeasures(name) 2031 }; 2032 } 2033 } 2034 2035 /* not type checking this file because flow doesn't play well with Proxy */ 2036 2037 var initProxy; 2038 2039 { 2040 var allowedGlobals = makeMap( 2041 'Infinity,undefined,NaN,isFinite,isNaN,' + 2042 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 2043 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 2044 'require' // for Webpack/Browserify 2045 ); 2046 2047 var warnNonPresent = function (target, key) { 2048 warn( 2049 "Property or method \"" + key + "\" is not defined on the instance but " + 2050 'referenced during render. Make sure that this property is reactive, ' + 2051 'either in the data option, or for class-based components, by ' + 2052 'initializing the property. ' + 2053 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', 2054 target 2055 ); 2056 }; 2057 2058 var warnReservedPrefix = function (target, key) { 2059 warn( 2060 "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " + 2061 'properties starting with "$" or "_" are not proxied in the Vue instance to ' + 2062 'prevent conflicts with Vue internals' + 2063 'See: https://vuejs.org/v2/api/#data', 2064 target 2065 ); 2066 }; 2067 2068 var hasProxy = 2069 typeof Proxy !== 'undefined' && isNative(Proxy); 2070 2071 if (hasProxy) { 2072 var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact'); 2073 config.keyCodes = new Proxy(config.keyCodes, { 2074 set: function set (target, key, value) { 2075 if (isBuiltInModifier(key)) { 2076 warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key)); 2077 return false 2078 } else { 2079 target[key] = value; 2080 return true 2081 } 2082 } 2083 }); 2084 } 2085 2086 var hasHandler = { 2087 has: function has (target, key) { 2088 var has = key in target; 2089 var isAllowed = allowedGlobals(key) || 2090 (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data)); 2091 if (!has && !isAllowed) { 2092 if (key in target.$data) { warnReservedPrefix(target, key); } 2093 else { warnNonPresent(target, key); } 2094 } 2095 return has || !isAllowed 2096 } 2097 }; 2098 2099 var getHandler = { 2100 get: function get (target, key) { 2101 if (typeof key === 'string' && !(key in target)) { 2102 if (key in target.$data) { warnReservedPrefix(target, key); } 2103 else { warnNonPresent(target, key); } 2104 } 2105 return target[key] 2106 } 2107 }; 2108 2109 initProxy = function initProxy (vm) { 2110 if (hasProxy) { 2111 // determine which proxy handler to use 2112 var options = vm.$options; 2113 var handlers = options.render && options.render._withStripped 2114 ? getHandler 2115 : hasHandler; 2116 vm._renderProxy = new Proxy(vm, handlers); 2117 } else { 2118 vm._renderProxy = vm; 2119 } 2120 }; 2121 } 2122 2123 /* */ 2124 2125 var seenObjects = new _Set(); 2126 2127 /** 2128 * Recursively traverse an object to evoke all converted 2129 * getters, so that every nested property inside the object 2130 * is collected as a "deep" dependency. 2131 */ 2132 function traverse (val) { 2133 _traverse(val, seenObjects); 2134 seenObjects.clear(); 2135 } 2136 2137 function _traverse (val, seen) { 2138 var i, keys; 2139 var isA = Array.isArray(val); 2140 if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) { 2141 return 2142 } 2143 if (val.__ob__) { 2144 var depId = val.__ob__.dep.id; 2145 if (seen.has(depId)) { 2146 return 2147 } 2148 seen.add(depId); 2149 } 2150 if (isA) { 2151 i = val.length; 2152 while (i--) { _traverse(val[i], seen); } 2153 } else { 2154 keys = Object.keys(val); 2155 i = keys.length; 2156 while (i--) { _traverse(val[keys[i]], seen); } 2157 } 2158 } 2159 2160 /* */ 2161 2162 var normalizeEvent = cached(function (name) { 2163 var passive = name.charAt(0) === '&'; 2164 name = passive ? name.slice(1) : name; 2165 var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first 2166 name = once$$1 ? name.slice(1) : name; 2167 var capture = name.charAt(0) === '!'; 2168 name = capture ? name.slice(1) : name; 2169 return { 2170 name: name, 2171 once: once$$1, 2172 capture: capture, 2173 passive: passive 2174 } 2175 }); 2176 2177 function createFnInvoker (fns, vm) { 2178 function invoker () { 2179 var arguments$1 = arguments; 2180 2181 var fns = invoker.fns; 2182 if (Array.isArray(fns)) { 2183 var cloned = fns.slice(); 2184 for (var i = 0; i < cloned.length; i++) { 2185 invokeWithErrorHandling(cloned[i], null, arguments$1, vm, "v-on handler"); 2186 } 2187 } else { 2188 // return handler return value for single handlers 2189 return invokeWithErrorHandling(fns, null, arguments, vm, "v-on handler") 2190 } 2191 } 2192 invoker.fns = fns; 2193 return invoker 2194 } 2195 2196 function updateListeners ( 2197 on, 2198 oldOn, 2199 add, 2200 remove$$1, 2201 createOnceHandler, 2202 vm 2203 ) { 2204 var name, def$$1, cur, old, event; 2205 for (name in on) { 2206 def$$1 = cur = on[name]; 2207 old = oldOn[name]; 2208 event = normalizeEvent(name); 2209 if (isUndef(cur)) { 2210 warn( 2211 "Invalid handler for event \"" + (event.name) + "\": got " + String(cur), 2212 vm 2213 ); 2214 } else if (isUndef(old)) { 2215 if (isUndef(cur.fns)) { 2216 cur = on[name] = createFnInvoker(cur, vm); 2217 } 2218 if (isTrue(event.once)) { 2219 cur = on[name] = createOnceHandler(event.name, cur, event.capture); 2220 } 2221 add(event.name, cur, event.capture, event.passive, event.params); 2222 } else if (cur !== old) { 2223 old.fns = cur; 2224 on[name] = old; 2225 } 2226 } 2227 for (name in oldOn) { 2228 if (isUndef(on[name])) { 2229 event = normalizeEvent(name); 2230 remove$$1(event.name, oldOn[name], event.capture); 2231 } 2232 } 2233 } 2234 2235 /* */ 2236 2237 function mergeVNodeHook (def, hookKey, hook) { 2238 if (def instanceof VNode) { 2239 def = def.data.hook || (def.data.hook = {}); 2240 } 2241 var invoker; 2242 var oldHook = def[hookKey]; 2243 2244 function wrappedHook () { 2245 hook.apply(this, arguments); 2246 // important: remove merged hook to ensure it's called only once 2247 // and prevent memory leak 2248 remove(invoker.fns, wrappedHook); 2249 } 2250 2251 if (isUndef(oldHook)) { 2252 // no existing hook 2253 invoker = createFnInvoker([wrappedHook]); 2254 } else { 2255 /* istanbul ignore if */ 2256 if (isDef(oldHook.fns) && isTrue(oldHook.merged)) { 2257 // already a merged invoker 2258 invoker = oldHook; 2259 invoker.fns.push(wrappedHook); 2260 } else { 2261 // existing plain hook 2262 invoker = createFnInvoker([oldHook, wrappedHook]); 2263 } 2264 } 2265 2266 invoker.merged = true; 2267 def[hookKey] = invoker; 2268 } 2269 2270 /* */ 2271 2272 function extractPropsFromVNodeData ( 2273 data, 2274 Ctor, 2275 tag 2276 ) { 2277 // we are only extracting raw values here. 2278 // validation and default values are handled in the child 2279 // component itself. 2280 var propOptions = Ctor.options.props; 2281 if (isUndef(propOptions)) { 2282 return 2283 } 2284 var res = {}; 2285 var attrs = data.attrs; 2286 var props = data.props; 2287 if (isDef(attrs) || isDef(props)) { 2288 for (var key in propOptions) { 2289 var altKey = hyphenate(key); 2290 { 2291 var keyInLowerCase = key.toLowerCase(); 2292 if ( 2293 key !== keyInLowerCase && 2294 attrs && hasOwn(attrs, keyInLowerCase) 2295 ) { 2296 tip( 2297 "Prop \"" + keyInLowerCase + "\" is passed to component " + 2298 (formatComponentName(tag || Ctor)) + ", but the declared prop name is" + 2299 " \"" + key + "\". " + 2300 "Note that HTML attributes are case-insensitive and camelCased " + 2301 "props need to use their kebab-case equivalents when using in-DOM " + 2302 "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"." 2303 ); 2304 } 2305 } 2306 checkProp(res, props, key, altKey, true) || 2307 checkProp(res, attrs, key, altKey, false); 2308 } 2309 } 2310 return res 2311 } 2312 2313 function checkProp ( 2314 res, 2315 hash, 2316 key, 2317 altKey, 2318 preserve 2319 ) {
vendor: 16,496 bytes, lines 2320-2808
2320 if (isDef(hash)) { 2321 if (hasOwn(hash, key)) { 2322 res[key] = hash[key]; 2323 if (!preserve) { 2324 delete hash[key]; 2325 } 2326 return true 2327 } else if (hasOwn(hash, altKey)) { 2328 res[key] = hash[altKey]; 2329 if (!preserve) { 2330 delete hash[altKey]; 2331 } 2332 return true 2333 } 2334 } 2335 return false 2336 } 2337 2338 /* */ 2339 2340 // The template compiler attempts to minimize the need for normalization by 2341 // statically analyzing the template at compile time. 2342 // 2343 // For plain HTML markup, normalization can be completely skipped because the 2344 // generated render function is guaranteed to return Array<VNode>. There are 2345 // two cases where extra normalization is needed: 2346 2347 // 1. When the children contains components - because a functional component 2348 // may return an Array instead of a single root. In this case, just a simple 2349 // normalization is needed - if any child is an Array, we flatten the whole 2350 // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep 2351 // because functional components already normalize their own children. 2352 function simpleNormalizeChildren (children) { 2353 for (var i = 0; i < children.length; i++) { 2354 if (Array.isArray(children[i])) { 2355 return Array.prototype.concat.apply([], children) 2356 } 2357 } 2358 return children 2359 } 2360 2361 // 2. When the children contains constructs that always generated nested Arrays, 2362 // e.g. <template>, <slot>, v-for, or when the children is provided by user 2363 // with hand-written render functions / JSX. In such cases a full normalization 2364 // is needed to cater to all possible types of children values. 2365 function normalizeChildren (children) { 2366 return isPrimitive(children) 2367 ? [createTextVNode(children)] 2368 : Array.isArray(children) 2369 ? normalizeArrayChildren(children) 2370 : undefined 2371 } 2372 2373 function isTextNode (node) { 2374 return isDef(node) && isDef(node.text) && isFalse(node.isComment) 2375 } 2376 2377 function normalizeArrayChildren (children, nestedIndex) { 2378 var res = []; 2379 var i, c, lastIndex, last; 2380 for (i = 0; i < children.length; i++) { 2381 c = children[i]; 2382 if (isUndef(c) || typeof c === 'boolean') { continue } 2383 lastIndex = res.length - 1; 2384 last = res[lastIndex]; 2385 // nested 2386 if (Array.isArray(c)) { 2387 if (c.length > 0) { 2388 c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)); 2389 // merge adjacent text nodes 2390 if (isTextNode(c[0]) && isTextNode(last)) { 2391 res[lastIndex] = createTextVNode(last.text + (c[0]).text); 2392 c.shift(); 2393 } 2394 res.push.apply(res, c); 2395 } 2396 } else if (isPrimitive(c)) { 2397 if (isTextNode(last)) { 2398 // merge adjacent text nodes 2399 // this is necessary for SSR hydration because text nodes are 2400 // essentially merged when rendered to HTML strings 2401 res[lastIndex] = createTextVNode(last.text + c); 2402 } else if (c !== '') { 2403 // convert primitive to vnode 2404 res.push(createTextVNode(c)); 2405 } 2406 } else { 2407 if (isTextNode(c) && isTextNode(last)) { 2408 // merge adjacent text nodes 2409 res[lastIndex] = createTextVNode(last.text + c.text); 2410 } else { 2411 // default key for nested array children (likely generated by v-for) 2412 if (isTrue(children._isVList) && 2413 isDef(c.tag) && 2414 isUndef(c.key) && 2415 isDef(nestedIndex)) { 2416 c.key = "__vlist" + nestedIndex + "_" + i + "__"; 2417 } 2418 res.push(c); 2419 } 2420 } 2421 } 2422 return res 2423 } 2424 2425 /* */ 2426 2427 function initProvide (vm) { 2428 var provide = vm.$options.provide; 2429 if (provide) { 2430 vm._provided = typeof provide === 'function' 2431 ? provide.call(vm) 2432 : provide; 2433 } 2434 } 2435 2436 function initInjections (vm) { 2437 var result = resolveInject(vm.$options.inject, vm); 2438 if (result) { 2439 toggleObserving(false); 2440 Object.keys(result).forEach(function (key) { 2441 /* istanbul ignore else */ 2442 { 2443 defineReactive$$1(vm, key, result[key], function () { 2444 warn( 2445 "Avoid mutating an injected value directly since the changes will be " + 2446 "overwritten whenever the provided component re-renders. " + 2447 "injection being mutated: \"" + key + "\"", 2448 vm 2449 ); 2450 }); 2451 } 2452 }); 2453 toggleObserving(true); 2454 } 2455 } 2456 2457 function resolveInject (inject, vm) { 2458 if (inject) { 2459 // inject is :any because flow is not smart enough to figure out cached 2460 var result = Object.create(null); 2461 var keys = hasSymbol 2462 ? Reflect.ownKeys(inject) 2463 : Object.keys(inject); 2464 2465 for (var i = 0; i < keys.length; i++) { 2466 var key = keys[i]; 2467 // #6574 in case the inject object is observed... 2468 if (key === '__ob__') { continue } 2469 var provideKey = inject[key].from; 2470 var source = vm; 2471 while (source) { 2472 if (source._provided && hasOwn(source._provided, provideKey)) { 2473 result[key] = source._provided[provideKey]; 2474 break 2475 } 2476 source = source.$parent; 2477 } 2478 if (!source) { 2479 if ('default' in inject[key]) { 2480 var provideDefault = inject[key].default; 2481 result[key] = typeof provideDefault === 'function' 2482 ? provideDefault.call(vm) 2483 : provideDefault; 2484 } else { 2485 warn(("Injection \"" + key + "\" not found"), vm); 2486 } 2487 } 2488 } 2489 return result 2490 } 2491 } 2492 2493 /* */ 2494 2495 2496 2497 /** 2498 * Runtime helper for resolving raw children VNodes into a slot object. 2499 */ 2500 function resolveSlots ( 2501 children, 2502 context 2503 ) { 2504 if (!children || !children.length) { 2505 return {} 2506 } 2507 var slots = {}; 2508 for (var i = 0, l = children.length; i < l; i++) { 2509 var child = children[i]; 2510 var data = child.data; 2511 // remove slot attribute if the node is resolved as a Vue slot node 2512 if (data && data.attrs && data.attrs.slot) { 2513 delete data.attrs.slot; 2514 } 2515 // named slots should only be respected if the vnode was rendered in the 2516 // same context. 2517 if ((child.context === context || child.fnContext === context) && 2518 data && data.slot != null 2519 ) { 2520 var name = data.slot; 2521 var slot = (slots[name] || (slots[name] = [])); 2522 if (child.tag === 'template') { 2523 slot.push.apply(slot, child.children || []); 2524 } else { 2525 slot.push(child); 2526 } 2527 } else { 2528 (slots.default || (slots.default = [])).push(child); 2529 } 2530 } 2531 // ignore slots that contains only whitespace 2532 for (var name$1 in slots) { 2533 if (slots[name$1].every(isWhitespace)) { 2534 delete slots[name$1]; 2535 } 2536 } 2537 return slots 2538 } 2539 2540 function isWhitespace (node) { 2541 return (node.isComment && !node.asyncFactory) || node.text === ' ' 2542 } 2543 2544 /* */ 2545 2546 function normalizeScopedSlots ( 2547 slots, 2548 normalSlots, 2549 prevSlots 2550 ) { 2551 var res; 2552 var hasNormalSlots = Object.keys(normalSlots).length > 0; 2553 var isStable = slots ? !!slots.$stable : !hasNormalSlots; 2554 var key = slots && slots.$key; 2555 if (!slots) { 2556 res = {}; 2557 } else if (slots._normalized) { 2558 // fast path 1: child component re-render only, parent did not change 2559 return slots._normalized 2560 } else if ( 2561 isStable && 2562 prevSlots && 2563 prevSlots !== emptyObject && 2564 key === prevSlots.$key && 2565 !hasNormalSlots && 2566 !prevSlots.$hasNormal 2567 ) { 2568 // fast path 2: stable scoped slots w/ no normal slots to proxy, 2569 // only need to normalize once 2570 return prevSlots 2571 } else { 2572 res = {}; 2573 for (var key$1 in slots) { 2574 if (slots[key$1] && key$1[0] !== '$') { 2575 res[key$1] = normalizeScopedSlot(normalSlots, key$1, slots[key$1]); 2576 } 2577 } 2578 } 2579 // expose normal slots on scopedSlots 2580 for (var key$2 in normalSlots) { 2581 if (!(key$2 in res)) { 2582 res[key$2] = proxyNormalSlot(normalSlots, key$2); 2583 } 2584 } 2585 // avoriaz seems to mock a non-extensible $scopedSlots object 2586 // and when that is passed down this would cause an error 2587 if (slots && Object.isExtensible(slots)) { 2588 (slots)._normalized = res; 2589 } 2590 def(res, '$stable', isStable); 2591 def(res, '$key', key); 2592 def(res, '$hasNormal', hasNormalSlots); 2593 return res 2594 } 2595 2596 function normalizeScopedSlot(normalSlots, key, fn) { 2597 var normalized = function () { 2598 var res = arguments.length ? fn.apply(null, arguments) : fn({}); 2599 res = res && typeof res === 'object' && !Array.isArray(res) 2600 ? [res] // single vnode 2601 : normalizeChildren(res); 2602 return res && ( 2603 res.length === 0 || 2604 (res.length === 1 && res[0].isComment) // #9658 2605 ) ? undefined 2606 : res 2607 }; 2608 // this is a slot using the new v-slot syntax without scope. although it is 2609 // compiled as a scoped slot, render fn users would expect it to be present 2610 // on this.$slots because the usage is semantically a normal slot. 2611 if (fn.proxy) { 2612 Object.defineProperty(normalSlots, key, { 2613 get: normalized, 2614 enumerable: true, 2615 configurable: true 2616 }); 2617 } 2618 return normalized 2619 } 2620 2621 function proxyNormalSlot(slots, key) { 2622 return function () { return slots[key]; } 2623 } 2624 2625 /* */ 2626 2627 /** 2628 * Runtime helper for rendering v-for lists. 2629 */ 2630 function renderList ( 2631 val, 2632 render 2633 ) { 2634 var ret, i, l, keys, key; 2635 if (Array.isArray(val) || typeof val === 'string') { 2636 ret = new Array(val.length); 2637 for (i = 0, l = val.length; i < l; i++) { 2638 ret[i] = render(val[i], i); 2639 } 2640 } else if (typeof val === 'number') { 2641 ret = new Array(val); 2642 for (i = 0; i < val; i++) { 2643 ret[i] = render(i + 1, i); 2644 } 2645 } else if (isObject(val)) { 2646 if (hasSymbol && val[Symbol.iterator]) { 2647 ret = []; 2648 var iterator = val[Symbol.iterator](); 2649 var result = iterator.next(); 2650 while (!result.done) { 2651 ret.push(render(result.value, ret.length)); 2652 result = iterator.next(); 2653 } 2654 } else { 2655 keys = Object.keys(val); 2656 ret = new Array(keys.length); 2657 for (i = 0, l = keys.length; i < l; i++) { 2658 key = keys[i]; 2659 ret[i] = render(val[key], key, i); 2660 } 2661 } 2662 } 2663 if (!isDef(ret)) { 2664 ret = []; 2665 } 2666 (ret)._isVList = true; 2667 return ret 2668 } 2669 2670 /* */ 2671 2672 /** 2673 * Runtime helper for rendering <slot> 2674 */ 2675 function renderSlot ( 2676 name, 2677 fallback, 2678 props, 2679 bindObject 2680 ) { 2681 var scopedSlotFn = this.$scopedSlots[name]; 2682 var nodes; 2683 if (scopedSlotFn) { // scoped slot 2684 props = props || {}; 2685 if (bindObject) { 2686 if (!isObject(bindObject)) { 2687 warn( 2688 'slot v-bind without argument expects an Object', 2689 this 2690 ); 2691 } 2692 props = extend(extend({}, bindObject), props); 2693 } 2694 nodes = scopedSlotFn(props) || fallback; 2695 } else { 2696 nodes = this.$slots[name] || fallback; 2697 } 2698 2699 var target = props && props.slot; 2700 if (target) { 2701 return this.$createElement('template', { slot: target }, nodes) 2702 } else { 2703 return nodes 2704 } 2705 } 2706 2707 /* */ 2708 2709 /** 2710 * Runtime helper for resolving filters 2711 */ 2712 function resolveFilter (id) { 2713 return resolveAsset(this.$options, 'filters', id, true) || identity 2714 } 2715 2716 /* */ 2717 2718 function isKeyNotMatch (expect, actual) { 2719 if (Array.isArray(expect)) { 2720 return expect.indexOf(actual) === -1 2721 } else { 2722 return expect !== actual 2723 } 2724 } 2725 2726 /** 2727 * Runtime helper for checking keyCodes from config. 2728 * exposed as Vue.prototype._k 2729 * passing in eventKeyName as last argument separately for backwards compat 2730 */ 2731 function checkKeyCodes ( 2732 eventKeyCode, 2733 key, 2734 builtInKeyCode, 2735 eventKeyName, 2736 builtInKeyName 2737 ) { 2738 var mappedKeyCode = config.keyCodes[key] || builtInKeyCode; 2739 if (builtInKeyName && eventKeyName && !config.keyCodes[key]) { 2740 return isKeyNotMatch(builtInKeyName, eventKeyName) 2741 } else if (mappedKeyCode) { 2742 return isKeyNotMatch(mappedKeyCode, eventKeyCode) 2743 } else if (eventKeyName) { 2744 return hyphenate(eventKeyName) !== key 2745 } 2746 } 2747 2748 /* */ 2749 2750 /** 2751 * Runtime helper for merging v-bind="object" into a VNode's data. 2752 */ 2753 function bindObjectProps ( 2754 data, 2755 tag, 2756 value, 2757 asProp, 2758 isSync 2759 ) { 2760 if (value) { 2761 if (!isObject(value)) { 2762 warn( 2763 'v-bind without argument expects an Object or Array value', 2764 this 2765 ); 2766 } else { 2767 if (Array.isArray(value)) { 2768 value = toObject(value); 2769 } 2770 var hash; 2771 var loop = function ( key ) { 2772 if ( 2773 key === 'class' || 2774 key === 'style' || 2775 isReservedAttribute(key) 2776 ) { 2777 hash = data; 2778 } else { 2779 var type = data.attrs && data.attrs.type; 2780 hash = asProp || config.mustUseProp(tag, type, key) 2781 ? data.domProps || (data.domProps = {}) 2782 : data.attrs || (data.attrs = {}); 2783 } 2784 var camelizedKey = camelize(key); 2785 var hyphenatedKey = hyphenate(key); 2786 if (!(camelizedKey in hash) && !(hyphenatedKey in hash)) { 2787 hash[key] = value[key]; 2788 2789 if (isSync) { 2790 var on = data.on || (data.on = {}); 2791 on[("update:" + key)] = function ($event) { 2792 value[key] = $event; 2793 }; 2794 } 2795 } 2796 }; 2797 2798 for (var key in value) loop( key ); 2799 } 2800 } 2801 return data 2802 } 2803 2804 /* */ 2805 2806 /** 2807 * Runtime helper for rendering static trees. 2808 */
vendor: 27,586 bytes, lines 2809-3625
2809 function renderStatic ( 2810 index, 2811 isInFor 2812 ) { 2813 var cached = this._staticTrees || (this._staticTrees = []); 2814 var tree = cached[index]; 2815 // if has already-rendered static tree and not inside v-for, 2816 // we can reuse the same tree. 2817 if (tree && !isInFor) { 2818 return tree 2819 } 2820 // otherwise, render a fresh tree. 2821 tree = cached[index] = this.$options.staticRenderFns[index].call( 2822 this._renderProxy, 2823 null, 2824 this // for render fns generated for functional component templates 2825 ); 2826 markStatic(tree, ("__static__" + index), false); 2827 return tree 2828 } 2829 2830 /** 2831 * Runtime helper for v-once. 2832 * Effectively it means marking the node as static with a unique key. 2833 */ 2834 function markOnce ( 2835 tree, 2836 index, 2837 key 2838 ) { 2839 markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true); 2840 return tree 2841 } 2842 2843 function markStatic ( 2844 tree, 2845 key, 2846 isOnce 2847 ) { 2848 if (Array.isArray(tree)) { 2849 for (var i = 0; i < tree.length; i++) { 2850 if (tree[i] && typeof tree[i] !== 'string') { 2851 markStaticNode(tree[i], (key + "_" + i), isOnce); 2852 } 2853 } 2854 } else { 2855 markStaticNode(tree, key, isOnce); 2856 } 2857 } 2858 2859 function markStaticNode (node, key, isOnce) { 2860 node.isStatic = true; 2861 node.key = key; 2862 node.isOnce = isOnce; 2863 } 2864 2865 /* */ 2866 2867 function bindObjectListeners (data, value) { 2868 if (value) { 2869 if (!isPlainObject(value)) { 2870 warn( 2871 'v-on without argument expects an Object value', 2872 this 2873 ); 2874 } else { 2875 var on = data.on = data.on ? extend({}, data.on) : {}; 2876 for (var key in value) { 2877 var existing = on[key]; 2878 var ours = value[key]; 2879 on[key] = existing ? [].concat(existing, ours) : ours; 2880 } 2881 } 2882 } 2883 return data 2884 } 2885 2886 /* */ 2887 2888 function resolveScopedSlots ( 2889 fns, // see flow/vnode 2890 res, 2891 // the following are added in 2.6 2892 hasDynamicKeys, 2893 contentHashKey 2894 ) { 2895 res = res || { $stable: !hasDynamicKeys }; 2896 for (var i = 0; i < fns.length; i++) { 2897 var slot = fns[i]; 2898 if (Array.isArray(slot)) { 2899 resolveScopedSlots(slot, res, hasDynamicKeys); 2900 } else if (slot) { 2901 // marker for reverse proxying v-slot without scope on this.$slots 2902 if (slot.proxy) { 2903 slot.fn.proxy = true; 2904 } 2905 res[slot.key] = slot.fn; 2906 } 2907 } 2908 if (contentHashKey) { 2909 (res).$key = contentHashKey; 2910 } 2911 return res 2912 } 2913 2914 /* */ 2915 2916 function bindDynamicKeys (baseObj, values) { 2917 for (var i = 0; i < values.length; i += 2) { 2918 var key = values[i]; 2919 if (typeof key === 'string' && key) { 2920 baseObj[values[i]] = values[i + 1]; 2921 } else if (key !== '' && key !== null) { 2922 // null is a speical value for explicitly removing a binding 2923 warn( 2924 ("Invalid value for dynamic directive argument (expected string or null): " + key), 2925 this 2926 ); 2927 } 2928 } 2929 return baseObj 2930 } 2931 2932 // helper to dynamically append modifier runtime markers to event names. 2933 // ensure only append when value is already string, otherwise it will be cast 2934 // to string and cause the type check to miss. 2935 function prependModifier (value, symbol) { 2936 return typeof value === 'string' ? symbol + value : value 2937 } 2938 2939 /* */ 2940 2941 function installRenderHelpers (target) { 2942 target._o = markOnce; 2943 target._n = toNumber; 2944 target._s = toString; 2945 target._l = renderList; 2946 target._t = renderSlot; 2947 target._q = looseEqual; 2948 target._i = looseIndexOf; 2949 target._m = renderStatic; 2950 target._f = resolveFilter; 2951 target._k = checkKeyCodes; 2952 target._b = bindObjectProps; 2953 target._v = createTextVNode; 2954 target._e = createEmptyVNode; 2955 target._u = resolveScopedSlots; 2956 target._g = bindObjectListeners; 2957 target._d = bindDynamicKeys; 2958 target._p = prependModifier; 2959 } 2960 2961 /* */ 2962 2963 function FunctionalRenderContext ( 2964 data, 2965 props, 2966 children, 2967 parent, 2968 Ctor 2969 ) { 2970 var this$1 = this; 2971 2972 var options = Ctor.options; 2973 // ensure the createElement function in functional components 2974 // gets a unique context - this is necessary for correct named slot check 2975 var contextVm; 2976 if (hasOwn(parent, '_uid')) { 2977 contextVm = Object.create(parent); 2978 // $flow-disable-line 2979 contextVm._original = parent; 2980 } else { 2981 // the context vm passed in is a functional context as well. 2982 // in this case we want to make sure we are able to get a hold to the 2983 // real context instance. 2984 contextVm = parent; 2985 // $flow-disable-line 2986 parent = parent._original; 2987 } 2988 var isCompiled = isTrue(options._compiled); 2989 var needNormalization = !isCompiled; 2990 2991 this.data = data; 2992 this.props = props; 2993 this.children = children; 2994 this.parent = parent; 2995 this.listeners = data.on || emptyObject; 2996 this.injections = resolveInject(options.inject, parent); 2997 this.slots = function () { 2998 if (!this$1.$slots) { 2999 normalizeScopedSlots( 3000 data.scopedSlots, 3001 this$1.$slots = resolveSlots(children, parent) 3002 ); 3003 } 3004 return this$1.$slots 3005 }; 3006 3007 Object.defineProperty(this, 'scopedSlots', ({ 3008 enumerable: true, 3009 get: function get () { 3010 return normalizeScopedSlots(data.scopedSlots, this.slots()) 3011 } 3012 })); 3013 3014 // support for compiled functional template 3015 if (isCompiled) { 3016 // exposing $options for renderStatic() 3017 this.$options = options; 3018 // pre-resolve slots for renderSlot() 3019 this.$slots = this.slots(); 3020 this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots); 3021 } 3022 3023 if (options._scopeId) { 3024 this._c = function (a, b, c, d) { 3025 var vnode = createElement(contextVm, a, b, c, d, needNormalization); 3026 if (vnode && !Array.isArray(vnode)) { 3027 vnode.fnScopeId = options._scopeId; 3028 vnode.fnContext = parent; 3029 } 3030 return vnode 3031 }; 3032 } else { 3033 this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); }; 3034 } 3035 } 3036 3037 installRenderHelpers(FunctionalRenderContext.prototype); 3038 3039 function createFunctionalComponent ( 3040 Ctor, 3041 propsData, 3042 data, 3043 contextVm, 3044 children 3045 ) { 3046 var options = Ctor.options; 3047 var props = {}; 3048 var propOptions = options.props; 3049 if (isDef(propOptions)) { 3050 for (var key in propOptions) { 3051 props[key] = validateProp(key, propOptions, propsData || emptyObject); 3052 } 3053 } else { 3054 if (isDef(data.attrs)) { mergeProps(props, data.attrs); } 3055 if (isDef(data.props)) { mergeProps(props, data.props); } 3056 } 3057 3058 var renderContext = new FunctionalRenderContext( 3059 data, 3060 props, 3061 children, 3062 contextVm, 3063 Ctor 3064 ); 3065 3066 var vnode = options.render.call(null, renderContext._c, renderContext); 3067 3068 if (vnode instanceof VNode) { 3069 return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext) 3070 } else if (Array.isArray(vnode)) { 3071 var vnodes = normalizeChildren(vnode) || []; 3072 var res = new Array(vnodes.length); 3073 for (var i = 0; i < vnodes.length; i++) { 3074 res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext); 3075 } 3076 return res 3077 } 3078 } 3079 3080 function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) { 3081 // #7817 clone node before setting fnContext, otherwise if the node is reused 3082 // (e.g. it was from a cached normal slot) the fnContext causes named slots 3083 // that should not be matched to match. 3084 var clone = cloneVNode(vnode); 3085 clone.fnContext = contextVm; 3086 clone.fnOptions = options; 3087 { 3088 (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext; 3089 } 3090 if (data.slot) { 3091 (clone.data || (clone.data = {})).slot = data.slot; 3092 } 3093 return clone 3094 } 3095 3096 function mergeProps (to, from) { 3097 for (var key in from) { 3098 to[camelize(key)] = from[key]; 3099 } 3100 } 3101 3102 /* */ 3103 3104 /* */ 3105 3106 /* */ 3107 3108 /* */ 3109 3110 // inline hooks to be invoked on component VNodes during patch 3111 var componentVNodeHooks = { 3112 init: function init (vnode, hydrating) { 3113 if ( 3114 vnode.componentInstance && 3115 !vnode.componentInstance._isDestroyed && 3116 vnode.data.keepAlive 3117 ) { 3118 // kept-alive components, treat as a patch 3119 var mountedNode = vnode; // work around flow 3120 componentVNodeHooks.prepatch(mountedNode, mountedNode); 3121 } else { 3122 var child = vnode.componentInstance = createComponentInstanceForVnode( 3123 vnode, 3124 activeInstance 3125 ); 3126 child.$mount(hydrating ? vnode.elm : undefined, hydrating); 3127 } 3128 }, 3129 3130 prepatch: function prepatch (oldVnode, vnode) { 3131 var options = vnode.componentOptions; 3132 var child = vnode.componentInstance = oldVnode.componentInstance; 3133 updateChildComponent( 3134 child, 3135 options.propsData, // updated props 3136 options.listeners, // updated listeners 3137 vnode, // new parent vnode 3138 options.children // new children 3139 ); 3140 }, 3141 3142 insert: function insert (vnode) { 3143 var context = vnode.context; 3144 var componentInstance = vnode.componentInstance; 3145 if (!componentInstance._isMounted) { 3146 componentInstance._isMounted = true; 3147 callHook(componentInstance, 'mounted'); 3148 } 3149 if (vnode.data.keepAlive) { 3150 if (context._isMounted) { 3151 // vue-router#1212 3152 // During updates, a kept-alive component's child components may 3153 // change, so directly walking the tree here may call activated hooks 3154 // on incorrect children. Instead we push them into a queue which will 3155 // be processed after the whole patch process ended. 3156 queueActivatedComponent(componentInstance); 3157 } else { 3158 activateChildComponent(componentInstance, true /* direct */); 3159 } 3160 } 3161 }, 3162 3163 destroy: function destroy (vnode) { 3164 var componentInstance = vnode.componentInstance; 3165 if (!componentInstance._isDestroyed) { 3166 if (!vnode.data.keepAlive) { 3167 componentInstance.$destroy(); 3168 } else { 3169 deactivateChildComponent(componentInstance, true /* direct */); 3170 } 3171 } 3172 } 3173 }; 3174 3175 var hooksToMerge = Object.keys(componentVNodeHooks); 3176 3177 function createComponent ( 3178 Ctor, 3179 data, 3180 context, 3181 children, 3182 tag 3183 ) { 3184 if (isUndef(Ctor)) { 3185 return 3186 } 3187 3188 var baseCtor = context.$options._base; 3189 3190 // plain options object: turn it into a constructor 3191 if (isObject(Ctor)) { 3192 Ctor = baseCtor.extend(Ctor); 3193 } 3194 3195 // if at this stage it's not a constructor or an async component factory, 3196 // reject. 3197 if (typeof Ctor !== 'function') { 3198 { 3199 warn(("Invalid Component definition: " + (String(Ctor))), context); 3200 } 3201 return 3202 } 3203 3204 // async component 3205 var asyncFactory; 3206 if (isUndef(Ctor.cid)) { 3207 asyncFactory = Ctor; 3208 Ctor = resolveAsyncComponent(asyncFactory, baseCtor); 3209 if (Ctor === undefined) { 3210 // return a placeholder node for async component, which is rendered 3211 // as a comment node but preserves all the raw information for the node. 3212 // the information will be used for async server-rendering and hydration. 3213 return createAsyncPlaceholder( 3214 asyncFactory, 3215 data, 3216 context, 3217 children, 3218 tag 3219 ) 3220 } 3221 } 3222 3223 data = data || {}; 3224 3225 // resolve constructor options in case global mixins are applied after 3226 // component constructor creation 3227 resolveConstructorOptions(Ctor); 3228 3229 // transform component v-model data into props & events 3230 if (isDef(data.model)) { 3231 transformModel(Ctor.options, data); 3232 } 3233 3234 // extract props 3235 var propsData = extractPropsFromVNodeData(data, Ctor, tag); 3236 3237 // functional component 3238 if (isTrue(Ctor.options.functional)) { 3239 return createFunctionalComponent(Ctor, propsData, data, context, children) 3240 } 3241 3242 // extract listeners, since these needs to be treated as 3243 // child component listeners instead of DOM listeners 3244 var listeners = data.on; 3245 // replace with listeners with .native modifier 3246 // so it gets processed during parent component patch. 3247 data.on = data.nativeOn; 3248 3249 if (isTrue(Ctor.options.abstract)) { 3250 // abstract components do not keep anything 3251 // other than props & listeners & slot 3252 3253 // work around flow 3254 var slot = data.slot; 3255 data = {}; 3256 if (slot) { 3257 data.slot = slot; 3258 } 3259 } 3260 3261 // install component management hooks onto the placeholder node 3262 installComponentHooks(data); 3263 3264 // return a placeholder vnode 3265 var name = Ctor.options.name || tag; 3266 var vnode = new VNode( 3267 ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')), 3268 data, undefined, undefined, undefined, context, 3269 { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }, 3270 asyncFactory 3271 ); 3272 3273 return vnode 3274 } 3275 3276 function createComponentInstanceForVnode ( 3277 vnode, // we know it's MountedComponentVNode but flow doesn't 3278 parent // activeInstance in lifecycle state 3279 ) { 3280 var options = { 3281 _isComponent: true, 3282 _parentVnode: vnode, 3283 parent: parent 3284 }; 3285 // check inline-template render functions 3286 var inlineTemplate = vnode.data.inlineTemplate; 3287 if (isDef(inlineTemplate)) { 3288 options.render = inlineTemplate.render; 3289 options.staticRenderFns = inlineTemplate.staticRenderFns; 3290 } 3291 return new vnode.componentOptions.Ctor(options) 3292 } 3293 3294 function installComponentHooks (data) { 3295 var hooks = data.hook || (data.hook = {}); 3296 for (var i = 0; i < hooksToMerge.length; i++) { 3297 var key = hooksToMerge[i]; 3298 var existing = hooks[key]; 3299 var toMerge = componentVNodeHooks[key]; 3300 if (existing !== toMerge && !(existing && existing._merged)) { 3301 hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge; 3302 } 3303 } 3304 } 3305 3306 function mergeHook$1 (f1, f2) { 3307 var merged = function (a, b) { 3308 // flow complains about extra args which is why we use any 3309 f1(a, b); 3310 f2(a, b); 3311 }; 3312 merged._merged = true; 3313 return merged 3314 } 3315 3316 // transform component v-model info (value and callback) into 3317 // prop and event handler respectively. 3318 function transformModel (options, data) { 3319 var prop = (options.model && options.model.prop) || 'value'; 3320 var event = (options.model && options.model.event) || 'input' 3321 ;(data.attrs || (data.attrs = {}))[prop] = data.model.value; 3322 var on = data.on || (data.on = {}); 3323 var existing = on[event]; 3324 var callback = data.model.callback; 3325 if (isDef(existing)) { 3326 if ( 3327 Array.isArray(existing) 3328 ? existing.indexOf(callback) === -1 3329 : existing !== callback 3330 ) { 3331 on[event] = [callback].concat(existing); 3332 } 3333 } else { 3334 on[event] = callback; 3335 } 3336 } 3337 3338 /* */ 3339 3340 var SIMPLE_NORMALIZE = 1; 3341 var ALWAYS_NORMALIZE = 2; 3342 3343 // wrapper function for providing a more flexible interface 3344 // without getting yelled at by flow 3345 function createElement ( 3346 context, 3347 tag, 3348 data, 3349 children, 3350 normalizationType, 3351 alwaysNormalize 3352 ) { 3353 if (Array.isArray(data) || isPrimitive(data)) { 3354 normalizationType = children; 3355 children = data; 3356 data = undefined; 3357 } 3358 if (isTrue(alwaysNormalize)) { 3359 normalizationType = ALWAYS_NORMALIZE; 3360 } 3361 return _createElement(context, tag, data, children, normalizationType) 3362 } 3363 3364 function _createElement ( 3365 context, 3366 tag, 3367 data, 3368 children, 3369 normalizationType 3370 ) { 3371 if (isDef(data) && isDef((data).__ob__)) { 3372 warn( 3373 "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" + 3374 'Always create fresh vnode data objects in each render!', 3375 context 3376 ); 3377 return createEmptyVNode() 3378 } 3379 // object syntax in v-bind 3380 if (isDef(data) && isDef(data.is)) { 3381 tag = data.is; 3382 } 3383 if (!tag) { 3384 // in case of component :is set to falsy value 3385 return createEmptyVNode() 3386 } 3387 // warn against non-primitive key 3388 if (isDef(data) && isDef(data.key) && !isPrimitive(data.key) 3389 ) { 3390 { 3391 warn( 3392 'Avoid using non-primitive value as key, ' + 3393 'use string/number value instead.', 3394 context 3395 ); 3396 } 3397 } 3398 // support single function children as default scoped slot 3399 if (Array.isArray(children) && 3400 typeof children[0] === 'function' 3401 ) { 3402 data = data || {}; 3403 data.scopedSlots = { default: children[0] }; 3404 children.length = 0; 3405 } 3406 if (normalizationType === ALWAYS_NORMALIZE) { 3407 children = normalizeChildren(children); 3408 } else if (normalizationType === SIMPLE_NORMALIZE) { 3409 children = simpleNormalizeChildren(children); 3410 } 3411 var vnode, ns; 3412 if (typeof tag === 'string') { 3413 var Ctor; 3414 ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag); 3415 if (config.isReservedTag(tag)) { 3416 // platform built-in elements 3417 vnode = new VNode( 3418 config.parsePlatformTagName(tag), data, children, 3419 undefined, undefined, context 3420 ); 3421 } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) { 3422 // component 3423 vnode = createComponent(Ctor, data, context, children, tag); 3424 } else { 3425 // unknown or unlisted namespaced elements 3426 // check at runtime because it may get assigned a namespace when its 3427 // parent normalizes children 3428 vnode = new VNode( 3429 tag, data, children, 3430 undefined, undefined, context 3431 ); 3432 } 3433 } else { 3434 // direct component options / constructor 3435 vnode = createComponent(tag, data, context, children); 3436 } 3437 if (Array.isArray(vnode)) { 3438 return vnode 3439 } else if (isDef(vnode)) { 3440 if (isDef(ns)) { applyNS(vnode, ns); } 3441 if (isDef(data)) { registerDeepBindings(data); } 3442 return vnode 3443 } else { 3444 return createEmptyVNode() 3445 } 3446 } 3447 3448 function applyNS (vnode, ns, force) { 3449 vnode.ns = ns; 3450 if (vnode.tag === 'foreignObject') { 3451 // use default namespace inside foreignObject 3452 ns = undefined; 3453 force = true; 3454 } 3455 if (isDef(vnode.children)) { 3456 for (var i = 0, l = vnode.children.length; i < l; i++) { 3457 var child = vnode.children[i]; 3458 if (isDef(child.tag) && ( 3459 isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) { 3460 applyNS(child, ns, force); 3461 } 3462 } 3463 } 3464 } 3465 3466 // ref #5318 3467 // necessary to ensure parent re-render when deep bindings like :style and 3468 // :class are used on slot nodes 3469 function registerDeepBindings (data) { 3470 if (isObject(data.style)) { 3471 traverse(data.style); 3472 } 3473 if (isObject(data.class)) { 3474 traverse(data.class); 3475 } 3476 } 3477 3478 /* */ 3479 3480 function initRender (vm) { 3481 vm._vnode = null; // the root of the child tree 3482 vm._staticTrees = null; // v-once cached trees 3483 var options = vm.$options; 3484 var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree 3485 var renderContext = parentVnode && parentVnode.context; 3486 vm.$slots = resolveSlots(options._renderChildren, renderContext); 3487 vm.$scopedSlots = emptyObject; 3488 // bind the createElement fn to this instance 3489 // so that we get proper render context inside it. 3490 // args order: tag, data, children, normalizationType, alwaysNormalize 3491 // internal version is used by render functions compiled from templates 3492 vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); }; 3493 // normalization is always applied for the public version, used in 3494 // user-written render functions. 3495 vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); }; 3496 3497 // $attrs & $listeners are exposed for easier HOC creation. 3498 // they need to be reactive so that HOCs using them are always updated 3499 var parentData = parentVnode && parentVnode.data; 3500 3501 /* istanbul ignore else */ 3502 { 3503 defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () { 3504 !isUpdatingChildComponent && warn("$attrs is readonly.", vm); 3505 }, true); 3506 defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () { 3507 !isUpdatingChildComponent && warn("$listeners is readonly.", vm); 3508 }, true); 3509 } 3510 } 3511 3512 var currentRenderingInstance = null; 3513 3514 function renderMixin (Vue) { 3515 // install runtime convenience helpers 3516 installRenderHelpers(Vue.prototype); 3517 3518 Vue.prototype.$nextTick = function (fn) { 3519 return nextTick(fn, this) 3520 }; 3521 3522 Vue.prototype._render = function () { 3523 var vm = this; 3524 var ref = vm.$options; 3525 var render = ref.render; 3526 var _parentVnode = ref._parentVnode; 3527 3528 if (_parentVnode) { 3529 vm.$scopedSlots = normalizeScopedSlots( 3530 _parentVnode.data.scopedSlots, 3531 vm.$slots, 3532 vm.$scopedSlots 3533 ); 3534 } 3535 3536 // set parent vnode. this allows render functions to have access 3537 // to the data on the placeholder node. 3538 vm.$vnode = _parentVnode; 3539 // render self 3540 var vnode; 3541 try { 3542 // There's no need to maintain a stack becaues all render fns are called 3543 // separately from one another. Nested component's render fns are called 3544 // when parent component is patched. 3545 currentRenderingInstance = vm; 3546 vnode = render.call(vm._renderProxy, vm.$createElement); 3547 } catch (e) { 3548 handleError(e, vm, "render"); 3549 // return error render result, 3550 // or previous vnode to prevent render error causing blank component 3551 /* istanbul ignore else */ 3552 if (vm.$options.renderError) { 3553 try { 3554 vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e); 3555 } catch (e) { 3556 handleError(e, vm, "renderError"); 3557 vnode = vm._vnode; 3558 } 3559 } else { 3560 vnode = vm._vnode; 3561 } 3562 } finally { 3563 currentRenderingInstance = null; 3564 } 3565 // if the returned array contains only a single node, allow it 3566 if (Array.isArray(vnode) && vnode.length === 1) { 3567 vnode = vnode[0]; 3568 } 3569 // return empty vnode in case the render function errored out 3570 if (!(vnode instanceof VNode)) { 3571 if (Array.isArray(vnode)) { 3572 warn( 3573 'Multiple root nodes returned from render function. Render function ' + 3574 'should return a single root node.', 3575 vm 3576 ); 3577 } 3578 vnode = createEmptyVNode(); 3579 } 3580 // set parent 3581 vnode.parent = _parentVnode; 3582 return vnode 3583 }; 3584 } 3585 3586 /* */ 3587 3588 function ensureCtor (comp, base) { 3589 if ( 3590 comp.__esModule || 3591 (hasSymbol && comp[Symbol.toStringTag] === 'Module') 3592 ) { 3593 comp = comp.default; 3594 } 3595 return isObject(comp) 3596 ? base.extend(comp) 3597 : comp 3598 } 3599 3600 function createAsyncPlaceholder ( 3601 factory, 3602 data, 3603 context, 3604 children, 3605 tag 3606 ) { 3607 var node = createEmptyVNode(); 3608 node.asyncFactory = factory; 3609 node.asyncMeta = { data: data, context: context, children: children, tag: tag }; 3610 return node 3611 } 3612 3613 function resolveAsyncComponent ( 3614 factory, 3615 baseCtor 3616 ) { 3617 if (isTrue(factory.error) && isDef(factory.errorComp)) { 3618 return factory.errorComp 3619 } 3620 3621 if (isDef(factory.resolved)) { 3622 return factory.resolved 3623 } 3624 3625 var owner = currentRenderingInstance;
vendor: 4,627 bytes, lines 3626-3760
3626 if (owner && isDef(factory.owners) && factory.owners.indexOf(owner) === -1) { 3627 // already pending 3628 factory.owners.push(owner); 3629 } 3630 3631 if (isTrue(factory.loading) && isDef(factory.loadingComp)) { 3632 return factory.loadingComp 3633 } 3634 3635 if (owner && !isDef(factory.owners)) { 3636 var owners = factory.owners = [owner]; 3637 var sync = true; 3638 var timerLoading = null; 3639 var timerTimeout = null 3640 3641 ;(owner).$on('hook:destroyed', function () { return remove(owners, owner); }); 3642 3643 var forceRender = function (renderCompleted) { 3644 for (var i = 0, l = owners.length; i < l; i++) { 3645 (owners[i]).$forceUpdate(); 3646 } 3647 3648 if (renderCompleted) { 3649 owners.length = 0; 3650 if (timerLoading !== null) { 3651 clearTimeout(timerLoading); 3652 timerLoading = null; 3653 } 3654 if (timerTimeout !== null) { 3655 clearTimeout(timerTimeout); 3656 timerTimeout = null; 3657 } 3658 } 3659 }; 3660 3661 var resolve = once(function (res) { 3662 // cache resolved 3663 factory.resolved = ensureCtor(res, baseCtor); 3664 // invoke callbacks only if this is not a synchronous resolve 3665 // (async resolves are shimmed as synchronous during SSR) 3666 if (!sync) { 3667 forceRender(true); 3668 } else { 3669 owners.length = 0; 3670 } 3671 }); 3672 3673 var reject = once(function (reason) { 3674 warn( 3675 "Failed to resolve async component: " + (String(factory)) + 3676 (reason ? ("\nReason: " + reason) : '') 3677 ); 3678 if (isDef(factory.errorComp)) { 3679 factory.error = true; 3680 forceRender(true); 3681 } 3682 }); 3683 3684 var res = factory(resolve, reject); 3685 3686 if (isObject(res)) { 3687 if (isPromise(res)) { 3688 // () => Promise 3689 if (isUndef(factory.resolved)) { 3690 res.then(resolve, reject); 3691 } 3692 } else if (isPromise(res.component)) { 3693 res.component.then(resolve, reject); 3694 3695 if (isDef(res.error)) { 3696 factory.errorComp = ensureCtor(res.error, baseCtor); 3697 } 3698 3699 if (isDef(res.loading)) { 3700 factory.loadingComp = ensureCtor(res.loading, baseCtor); 3701 if (res.delay === 0) { 3702 factory.loading = true; 3703 } else { 3704 timerLoading = setTimeout(function () { 3705 timerLoading = null; 3706 if (isUndef(factory.resolved) && isUndef(factory.error)) { 3707 factory.loading = true; 3708 forceRender(false); 3709 } 3710 }, res.delay || 200); 3711 } 3712 } 3713 3714 if (isDef(res.timeout)) { 3715 timerTimeout = setTimeout(function () { 3716 timerTimeout = null; 3717 if (isUndef(factory.resolved)) { 3718 reject( 3719 "timeout (" + (res.timeout) + "ms)" 3720 ); 3721 } 3722 }, res.timeout); 3723 } 3724 } 3725 } 3726 3727 sync = false; 3728 // return in case resolved synchronously 3729 return factory.loading 3730 ? factory.loadingComp 3731 : factory.resolved 3732 } 3733 } 3734 3735 /* */ 3736 3737 function isAsyncPlaceholder (node) { 3738 return node.isComment && node.asyncFactory 3739 } 3740 3741 /* */ 3742 3743 function getFirstComponentChild (children) { 3744 if (Array.isArray(children)) { 3745 for (var i = 0; i < children.length; i++) { 3746 var c = children[i]; 3747 if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) { 3748 return c 3749 } 3750 } 3751 } 3752 } 3753 3754 /* */ 3755 3756 /* */ 3757 3758 function initEvents (vm) { 3759 vm._events = Object.create(null); 3760 vm._hasHookEvent = false;
vendor: 10,387 bytes, lines 3761-4076
3761 // init parent attached events 3762 var listeners = vm.$options._parentListeners; 3763 if (listeners) { 3764 updateComponentListeners(vm, listeners); 3765 } 3766 } 3767 3768 var target; 3769 3770 function add (event, fn) { 3771 target.$on(event, fn); 3772 } 3773 3774 function remove$1 (event, fn) { 3775 target.$off(event, fn); 3776 } 3777 3778 function createOnceHandler (event, fn) { 3779 var _target = target; 3780 return function onceHandler () { 3781 var res = fn.apply(null, arguments); 3782 if (res !== null) { 3783 _target.$off(event, onceHandler); 3784 } 3785 } 3786 } 3787 3788 function updateComponentListeners ( 3789 vm, 3790 listeners, 3791 oldListeners 3792 ) { 3793 target = vm; 3794 updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm); 3795 target = undefined; 3796 } 3797 3798 function eventsMixin (Vue) { 3799 var hookRE = /^hook:/; 3800 Vue.prototype.$on = function (event, fn) { 3801 var vm = this; 3802 if (Array.isArray(event)) { 3803 for (var i = 0, l = event.length; i < l; i++) { 3804 vm.$on(event[i], fn); 3805 } 3806 } else { 3807 (vm._events[event] || (vm._events[event] = [])).push(fn); 3808 // optimize hook:event cost by using a boolean flag marked at registration 3809 // instead of a hash lookup 3810 if (hookRE.test(event)) { 3811 vm._hasHookEvent = true; 3812 } 3813 } 3814 return vm 3815 }; 3816 3817 Vue.prototype.$once = function (event, fn) { 3818 var vm = this; 3819 function on () { 3820 vm.$off(event, on); 3821 fn.apply(vm, arguments); 3822 } 3823 on.fn = fn; 3824 vm.$on(event, on); 3825 return vm 3826 }; 3827 3828 Vue.prototype.$off = function (event, fn) { 3829 var vm = this; 3830 // all 3831 if (!arguments.length) { 3832 vm._events = Object.create(null); 3833 return vm 3834 } 3835 // array of events 3836 if (Array.isArray(event)) { 3837 for (var i$1 = 0, l = event.length; i$1 < l; i$1++) { 3838 vm.$off(event[i$1], fn); 3839 } 3840 return vm 3841 } 3842 // specific event 3843 var cbs = vm._events[event]; 3844 if (!cbs) { 3845 return vm 3846 } 3847 if (!fn) { 3848 vm._events[event] = null; 3849 return vm 3850 } 3851 // specific handler 3852 var cb; 3853 var i = cbs.length; 3854 while (i--) { 3855 cb = cbs[i]; 3856 if (cb === fn || cb.fn === fn) { 3857 cbs.splice(i, 1); 3858 break 3859 } 3860 } 3861 return vm 3862 }; 3863 3864 Vue.prototype.$emit = function (event) { 3865 var vm = this; 3866 { 3867 var lowerCaseEvent = event.toLowerCase(); 3868 if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) { 3869 tip( 3870 "Event \"" + lowerCaseEvent + "\" is emitted in component " + 3871 (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " + 3872 "Note that HTML attributes are case-insensitive and you cannot use " + 3873 "v-on to listen to camelCase events when using in-DOM templates. " + 3874 "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"." 3875 ); 3876 } 3877 } 3878 var cbs = vm._events[event]; 3879 if (cbs) { 3880 cbs = cbs.length > 1 ? toArray(cbs) : cbs; 3881 var args = toArray(arguments, 1); 3882 var info = "event handler for \"" + event + "\""; 3883 for (var i = 0, l = cbs.length; i < l; i++) { 3884 invokeWithErrorHandling(cbs[i], vm, args, vm, info); 3885 } 3886 } 3887 return vm 3888 }; 3889 } 3890 3891 /* */ 3892 3893 var activeInstance = null; 3894 var isUpdatingChildComponent = false; 3895 3896 function setActiveInstance(vm) { 3897 var prevActiveInstance = activeInstance; 3898 activeInstance = vm; 3899 return function () { 3900 activeInstance = prevActiveInstance; 3901 } 3902 } 3903 3904 function initLifecycle (vm) { 3905 var options = vm.$options; 3906 3907 // locate first non-abstract parent 3908 var parent = options.parent; 3909 if (parent && !options.abstract) { 3910 while (parent.$options.abstract && parent.$parent) { 3911 parent = parent.$parent; 3912 } 3913 parent.$children.push(vm); 3914 } 3915 3916 vm.$parent = parent; 3917 vm.$root = parent ? parent.$root : vm; 3918 3919 vm.$children = []; 3920 vm.$refs = {}; 3921 3922 vm._watcher = null; 3923 vm._inactive = null; 3924 vm._directInactive = false; 3925 vm._isMounted = false; 3926 vm._isDestroyed = false; 3927 vm._isBeingDestroyed = false; 3928 } 3929 3930 function lifecycleMixin (Vue) { 3931 Vue.prototype._update = function (vnode, hydrating) { 3932 var vm = this; 3933 var prevEl = vm.$el; 3934 var prevVnode = vm._vnode; 3935 var restoreActiveInstance = setActiveInstance(vm); 3936 vm._vnode = vnode; 3937 // Vue.prototype.__patch__ is injected in entry points 3938 // based on the rendering backend used. 3939 if (!prevVnode) { 3940 // initial render 3941 vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */); 3942 } else { 3943 // updates 3944 vm.$el = vm.__patch__(prevVnode, vnode); 3945 } 3946 restoreActiveInstance(); 3947 // update __vue__ reference 3948 if (prevEl) { 3949 prevEl.__vue__ = null; 3950 } 3951 if (vm.$el) { 3952 vm.$el.__vue__ = vm; 3953 } 3954 // if parent is an HOC, update its $el as well 3955 if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) { 3956 vm.$parent.$el = vm.$el; 3957 } 3958 // updated hook is called by the scheduler to ensure that children are 3959 // updated in a parent's updated hook. 3960 }; 3961 3962 Vue.prototype.$forceUpdate = function () { 3963 var vm = this; 3964 if (vm._watcher) { 3965 vm._watcher.update(); 3966 } 3967 }; 3968 3969 Vue.prototype.$destroy = function () { 3970 var vm = this; 3971 if (vm._isBeingDestroyed) { 3972 return 3973 } 3974 callHook(vm, 'beforeDestroy'); 3975 vm._isBeingDestroyed = true; 3976 // remove self from parent 3977 var parent = vm.$parent; 3978 if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) { 3979 remove(parent.$children, vm); 3980 } 3981 // teardown watchers 3982 if (vm._watcher) { 3983 vm._watcher.teardown(); 3984 } 3985 var i = vm._watchers.length; 3986 while (i--) { 3987 vm._watchers[i].teardown(); 3988 } 3989 // remove reference from data ob 3990 // frozen object may not have observer. 3991 if (vm._data.__ob__) { 3992 vm._data.__ob__.vmCount--; 3993 } 3994 // call the last hook... 3995 vm._isDestroyed = true; 3996 // invoke destroy hooks on current rendered tree 3997 vm.__patch__(vm._vnode, null); 3998 // fire destroyed hook 3999 callHook(vm, 'destroyed'); 4000 // turn off all instance listeners. 4001 vm.$off(); 4002 // remove __vue__ reference 4003 if (vm.$el) { 4004 vm.$el.__vue__ = null; 4005 } 4006 // release circular reference (#6759) 4007 if (vm.$vnode) { 4008 vm.$vnode.parent = null; 4009 } 4010 }; 4011 } 4012 4013 function mountComponent ( 4014 vm, 4015 el, 4016 hydrating 4017 ) { 4018 vm.$el = el; 4019 if (!vm.$options.render) { 4020 vm.$options.render = createEmptyVNode; 4021 { 4022 /* istanbul ignore if */ 4023 if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') || 4024 vm.$options.el || el) { 4025 warn( 4026 'You are using the runtime-only build of Vue where the template ' + 4027 'compiler is not available. Either pre-compile the templates into ' + 4028 'render functions, or use the compiler-included build.', 4029 vm 4030 ); 4031 } else { 4032 warn( 4033 'Failed to mount component: template or render function not defined.', 4034 vm 4035 ); 4036 } 4037 } 4038 } 4039 callHook(vm, 'beforeMount'); 4040 4041 var updateComponent; 4042 /* istanbul ignore if */ 4043 if (config.performance && mark) { 4044 updateComponent = function () { 4045 var name = vm._name; 4046 var id = vm._uid; 4047 var startTag = "vue-perf-start:" + id; 4048 var endTag = "vue-perf-end:" + id; 4049 4050 mark(startTag); 4051 var vnode = vm._render(); 4052 mark(endTag); 4053 measure(("vue " + name + " render"), startTag, endTag); 4054 4055 mark(startTag); 4056 vm._update(vnode, hydrating); 4057 mark(endTag); 4058 measure(("vue " + name + " patch"), startTag, endTag); 4059 }; 4060 } else { 4061 updateComponent = function () { 4062 vm._update(vm._render(), hydrating); 4063 }; 4064 } 4065 4066 // we set this to vm._watcher inside the watcher's constructor 4067 // since the watcher's initial patch may call $forceUpdate (e.g. inside child 4068 // component's mounted hook), which relies on vm._watcher being already defined 4069 new Watcher(vm, updateComponent, noop, { 4070 before: function before () { 4071 if (vm._isMounted && !vm._isDestroyed) { 4072 callHook(vm, 'beforeUpdate'); 4073 } 4074 } 4075 }, true /* isRenderWatcher */); 4076 hydrating = false;
vendor: 5,112 bytes, lines 4077-4232
4077 4078 // manually mounted instance, call mounted on self 4079 // mounted is called for render-created child components in its inserted hook 4080 if (vm.$vnode == null) { 4081 vm._isMounted = true; 4082 callHook(vm, 'mounted'); 4083 } 4084 return vm 4085 } 4086 4087 function updateChildComponent ( 4088 vm, 4089 propsData, 4090 listeners, 4091 parentVnode, 4092 renderChildren 4093 ) { 4094 { 4095 isUpdatingChildComponent = true; 4096 } 4097 4098 // determine whether component has slot children 4099 // we need to do this before overwriting $options._renderChildren. 4100 4101 // check if there are dynamic scopedSlots (hand-written or compiled but with 4102 // dynamic slot names). Static scoped slots compiled from template has the 4103 // "$stable" marker. 4104 var newScopedSlots = parentVnode.data.scopedSlots; 4105 var oldScopedSlots = vm.$scopedSlots; 4106 var hasDynamicScopedSlot = !!( 4107 (newScopedSlots && !newScopedSlots.$stable) || 4108 (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) || 4109 (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) 4110 ); 4111 4112 // Any static slot children from the parent may have changed during parent's 4113 // update. Dynamic scoped slots may also have changed. In such cases, a forced 4114 // update is necessary to ensure correctness. 4115 var needsForceUpdate = !!( 4116 renderChildren || // has new static slots 4117 vm.$options._renderChildren || // has old static slots 4118 hasDynamicScopedSlot 4119 ); 4120 4121 vm.$options._parentVnode = parentVnode; 4122 vm.$vnode = parentVnode; // update vm's placeholder node without re-render 4123 4124 if (vm._vnode) { // update child tree's parent 4125 vm._vnode.parent = parentVnode; 4126 } 4127 vm.$options._renderChildren = renderChildren; 4128 4129 // update $attrs and $listeners hash 4130 // these are also reactive so they may trigger child update if the child 4131 // used them during render 4132 vm.$attrs = parentVnode.data.attrs || emptyObject; 4133 vm.$listeners = listeners || emptyObject; 4134 4135 // update props 4136 if (propsData && vm.$options.props) { 4137 toggleObserving(false); 4138 var props = vm._props; 4139 var propKeys = vm.$options._propKeys || []; 4140 for (var i = 0; i < propKeys.length; i++) { 4141 var key = propKeys[i]; 4142 var propOptions = vm.$options.props; // wtf flow? 4143 props[key] = validateProp(key, propOptions, propsData, vm); 4144 } 4145 toggleObserving(true); 4146 // keep a copy of raw propsData 4147 vm.$options.propsData = propsData; 4148 } 4149 4150 // update listeners 4151 listeners = listeners || emptyObject; 4152 var oldListeners = vm.$options._parentListeners; 4153 vm.$options._parentListeners = listeners; 4154 updateComponentListeners(vm, listeners, oldListeners); 4155 4156 // resolve slots + force update if has children 4157 if (needsForceUpdate) { 4158 vm.$slots = resolveSlots(renderChildren, parentVnode.context); 4159 vm.$forceUpdate(); 4160 } 4161 4162 { 4163 isUpdatingChildComponent = false; 4164 } 4165 } 4166 4167 function isInInactiveTree (vm) { 4168 while (vm && (vm = vm.$parent)) { 4169 if (vm._inactive) { return true } 4170 } 4171 return false 4172 } 4173 4174 function activateChildComponent (vm, direct) { 4175 if (direct) { 4176 vm._directInactive = false; 4177 if (isInInactiveTree(vm)) { 4178 return 4179 } 4180 } else if (vm._directInactive) { 4181 return 4182 } 4183 if (vm._inactive || vm._inactive === null) { 4184 vm._inactive = false; 4185 for (var i = 0; i < vm.$children.length; i++) { 4186 activateChildComponent(vm.$children[i]); 4187 } 4188 callHook(vm, 'activated'); 4189 } 4190 } 4191 4192 function deactivateChildComponent (vm, direct) { 4193 if (direct) { 4194 vm._directInactive = true; 4195 if (isInInactiveTree(vm)) { 4196 return 4197 } 4198 } 4199 if (!vm._inactive) { 4200 vm._inactive = true; 4201 for (var i = 0; i < vm.$children.length; i++) { 4202 deactivateChildComponent(vm.$children[i]); 4203 } 4204 callHook(vm, 'deactivated'); 4205 } 4206 } 4207 4208 function callHook (vm, hook) { 4209 // #7573 disable dep collection when invoking lifecycle hooks 4210 pushTarget(); 4211 var handlers = vm.$options[hook]; 4212 var info = hook + " hook"; 4213 if (handlers) { 4214 for (var i = 0, j = handlers.length; i < j; i++) { 4215 invokeWithErrorHandling(handlers[i], vm, null, vm, info); 4216 } 4217 } 4218 if (vm._hasHookEvent) { 4219 vm.$emit('hook:' + hook); 4220 } 4221 popTarget(); 4222 } 4223 4224 /* */ 4225 4226 var MAX_UPDATE_COUNT = 100; 4227 4228 var queue = []; 4229 var activatedChildren = []; 4230 var has = {}; 4231 var circular = {}; 4232 var waiting = false;
vendor: 10,114 bytes, lines 4233-4550
4233 var flushing = false; 4234 var index = 0; 4235 4236 /** 4237 * Reset the scheduler's state. 4238 */ 4239 function resetSchedulerState () { 4240 index = queue.length = activatedChildren.length = 0; 4241 has = {}; 4242 { 4243 circular = {}; 4244 } 4245 waiting = flushing = false; 4246 } 4247 4248 // Async edge case #6566 requires saving the timestamp when event listeners are 4249 // attached. However, calling performance.now() has a perf overhead especially 4250 // if the page has thousands of event listeners. Instead, we take a timestamp 4251 // every time the scheduler flushes and use that for all event listeners 4252 // attached during that flush. 4253 var currentFlushTimestamp = 0; 4254 4255 // Async edge case fix requires storing an event listener's attach timestamp. 4256 var getNow = Date.now; 4257 4258 // Determine what event timestamp the browser is using. Annoyingly, the 4259 // timestamp can either be hi-res (relative to page load) or low-res 4260 // (relative to UNIX epoch), so in order to compare time we have to use the 4261 // same timestamp type when saving the flush timestamp. 4262 // All IE versions use low-res event timestamps, and have problematic clock 4263 // implementations (#9632) 4264 if (inBrowser && !isIE) { 4265 var performance = window.performance; 4266 if ( 4267 performance && 4268 typeof performance.now === 'function' && 4269 getNow() > document.createEvent('Event').timeStamp 4270 ) { 4271 // if the event timestamp, although evaluated AFTER the Date.now(), is 4272 // smaller than it, it means the event is using a hi-res timestamp, 4273 // and we need to use the hi-res version for event listener timestamps as 4274 // well. 4275 getNow = function () { return performance.now(); }; 4276 } 4277 } 4278 4279 /** 4280 * Flush both queues and run the watchers. 4281 */ 4282 function flushSchedulerQueue () { 4283 currentFlushTimestamp = getNow(); 4284 flushing = true; 4285 var watcher, id; 4286 4287 // Sort queue before flush. 4288 // This ensures that: 4289 // 1. Components are updated from parent to child. (because parent is always 4290 // created before the child) 4291 // 2. A component's user watchers are run before its render watcher (because 4292 // user watchers are created before the render watcher) 4293 // 3. If a component is destroyed during a parent component's watcher run, 4294 // its watchers can be skipped. 4295 queue.sort(function (a, b) { return a.id - b.id; }); 4296 4297 // do not cache length because more watchers might be pushed 4298 // as we run existing watchers 4299 for (index = 0; index < queue.length; index++) { 4300 watcher = queue[index]; 4301 if (watcher.before) { 4302 watcher.before(); 4303 } 4304 id = watcher.id; 4305 has[id] = null; 4306 watcher.run(); 4307 // in dev build, check and stop circular updates. 4308 if (has[id] != null) { 4309 circular[id] = (circular[id] || 0) + 1; 4310 if (circular[id] > MAX_UPDATE_COUNT) { 4311 warn( 4312 'You may have an infinite update loop ' + ( 4313 watcher.user 4314 ? ("in watcher with expression \"" + (watcher.expression) + "\"") 4315 : "in a component render function." 4316 ), 4317 watcher.vm 4318 ); 4319 break 4320 } 4321 } 4322 } 4323 4324 // keep copies of post queues before resetting state 4325 var activatedQueue = activatedChildren.slice(); 4326 var updatedQueue = queue.slice(); 4327 4328 resetSchedulerState(); 4329 4330 // call component updated and activated hooks 4331 callActivatedHooks(activatedQueue); 4332 callUpdatedHooks(updatedQueue); 4333 4334 // devtool hook 4335 /* istanbul ignore if */ 4336 if (devtools && config.devtools) { 4337 devtools.emit('flush'); 4338 } 4339 } 4340 4341 function callUpdatedHooks (queue) { 4342 var i = queue.length; 4343 while (i--) { 4344 var watcher = queue[i]; 4345 var vm = watcher.vm; 4346 if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) { 4347 callHook(vm, 'updated'); 4348 } 4349 } 4350 } 4351 4352 /** 4353 * Queue a kept-alive component that was activated during patch. 4354 * The queue will be processed after the entire tree has been patched. 4355 */ 4356 function queueActivatedComponent (vm) { 4357 // setting _inactive to false here so that a render function can 4358 // rely on checking whether it's in an inactive tree (e.g. router-view) 4359 vm._inactive = false; 4360 activatedChildren.push(vm); 4361 } 4362 4363 function callActivatedHooks (queue) { 4364 for (var i = 0; i < queue.length; i++) { 4365 queue[i]._inactive = true; 4366 activateChildComponent(queue[i], true /* true */); 4367 } 4368 } 4369 4370 /** 4371 * Push a watcher into the watcher queue. 4372 * Jobs with duplicate IDs will be skipped unless it's 4373 * pushed when the queue is being flushed. 4374 */ 4375 function queueWatcher (watcher) { 4376 var id = watcher.id; 4377 if (has[id] == null) { 4378 has[id] = true; 4379 if (!flushing) { 4380 queue.push(watcher); 4381 } else { 4382 // if already flushing, splice the watcher based on its id 4383 // if already past its id, it will be run next immediately. 4384 var i = queue.length - 1; 4385 while (i > index && queue[i].id > watcher.id) { 4386 i--; 4387 } 4388 queue.splice(i + 1, 0, watcher); 4389 } 4390 // queue the flush 4391 if (!waiting) { 4392 waiting = true; 4393 4394 if (!config.async) { 4395 flushSchedulerQueue(); 4396 return 4397 } 4398 nextTick(flushSchedulerQueue); 4399 } 4400 } 4401 } 4402 4403 /* */ 4404 4405 4406 4407 var uid$2 = 0; 4408 4409 /** 4410 * A watcher parses an expression, collects dependencies, 4411 * and fires callback when the expression value changes. 4412 * This is used for both the $watch() api and directives. 4413 */ 4414 var Watcher = function Watcher ( 4415 vm, 4416 expOrFn, 4417 cb, 4418 options, 4419 isRenderWatcher 4420 ) { 4421 this.vm = vm; 4422 if (isRenderWatcher) { 4423 vm._watcher = this; 4424 } 4425 vm._watchers.push(this); 4426 // options 4427 if (options) { 4428 this.deep = !!options.deep; 4429 this.user = !!options.user; 4430 this.lazy = !!options.lazy; 4431 this.sync = !!options.sync; 4432 this.before = options.before; 4433 } else { 4434 this.deep = this.user = this.lazy = this.sync = false; 4435 } 4436 this.cb = cb; 4437 this.id = ++uid$2; // uid for batching 4438 this.active = true; 4439 this.dirty = this.lazy; // for lazy watchers 4440 this.deps = []; 4441 this.newDeps = []; 4442 this.depIds = new _Set(); 4443 this.newDepIds = new _Set(); 4444 this.expression = expOrFn.toString(); 4445 // parse expression for getter 4446 if (typeof expOrFn === 'function') { 4447 this.getter = expOrFn; 4448 } else { 4449 this.getter = parsePath(expOrFn); 4450 if (!this.getter) { 4451 this.getter = noop; 4452 warn( 4453 "Failed watching path: \"" + expOrFn + "\" " + 4454 'Watcher only accepts simple dot-delimited paths. ' + 4455 'For full control, use a function instead.', 4456 vm 4457 ); 4458 } 4459 } 4460 this.value = this.lazy 4461 ? undefined 4462 : this.get(); 4463 }; 4464 4465 /** 4466 * Evaluate the getter, and re-collect dependencies. 4467 */ 4468 Watcher.prototype.get = function get () { 4469 pushTarget(this); 4470 var value; 4471 var vm = this.vm; 4472 try { 4473 value = this.getter.call(vm, vm); 4474 } catch (e) { 4475 if (this.user) { 4476 handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\"")); 4477 } else { 4478 throw e 4479 } 4480 } finally { 4481 // "touch" every property so they are all tracked as 4482 // dependencies for deep watching 4483 if (this.deep) { 4484 traverse(value); 4485 } 4486 popTarget(); 4487 this.cleanupDeps(); 4488 } 4489 return value 4490 }; 4491 4492 /** 4493 * Add a dependency to this directive. 4494 */ 4495 Watcher.prototype.addDep = function addDep (dep) { 4496 var id = dep.id; 4497 if (!this.newDepIds.has(id)) { 4498 this.newDepIds.add(id); 4499 this.newDeps.push(dep); 4500 if (!this.depIds.has(id)) { 4501 dep.addSub(this); 4502 } 4503 } 4504 }; 4505 4506 /** 4507 * Clean up for dependency collection. 4508 */ 4509 Watcher.prototype.cleanupDeps = function cleanupDeps () { 4510 var i = this.deps.length; 4511 while (i--) { 4512 var dep = this.deps[i]; 4513 if (!this.newDepIds.has(dep.id)) { 4514 dep.removeSub(this); 4515 } 4516 } 4517 var tmp = this.depIds; 4518 this.depIds = this.newDepIds; 4519 this.newDepIds = tmp; 4520 this.newDepIds.clear(); 4521 tmp = this.deps; 4522 this.deps = this.newDeps; 4523 this.newDeps = tmp; 4524 this.newDeps.length = 0; 4525 }; 4526 4527 /** 4528 * Subscriber interface. 4529 * Will be called when a dependency changes. 4530 */ 4531 Watcher.prototype.update = function update () { 4532 /* istanbul ignore else */ 4533 if (this.lazy) { 4534 this.dirty = true; 4535 } else if (this.sync) { 4536 this.run(); 4537 } else { 4538 queueWatcher(this); 4539 } 4540 }; 4541 4542 /** 4543 * Scheduler job interface. 4544 * Will be called by the scheduler. 4545 */ 4546 Watcher.prototype.run = function run () { 4547 if (this.active) { 4548 var value = this.get(); 4549 if ( 4550 value !== this.value ||
4551 // Deep watchers and watchers on Object/Arrays should fire even 4552 // when the value is the same, because the value may 4553 // have mutated. 4554 isObject(value) || 4555 this.deep 4556 ) { 4557 // set new value 4558 var oldValue = this.value; 4559 this.value = value; 4560 if (this.user) { 4561 try { 4562 this.cb.call(this.vm, value, oldValue); 4563 } catch (e) { 4564 handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\"")); 4565 } 4566 } else { 4567 this.cb.call(this.vm, value, oldValue); 4568 } 4569 } 4570 } 4571 }; 4572 4573 /** 4574 * Evaluate the value of the watcher. 4575 * This only gets called for lazy watchers. 4576 */ 4577 Watcher.prototype.evaluate = function evaluate () { 4578 this.value = this.get(); 4579 this.dirty = false; 4580 }; 4581 4582 /** 4583 * Depend on all deps collected by this watcher. 4584 */
4585 Watcher.prototype.depend = function depend () { 4586 var i = this.deps.length; 4587 while (i--) { 4588 this.deps[i].depend(); 4589 } 4590 }; 4591 4592 /** 4593 * Remove self from all dependencies' subscriber list. 4594 */ 4595 Watcher.prototype.teardown = function teardown () { 4596 if (this.active) { 4597 // remove self from vm's watcher list 4598 // this is a somewhat expensive operation so we skip it 4599 // if the vm is being destroyed. 4600 if (!this.vm._isBeingDestroyed) { 4601 remove(this.vm._watchers, this); 4602 } 4603 var i = this.deps.length; 4604 while (i--) { 4605 this.deps[i].removeSub(this); 4606 } 4607 this.active = false; 4608 } 4609 }; 4610 4611 /* */ 4612 4613 var sharedPropertyDefinition = { 4614 enumerable: true, 4615 configurable: true, 4616 get: noop, 4617 set: noop 4618 }; 4619 4620 function proxy (target, sourceKey, key) { 4621 sharedPropertyDefinition.get = function proxyGetter () { 4622 return this[sourceKey][key] 4623 }; 4624 sharedPropertyDefinition.set = function proxySetter (val) { 4625 this[sourceKey][key] = val; 4626 }; 4627 Object.defineProperty(target, key, sharedPropertyDefinition); 4628 } 4629 4630 function initState (vm) { 4631 vm._watchers = []; 4632 var opts = vm.$options; 4633 if (opts.props) { initProps(vm, opts.props); } 4634 if (opts.methods) { initMethods(vm, opts.methods); } 4635 if (opts.data) { 4636 initData(vm); 4637 } else { 4638 observe(vm._data = {}, true /* asRootData */); 4639 } 4640 if (opts.computed) { initComputed(vm, opts.computed); } 4641 if (opts.watch && opts.watch !== nativeWatch) { 4642 initWatch(vm, opts.watch); 4643 } 4644 } 4645 4646 function initProps (vm, propsOptions) { 4647 var propsData = vm.$options.propsData || {}; 4648 var props = vm._props = {}; 4649 // cache prop keys so that future props updates can iterate using Array 4650 // instead of dynamic object key enumeration. 4651 var keys = vm.$options._propKeys = []; 4652 var isRoot = !vm.$parent; 4653 // root instance props should be converted 4654 if (!isRoot) { 4655 toggleObserving(false); 4656 } 4657 var loop = function ( key ) { 4658 keys.push(key); 4659 var value = validateProp(key, propsOptions, propsData, vm); 4660 /* istanbul ignore else */ 4661 { 4662 var hyphenatedKey = hyphenate(key); 4663 if (isReservedAttribute(hyphenatedKey) || 4664 config.isReservedAttr(hyphenatedKey)) { 4665 warn( 4666 ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."), 4667 vm 4668 ); 4669 } 4670 defineReactive$$1(props, key, value, function () { 4671 if (!isRoot && !isUpdatingChildComponent) { 4672 warn( 4673 "Avoid mutating a prop directly since the value will be " + 4674 "overwritten whenever the parent component re-renders. " + 4675 "Instead, use a data or computed property based on the prop's " + 4676 "value. Prop being mutated: \"" + key + "\"", 4677 vm 4678 ); 4679 } 4680 }); 4681 } 4682 // static props are already proxied on the component's prototype 4683 // during Vue.extend(). We only need to proxy props defined at 4684 // instantiation here. 4685 if (!(key in vm)) { 4686 proxy(vm, "_props", key); 4687 } 4688 }; 4689 4690 for (var key in propsOptions) loop( key ); 4691 toggleObserving(true); 4692 } 4693 4694 function initData (vm) { 4695 var data = vm.$options.data; 4696 data = vm._data = typeof data === 'function' 4697 ? getData(data, vm) 4698 : data || {}; 4699 if (!isPlainObject(data)) { 4700 data = {}; 4701 warn( 4702 'data functions should return an object:\n' + 4703 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', 4704 vm 4705 ); 4706 } 4707 // proxy data on instance 4708 var keys = Object.keys(data); 4709 var props = vm.$options.props; 4710 var methods = vm.$options.methods; 4711 var i = keys.length; 4712 while (i--) { 4713 var key = keys[i]; 4714 { 4715 if (methods && hasOwn(methods, key)) { 4716 warn( 4717 ("Method \"" + key + "\" has already been defined as a data property."), 4718 vm 4719 ); 4720 } 4721 } 4722 if (props && hasOwn(props, key)) { 4723 warn( 4724 "The data property \"" + key + "\" is already declared as a prop. " + 4725 "Use prop default value instead.", 4726 vm 4727 ); 4728 } else if (!isReserved(key)) { 4729 proxy(vm, "_data", key); 4730 } 4731 } 4732 // observe data 4733 observe(data, true /* asRootData */); 4734 } 4735 4736 function getData (data, vm) { 4737 // #7573 disable dep collection when invoking data getters 4738 pushTarget(); 4739 try { 4740 return data.call(vm, vm) 4741 } catch (e) { 4742 handleError(e, vm, "data()"); 4743 return {} 4744 } finally { 4745 popTarget(); 4746 } 4747 } 4748 4749 var computedWatcherOptions = { lazy: true }; 4750 4751 function initComputed (vm, computed) { 4752 // $flow-disable-line 4753 var watchers = vm._computedWatchers = Object.create(null); 4754 // computed properties are just getters during SSR 4755 var isSSR = isServerRendering(); 4756 4757 for (var key in computed) { 4758 var userDef = computed[key]; 4759 var getter = typeof userDef === 'function' ? userDef : userDef.get; 4760 if (getter == null) { 4761 warn( 4762 ("Getter is missing for computed property \"" + key + "\"."), 4763 vm 4764 ); 4765 } 4766 4767 if (!isSSR) { 4768 // create internal watcher for the computed property. 4769 watchers[key] = new Watcher( 4770 vm, 4771 getter || noop, 4772 noop, 4773 computedWatcherOptions 4774 ); 4775 } 4776 4777 // component-defined computed properties are already defined on the 4778 // component prototype. We only need to define computed properties defined 4779 // at instantiation here. 4780 if (!(key in vm)) { 4781 defineComputed(vm, key, userDef); 4782 } else { 4783 if (key in vm.$data) { 4784 warn(("The computed property \"" + key + "\" is already defined in data."), vm); 4785 } else if (vm.$options.props && key in vm.$options.props) { 4786 warn(("The computed property \"" + key + "\" is already defined as a prop."), vm); 4787 } 4788 } 4789 } 4790 } 4791 4792 function defineComputed ( 4793 target, 4794 key, 4795 userDef 4796 ) { 4797 var shouldCache = !isServerRendering(); 4798 if (typeof userDef === 'function') { 4799 sharedPropertyDefinition.get = shouldCache 4800 ? createComputedGetter(key) 4801 : createGetterInvoker(userDef); 4802 sharedPropertyDefinition.set = noop; 4803 } else { 4804 sharedPropertyDefinition.get = userDef.get 4805 ? shouldCache && userDef.cache !== false 4806 ? createComputedGetter(key) 4807 : createGetterInvoker(userDef.get) 4808 : noop; 4809 sharedPropertyDefinition.set = userDef.set || noop; 4810 } 4811 if (sharedPropertyDefinition.set === noop) { 4812 sharedPropertyDefinition.set = function () { 4813 warn( 4814 ("Computed property \"" + key + "\" was assigned to but it has no setter."), 4815 this 4816 ); 4817 }; 4818 } 4819 Object.defineProperty(target, key, sharedPropertyDefinition); 4820 } 4821 4822 function createComputedGetter (key) { 4823 return function computedGetter () { 4824 var watcher = this._computedWatchers && this._computedWatchers[key]; 4825 if (watcher) { 4826 if (watcher.dirty) { 4827 watcher.evaluate(); 4828 } 4829 if (Dep.target) {
4830 watcher.depend(); 4831 } 4832 return watcher.value 4833 } 4834 } 4835 } 4836 4837 function createGetterInvoker(fn) { 4838 return function computedGetter () { 4839 return fn.call(this, this) 4840 } 4841 } 4842 4843 function initMethods (vm, methods) { 4844 var props = vm.$options.props; 4845 for (var key in methods) { 4846 { 4847 if (typeof methods[key] !== 'function') { 4848 warn( 4849 "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " + 4850 "Did you reference the function correctly?", 4851 vm 4852 ); 4853 } 4854 if (props && hasOwn(props, key)) { 4855 warn( 4856 ("Method \"" + key + "\" has already been defined as a prop."), 4857 vm 4858 ); 4859 } 4860 if ((key in vm) && isReserved(key)) { 4861 warn( 4862 "Method \"" + key + "\" conflicts with an existing Vue instance method. " + 4863 "Avoid defining component methods that start with _ or $." 4864 ); 4865 } 4866 } 4867 vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm); 4868 } 4869 } 4870 4871 function initWatch (vm, watch) { 4872 for (var key in watch) { 4873 var handler = watch[key]; 4874 if (Array.isArray(handler)) { 4875 for (var i = 0; i < handler.length; i++) { 4876 createWatcher(vm, key, handler[i]); 4877 } 4878 } else { 4879 createWatcher(vm, key, handler); 4880 } 4881 } 4882 } 4883 4884 function createWatcher ( 4885 vm, 4886 expOrFn, 4887 handler, 4888 options 4889 ) { 4890 if (isPlainObject(handler)) { 4891 options = handler; 4892 handler = handler.handler; 4893 } 4894 if (typeof handler === 'string') { 4895 handler = vm[handler]; 4896 } 4897 return vm.$watch(expOrFn, handler, options) 4898 } 4899 4900 function stateMixin (Vue) { 4901 // flow somehow has problems with directly declared definition object 4902 // when using Object.defineProperty, so we have to procedurally build up 4903 // the object here. 4904 var dataDef = {}; 4905 dataDef.get = function () { return this._data }; 4906 var propsDef = {}; 4907 propsDef.get = function () { return this._props }; 4908 { 4909 dataDef.set = function () { 4910 warn( 4911 'Avoid replacing instance root $data. ' + 4912 'Use nested data properties instead.', 4913 this 4914 ); 4915 }; 4916 propsDef.set = function () { 4917 warn("$props is readonly.", this); 4918 }; 4919 } 4920 Object.defineProperty(Vue.prototype, '$data', dataDef); 4921 Object.defineProperty(Vue.prototype, '$props', propsDef); 4922 4923 Vue.prototype.$set = set; 4924 Vue.prototype.$delete = del; 4925 4926 Vue.prototype.$watch = function ( 4927 expOrFn, 4928 cb, 4929 options 4930 ) { 4931 var vm = this; 4932 if (isPlainObject(cb)) { 4933 return createWatcher(vm, expOrFn, cb, options) 4934 } 4935 options = options || {}; 4936 options.user = true; 4937 var watcher = new Watcher(vm, expOrFn, cb, options); 4938 if (options.immediate) { 4939 try { 4940 cb.call(vm, watcher.value); 4941 } catch (error) { 4942 handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\"")); 4943 } 4944 } 4945 return function unwatchFn () { 4946 watcher.teardown(); 4947 } 4948 }; 4949 } 4950 4951 /* */ 4952 4953 var uid$3 = 0; 4954 4955 function initMixin (Vue) { 4956 Vue.prototype._init = function (options) { 4957 var vm = this; 4958 // a uid 4959 vm._uid = uid$3++; 4960 4961 var startTag, endTag; 4962 /* istanbul ignore if */ 4963 if (config.performance && mark) { 4964 startTag = "vue-perf-start:" + (vm._uid); 4965 endTag = "vue-perf-end:" + (vm._uid); 4966 mark(startTag); 4967 } 4968 4969 // a flag to avoid this being observed 4970 vm._isVue = true; 4971 // merge options 4972 if (options && options._isComponent) {
vendor: 4,364 bytes, lines 4973-5096
4973 // optimize internal component instantiation 4974 // since dynamic options merging is pretty slow, and none of the 4975 // internal component options needs special treatment. 4976 initInternalComponent(vm, options); 4977 } else { 4978 vm.$options = mergeOptions( 4979 resolveConstructorOptions(vm.constructor), 4980 options || {}, 4981 vm 4982 ); 4983 } 4984 /* istanbul ignore else */ 4985 { 4986 initProxy(vm); 4987 } 4988 // expose real self 4989 vm._self = vm; 4990 initLifecycle(vm); 4991 initEvents(vm); 4992 initRender(vm); 4993 callHook(vm, 'beforeCreate'); 4994 initInjections(vm); // resolve injections before data/props 4995 initState(vm); 4996 initProvide(vm); // resolve provide after data/props 4997 callHook(vm, 'created'); 4998 4999 /* istanbul ignore if */ 5000 if (config.performance && mark) { 5001 vm._name = formatComponentName(vm, false); 5002 mark(endTag); 5003 measure(("vue " + (vm._name) + " init"), startTag, endTag); 5004 } 5005 5006 if (vm.$options.el) { 5007 vm.$mount(vm.$options.el); 5008 } 5009 }; 5010 } 5011 5012 function initInternalComponent (vm, options) { 5013 var opts = vm.$options = Object.create(vm.constructor.options); 5014 // doing this because it's faster than dynamic enumeration. 5015 var parentVnode = options._parentVnode; 5016 opts.parent = options.parent; 5017 opts._parentVnode = parentVnode; 5018 5019 var vnodeComponentOptions = parentVnode.componentOptions; 5020 opts.propsData = vnodeComponentOptions.propsData; 5021 opts._parentListeners = vnodeComponentOptions.listeners; 5022 opts._renderChildren = vnodeComponentOptions.children; 5023 opts._componentTag = vnodeComponentOptions.tag; 5024 5025 if (options.render) { 5026 opts.render = options.render; 5027 opts.staticRenderFns = options.staticRenderFns; 5028 } 5029 } 5030 5031 function resolveConstructorOptions (Ctor) { 5032 var options = Ctor.options; 5033 if (Ctor.super) { 5034 var superOptions = resolveConstructorOptions(Ctor.super); 5035 var cachedSuperOptions = Ctor.superOptions; 5036 if (superOptions !== cachedSuperOptions) { 5037 // super option changed, 5038 // need to resolve new options. 5039 Ctor.superOptions = superOptions; 5040 // check if there are any late-modified/attached options (#4976) 5041 var modifiedOptions = resolveModifiedOptions(Ctor); 5042 // update base extend options 5043 if (modifiedOptions) { 5044 extend(Ctor.extendOptions, modifiedOptions); 5045 } 5046 options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions); 5047 if (options.name) { 5048 options.components[options.name] = Ctor; 5049 } 5050 } 5051 } 5052 return options 5053 } 5054 5055 function resolveModifiedOptions (Ctor) { 5056 var modified; 5057 var latest = Ctor.options; 5058 var sealed = Ctor.sealedOptions; 5059 for (var key in latest) { 5060 if (latest[key] !== sealed[key]) { 5061 if (!modified) { modified = {}; } 5062 modified[key] = latest[key]; 5063 } 5064 } 5065 return modified 5066 } 5067 5068 function Vue (options) { 5069 if (!(this instanceof Vue) 5070 ) { 5071 warn('Vue is a constructor and should be called with the `new` keyword'); 5072 } 5073 this._init(options); 5074 } 5075 5076 initMixin(Vue); 5077 stateMixin(Vue); 5078 eventsMixin(Vue); 5079 lifecycleMixin(Vue); 5080 renderMixin(Vue); 5081 5082 /* */ 5083 5084 function initUse (Vue) { 5085 Vue.use = function (plugin) { 5086 var installedPlugins = (this._installedPlugins || (this._installedPlugins = [])); 5087 if (installedPlugins.indexOf(plugin) > -1) { 5088 return this 5089 } 5090 5091 // additional parameters 5092 var args = toArray(arguments, 1); 5093 args.unshift(this); 5094 if (typeof plugin.install === 'function') { 5095 plugin.install.apply(plugin, args); 5096 } else if (typeof plugin === 'function') {
vendor: 2,831 bytes, lines 5097-5184
5097 plugin.apply(null, args); 5098 } 5099 installedPlugins.push(plugin); 5100 return this 5101 }; 5102 } 5103 5104 /* */ 5105 5106 function initMixin$1 (Vue) { 5107 Vue.mixin = function (mixin) { 5108 this.options = mergeOptions(this.options, mixin); 5109 return this 5110 }; 5111 } 5112 5113 /* */ 5114 5115 function initExtend (Vue) { 5116 /** 5117 * Each instance constructor, including Vue, has a unique 5118 * cid. This enables us to create wrapped "child 5119 * constructors" for prototypal inheritance and cache them. 5120 */ 5121 Vue.cid = 0; 5122 var cid = 1; 5123 5124 /** 5125 * Class inheritance 5126 */ 5127 Vue.extend = function (extendOptions) { 5128 extendOptions = extendOptions || {}; 5129 var Super = this; 5130 var SuperId = Super.cid; 5131 var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {}); 5132 if (cachedCtors[SuperId]) { 5133 return cachedCtors[SuperId] 5134 } 5135 5136 var name = extendOptions.name || Super.options.name; 5137 if (name) { 5138 validateComponentName(name); 5139 } 5140 5141 var Sub = function VueComponent (options) { 5142 this._init(options); 5143 }; 5144 Sub.prototype = Object.create(Super.prototype); 5145 Sub.prototype.constructor = Sub; 5146 Sub.cid = cid++; 5147 Sub.options = mergeOptions( 5148 Super.options, 5149 extendOptions 5150 ); 5151 Sub['super'] = Super; 5152 5153 // For props and computed properties, we define the proxy getters on 5154 // the Vue instances at extension time, on the extended prototype. This 5155 // avoids Object.defineProperty calls for each instance created. 5156 if (Sub.options.props) { 5157 initProps$1(Sub); 5158 } 5159 if (Sub.options.computed) { 5160 initComputed$1(Sub); 5161 } 5162 5163 // allow further extension/mixin/plugin usage 5164 Sub.extend = Super.extend; 5165 Sub.mixin = Super.mixin; 5166 Sub.use = Super.use; 5167 5168 // create asset registers, so extended classes 5169 // can have their private assets too. 5170 ASSET_TYPES.forEach(function (type) { 5171 Sub[type] = Super[type]; 5172 }); 5173 // enable recursive self-lookup 5174 if (name) { 5175 Sub.options.components[name] = Sub; 5176 } 5177 5178 // keep a reference to the super options at extension time. 5179 // later at instantiation we can check if Super's options have 5180 // been updated. 5181 Sub.superOptions = Super.options; 5182 Sub.extendOptions = extendOptions; 5183 Sub.sealedOptions = extend({}, Sub.options); 5184
vendor: 22,010 bytes, lines 5185-5904
5185 // cache constructor 5186 cachedCtors[SuperId] = Sub; 5187 return Sub 5188 }; 5189 } 5190 5191 function initProps$1 (Comp) { 5192 var props = Comp.options.props; 5193 for (var key in props) { 5194 proxy(Comp.prototype, "_props", key); 5195 } 5196 } 5197 5198 function initComputed$1 (Comp) { 5199 var computed = Comp.options.computed; 5200 for (var key in computed) { 5201 defineComputed(Comp.prototype, key, computed[key]); 5202 } 5203 } 5204 5205 /* */ 5206 5207 function initAssetRegisters (Vue) { 5208 /** 5209 * Create asset registration methods. 5210 */ 5211 ASSET_TYPES.forEach(function (type) { 5212 Vue[type] = function ( 5213 id, 5214 definition 5215 ) { 5216 if (!definition) { 5217 return this.options[type + 's'][id] 5218 } else { 5219 /* istanbul ignore if */ 5220 if (type === 'component') { 5221 validateComponentName(id); 5222 } 5223 if (type === 'component' && isPlainObject(definition)) { 5224 definition.name = definition.name || id; 5225 definition = this.options._base.extend(definition); 5226 } 5227 if (type === 'directive' && typeof definition === 'function') { 5228 definition = { bind: definition, update: definition }; 5229 } 5230 this.options[type + 's'][id] = definition; 5231 return definition 5232 } 5233 }; 5234 }); 5235 } 5236 5237 /* */ 5238 5239 5240 5241 function getComponentName (opts) { 5242 return opts && (opts.Ctor.options.name || opts.tag) 5243 } 5244 5245 function matches (pattern, name) { 5246 if (Array.isArray(pattern)) { 5247 return pattern.indexOf(name) > -1 5248 } else if (typeof pattern === 'string') { 5249 return pattern.split(',').indexOf(name) > -1 5250 } else if (isRegExp(pattern)) { 5251 return pattern.test(name) 5252 } 5253 /* istanbul ignore next */ 5254 return false 5255 } 5256 5257 function pruneCache (keepAliveInstance, filter) { 5258 var cache = keepAliveInstance.cache; 5259 var keys = keepAliveInstance.keys; 5260 var _vnode = keepAliveInstance._vnode; 5261 for (var key in cache) { 5262 var cachedNode = cache[key]; 5263 if (cachedNode) { 5264 var name = getComponentName(cachedNode.componentOptions); 5265 if (name && !filter(name)) { 5266 pruneCacheEntry(cache, key, keys, _vnode); 5267 } 5268 } 5269 } 5270 } 5271 5272 function pruneCacheEntry ( 5273 cache, 5274 key, 5275 keys, 5276 current 5277 ) { 5278 var cached$$1 = cache[key]; 5279 if (cached$$1 && (!current || cached$$1.tag !== current.tag)) { 5280 cached$$1.componentInstance.$destroy(); 5281 } 5282 cache[key] = null; 5283 remove(keys, key); 5284 } 5285 5286 var patternTypes = [String, RegExp, Array]; 5287 5288 var KeepAlive = { 5289 name: 'keep-alive', 5290 abstract: true, 5291 5292 props: { 5293 include: patternTypes, 5294 exclude: patternTypes, 5295 max: [String, Number] 5296 }, 5297 5298 created: function created () { 5299 this.cache = Object.create(null); 5300 this.keys = []; 5301 }, 5302 5303 destroyed: function destroyed () { 5304 for (var key in this.cache) { 5305 pruneCacheEntry(this.cache, key, this.keys); 5306 } 5307 }, 5308 5309 mounted: function mounted () { 5310 var this$1 = this; 5311 5312 this.$watch('include', function (val) { 5313 pruneCache(this$1, function (name) { return matches(val, name); }); 5314 }); 5315 this.$watch('exclude', function (val) { 5316 pruneCache(this$1, function (name) { return !matches(val, name); }); 5317 }); 5318 }, 5319 5320 render: function render () { 5321 var slot = this.$slots.default; 5322 var vnode = getFirstComponentChild(slot); 5323 var componentOptions = vnode && vnode.componentOptions; 5324 if (componentOptions) { 5325 // check pattern 5326 var name = getComponentName(componentOptions); 5327 var ref = this; 5328 var include = ref.include; 5329 var exclude = ref.exclude; 5330 if ( 5331 // not included 5332 (include && (!name || !matches(include, name))) || 5333 // excluded 5334 (exclude && name && matches(exclude, name)) 5335 ) { 5336 return vnode 5337 } 5338 5339 var ref$1 = this; 5340 var cache = ref$1.cache; 5341 var keys = ref$1.keys; 5342 var key = vnode.key == null 5343 // same constructor may get registered as different local components 5344 // so cid alone is not enough (#3269) 5345 ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '') 5346 : vnode.key; 5347 if (cache[key]) { 5348 vnode.componentInstance = cache[key].componentInstance; 5349 // make current key freshest 5350 remove(keys, key); 5351 keys.push(key); 5352 } else { 5353 cache[key] = vnode; 5354 keys.push(key); 5355 // prune oldest entry 5356 if (this.max && keys.length > parseInt(this.max)) { 5357 pruneCacheEntry(cache, keys[0], keys, this._vnode); 5358 } 5359 } 5360 5361 vnode.data.keepAlive = true; 5362 } 5363 return vnode || (slot && slot[0]) 5364 } 5365 }; 5366 5367 var builtInComponents = { 5368 KeepAlive: KeepAlive 5369 }; 5370 5371 /* */ 5372 5373 function initGlobalAPI (Vue) { 5374 // config 5375 var configDef = {}; 5376 configDef.get = function () { return config; }; 5377 { 5378 configDef.set = function () { 5379 warn( 5380 'Do not replace the Vue.config object, set individual fields instead.' 5381 ); 5382 }; 5383 } 5384 Object.defineProperty(Vue, 'config', configDef); 5385 5386 // exposed util methods. 5387 // NOTE: these are not considered part of the public API - avoid relying on 5388 // them unless you are aware of the risk. 5389 Vue.util = { 5390 warn: warn, 5391 extend: extend, 5392 mergeOptions: mergeOptions, 5393 defineReactive: defineReactive$$1 5394 }; 5395 5396 Vue.set = set; 5397 Vue.delete = del; 5398 Vue.nextTick = nextTick; 5399 5400 // 2.6 explicit observable API 5401 Vue.observable = function (obj) { 5402 observe(obj); 5403 return obj 5404 }; 5405 5406 Vue.options = Object.create(null); 5407 ASSET_TYPES.forEach(function (type) { 5408 Vue.options[type + 's'] = Object.create(null); 5409 }); 5410 5411 // this is used to identify the "base" constructor to extend all plain-object 5412 // components with in Weex's multi-instance scenarios. 5413 Vue.options._base = Vue; 5414 5415 extend(Vue.options.components, builtInComponents); 5416 5417 initUse(Vue); 5418 initMixin$1(Vue); 5419 initExtend(Vue); 5420 initAssetRegisters(Vue); 5421 } 5422 5423 initGlobalAPI(Vue); 5424 5425 Object.defineProperty(Vue.prototype, '$isServer', { 5426 get: isServerRendering 5427 }); 5428 5429 Object.defineProperty(Vue.prototype, '$ssrContext', { 5430 get: function get () { 5431 /* istanbul ignore next */ 5432 return this.$vnode && this.$vnode.ssrContext 5433 } 5434 }); 5435 5436 // expose FunctionalRenderContext for ssr runtime helper installation 5437 Object.defineProperty(Vue, 'FunctionalRenderContext', { 5438 value: FunctionalRenderContext 5439 }); 5440 5441 Vue.version = '2.6.10'; 5442 5443 /* */ 5444 5445 // these are reserved for web because they are directly compiled away 5446 // during template compilation 5447 var isReservedAttr = makeMap('style,class'); 5448 5449 // attributes that should be using props for binding 5450 var acceptValue = makeMap('input,textarea,option,select,progress'); 5451 var mustUseProp = function (tag, type, attr) { 5452 return ( 5453 (attr === 'value' && acceptValue(tag)) && type !== 'button' || 5454 (attr === 'selected' && tag === 'option') || 5455 (attr === 'checked' && tag === 'input') || 5456 (attr === 'muted' && tag === 'video') 5457 ) 5458 }; 5459 5460 var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck'); 5461 5462 var isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only'); 5463 5464 var convertEnumeratedValue = function (key, value) { 5465 return isFalsyAttrValue(value) || value === 'false' 5466 ? 'false' 5467 // allow arbitrary string value for contenteditable 5468 : key === 'contenteditable' && isValidContentEditableValue(value) 5469 ? value 5470 : 'true' 5471 }; 5472 5473 var isBooleanAttr = makeMap( 5474 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' + 5475 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + 5476 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + 5477 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + 5478 'required,reversed,scoped,seamless,selected,sortable,translate,' + 5479 'truespeed,typemustmatch,visible' 5480 ); 5481 5482 var xlinkNS = 'http://www.w3.org/1999/xlink'; 5483 5484 var isXlink = function (name) { 5485 return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink' 5486 }; 5487 5488 var getXlinkProp = function (name) { 5489 return isXlink(name) ? name.slice(6, name.length) : '' 5490 }; 5491 5492 var isFalsyAttrValue = function (val) { 5493 return val == null || val === false 5494 }; 5495 5496 /* */ 5497 5498 function genClassForVnode (vnode) { 5499 var data = vnode.data; 5500 var parentNode = vnode; 5501 var childNode = vnode; 5502 while (isDef(childNode.componentInstance)) { 5503 childNode = childNode.componentInstance._vnode; 5504 if (childNode && childNode.data) { 5505 data = mergeClassData(childNode.data, data); 5506 } 5507 } 5508 while (isDef(parentNode = parentNode.parent)) { 5509 if (parentNode && parentNode.data) { 5510 data = mergeClassData(data, parentNode.data); 5511 } 5512 } 5513 return renderClass(data.staticClass, data.class) 5514 } 5515 5516 function mergeClassData (child, parent) { 5517 return { 5518 staticClass: concat(child.staticClass, parent.staticClass), 5519 class: isDef(child.class) 5520 ? [child.class, parent.class] 5521 : parent.class 5522 } 5523 } 5524 5525 function renderClass ( 5526 staticClass, 5527 dynamicClass 5528 ) { 5529 if (isDef(staticClass) || isDef(dynamicClass)) { 5530 return concat(staticClass, stringifyClass(dynamicClass)) 5531 } 5532 /* istanbul ignore next */ 5533 return '' 5534 } 5535 5536 function concat (a, b) { 5537 return a ? b ? (a + ' ' + b) : a : (b || '') 5538 } 5539 5540 function stringifyClass (value) { 5541 if (Array.isArray(value)) { 5542 return stringifyArray(value) 5543 } 5544 if (isObject(value)) { 5545 return stringifyObject(value) 5546 } 5547 if (typeof value === 'string') { 5548 return value 5549 } 5550 /* istanbul ignore next */ 5551 return '' 5552 } 5553 5554 function stringifyArray (value) { 5555 var res = ''; 5556 var stringified; 5557 for (var i = 0, l = value.length; i < l; i++) { 5558 if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') { 5559 if (res) { res += ' '; } 5560 res += stringified; 5561 } 5562 } 5563 return res 5564 } 5565 5566 function stringifyObject (value) { 5567 var res = ''; 5568 for (var key in value) { 5569 if (value[key]) { 5570 if (res) { res += ' '; } 5571 res += key; 5572 } 5573 } 5574 return res 5575 } 5576 5577 /* */ 5578 5579 var namespaceMap = { 5580 svg: 'http://www.w3.org/2000/svg', 5581 math: 'http://www.w3.org/1998/Math/MathML' 5582 }; 5583 5584 var isHTMLTag = makeMap( 5585 'html,body,base,head,link,meta,style,title,' + 5586 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + 5587 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' + 5588 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' + 5589 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' + 5590 'embed,object,param,source,canvas,script,noscript,del,ins,' + 5591 'caption,col,colgroup,table,thead,tbody,td,th,tr,' + 5592 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + 5593 'output,progress,select,textarea,' + 5594 'details,dialog,menu,menuitem,summary,' + 5595 'content,element,shadow,template,blockquote,iframe,tfoot' 5596 ); 5597 5598 // this map is intentionally selective, only covering SVG elements that may 5599 // contain child elements. 5600 var isSVG = makeMap( 5601 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' + 5602 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + 5603 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', 5604 true 5605 ); 5606 5607 var isPreTag = function (tag) { return tag === 'pre'; }; 5608 5609 var isReservedTag = function (tag) { 5610 return isHTMLTag(tag) || isSVG(tag) 5611 }; 5612 5613 function getTagNamespace (tag) { 5614 if (isSVG(tag)) { 5615 return 'svg' 5616 } 5617 // basic support for MathML 5618 // note it doesn't support other MathML elements being component roots 5619 if (tag === 'math') { 5620 return 'math' 5621 } 5622 } 5623 5624 var unknownElementCache = Object.create(null); 5625 function isUnknownElement (tag) { 5626 /* istanbul ignore if */ 5627 if (!inBrowser) { 5628 return true 5629 } 5630 if (isReservedTag(tag)) { 5631 return false 5632 } 5633 tag = tag.toLowerCase(); 5634 /* istanbul ignore if */ 5635 if (unknownElementCache[tag] != null) { 5636 return unknownElementCache[tag] 5637 } 5638 var el = document.createElement(tag); 5639 if (tag.indexOf('-') > -1) { 5640 // http://stackoverflow.com/a/28210364/1070244 5641 return (unknownElementCache[tag] = ( 5642 el.constructor === window.HTMLUnknownElement || 5643 el.constructor === window.HTMLElement 5644 )) 5645 } else { 5646 return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString())) 5647 } 5648 } 5649 5650 var isTextInputType = makeMap('text,number,password,search,email,tel,url'); 5651 5652 /* */ 5653 5654 /** 5655 * Query an element selector if it's not an element already. 5656 */ 5657 function query (el) { 5658 if (typeof el === 'string') { 5659 var selected = document.querySelector(el); 5660 if (!selected) { 5661 warn( 5662 'Cannot find element: ' + el 5663 ); 5664 return document.createElement('div') 5665 } 5666 return selected 5667 } else { 5668 return el 5669 } 5670 } 5671 5672 /* */ 5673 5674 function createElement$1 (tagName, vnode) { 5675 var elm = document.createElement(tagName); 5676 if (tagName !== 'select') { 5677 return elm 5678 } 5679 // false or null will remove the attribute but undefined will not 5680 if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) { 5681 elm.setAttribute('multiple', 'multiple'); 5682 } 5683 return elm 5684 } 5685 5686 function createElementNS (namespace, tagName) { 5687 return document.createElementNS(namespaceMap[namespace], tagName) 5688 } 5689 5690 function createTextNode (text) { 5691 return document.createTextNode(text) 5692 } 5693 5694 function createComment (text) { 5695 return document.createComment(text) 5696 } 5697 5698 function insertBefore (parentNode, newNode, referenceNode) { 5699 parentNode.insertBefore(newNode, referenceNode); 5700 } 5701 5702 function removeChild (node, child) { 5703 node.removeChild(child); 5704 } 5705 5706 function appendChild (node, child) { 5707 node.appendChild(child); 5708 } 5709 5710 function parentNode (node) { 5711 return node.parentNode 5712 } 5713 5714 function nextSibling (node) { 5715 return node.nextSibling 5716 } 5717 5718 function tagName (node) { 5719 return node.tagName 5720 } 5721 5722 function setTextContent (node, text) { 5723 node.textContent = text; 5724 } 5725 5726 function setStyleScope (node, scopeId) { 5727 node.setAttribute(scopeId, ''); 5728 } 5729 5730 var nodeOps = /*#__PURE__*/Object.freeze({ 5731 createElement: createElement$1, 5732 createElementNS: createElementNS, 5733 createTextNode: createTextNode, 5734 createComment: createComment, 5735 insertBefore: insertBefore, 5736 removeChild: removeChild, 5737 appendChild: appendChild, 5738 parentNode: parentNode, 5739 nextSibling: nextSibling, 5740 tagName: tagName, 5741 setTextContent: setTextContent, 5742 setStyleScope: setStyleScope 5743 }); 5744 5745 /* */ 5746 5747 var ref = { 5748 create: function create (_, vnode) { 5749 registerRef(vnode); 5750 }, 5751 update: function update (oldVnode, vnode) { 5752 if (oldVnode.data.ref !== vnode.data.ref) { 5753 registerRef(oldVnode, true); 5754 registerRef(vnode); 5755 } 5756 }, 5757 destroy: function destroy (vnode) { 5758 registerRef(vnode, true); 5759 } 5760 }; 5761 5762 function registerRef (vnode, isRemoval) { 5763 var key = vnode.data.ref; 5764 if (!isDef(key)) { return } 5765 5766 var vm = vnode.context; 5767 var ref = vnode.componentInstance || vnode.elm; 5768 var refs = vm.$refs; 5769 if (isRemoval) { 5770 if (Array.isArray(refs[key])) { 5771 remove(refs[key], ref); 5772 } else if (refs[key] === ref) { 5773 refs[key] = undefined; 5774 } 5775 } else { 5776 if (vnode.data.refInFor) { 5777 if (!Array.isArray(refs[key])) { 5778 refs[key] = [ref]; 5779 } else if (refs[key].indexOf(ref) < 0) { 5780 // $flow-disable-line 5781 refs[key].push(ref); 5782 } 5783 } else { 5784 refs[key] = ref; 5785 } 5786 } 5787 } 5788 5789 /** 5790 * Virtual DOM patching algorithm based on Snabbdom by 5791 * Simon Friis Vindum (@paldepind) 5792 * Licensed under the MIT License 5793 * https://github.com/paldepind/snabbdom/blob/master/LICENSE 5794 * 5795 * modified by Evan You (@yyx990803) 5796 * 5797 * Not type-checking this because this file is perf-critical and the cost 5798 * of making flow understand it is not worth it. 5799 */ 5800 5801 var emptyNode = new VNode('', {}, []); 5802 5803 var hooks = ['create', 'activate', 'update', 'remove', 'destroy']; 5804 5805 function sameVnode (a, b) { 5806 return ( 5807 a.key === b.key && ( 5808 ( 5809 a.tag === b.tag && 5810 a.isComment === b.isComment && 5811 isDef(a.data) === isDef(b.data) && 5812 sameInputType(a, b) 5813 ) || ( 5814 isTrue(a.isAsyncPlaceholder) && 5815 a.asyncFactory === b.asyncFactory && 5816 isUndef(b.asyncFactory.error) 5817 ) 5818 ) 5819 ) 5820 } 5821 5822 function sameInputType (a, b) { 5823 if (a.tag !== 'input') { return true } 5824 var i; 5825 var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type; 5826 var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type; 5827 return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB) 5828 } 5829 5830 function createKeyToOldIdx (children, beginIdx, endIdx) { 5831 var i, key; 5832 var map = {}; 5833 for (i = beginIdx; i <= endIdx; ++i) { 5834 key = children[i].key; 5835 if (isDef(key)) { map[key] = i; } 5836 } 5837 return map 5838 } 5839 5840 function createPatchFunction (backend) { 5841 var i, j; 5842 var cbs = {}; 5843 5844 var modules = backend.modules; 5845 var nodeOps = backend.nodeOps; 5846 5847 for (i = 0; i < hooks.length; ++i) { 5848 cbs[hooks[i]] = []; 5849 for (j = 0; j < modules.length; ++j) { 5850 if (isDef(modules[j][hooks[i]])) { 5851 cbs[hooks[i]].push(modules[j][hooks[i]]); 5852 } 5853 } 5854 } 5855 5856 function emptyNodeAt (elm) { 5857 return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm) 5858 } 5859 5860 function createRmCb (childElm, listeners) { 5861 function remove$$1 () { 5862 if (--remove$$1.listeners === 0) { 5863 removeNode(childElm); 5864 } 5865 } 5866 remove$$1.listeners = listeners; 5867 return remove$$1 5868 } 5869 5870 function removeNode (el) { 5871 var parent = nodeOps.parentNode(el); 5872 // element may have already been removed due to v-html / v-text 5873 if (isDef(parent)) { 5874 nodeOps.removeChild(parent, el); 5875 } 5876 } 5877 5878 function isUnknownElement$$1 (vnode, inVPre) { 5879 return ( 5880 !inVPre && 5881 !vnode.ns && 5882 !( 5883 config.ignoredElements.length && 5884 config.ignoredElements.some(function (ignore) { 5885 return isRegExp(ignore) 5886 ? ignore.test(vnode.tag) 5887 : ignore === vnode.tag 5888 }) 5889 ) && 5890 config.isUnknownElement(vnode.tag) 5891 ) 5892 } 5893 5894 var creatingElmInVPre = 0; 5895 5896 function createElm ( 5897 vnode, 5898 insertedVnodeQueue, 5899 parentElm, 5900 refElm, 5901 nested, 5902 ownerArray, 5903 index 5904 ) {
5905 if (isDef(vnode.elm) && isDef(ownerArray)) { 5906 // This vnode was used in a previous render! 5907 // now it's used as a new node, overwriting its elm would cause 5908 // potential patch errors down the road when it's used as an insertion 5909 // reference node. Instead, we clone the node on-demand before creating 5910 // associated DOM element for it. 5911 vnode = ownerArray[index] = cloneVNode(vnode); 5912 } 5913 5914 vnode.isRootInsert = !nested; // for transition enter check 5915 if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) { 5916 return 5917 } 5918 5919 var data = vnode.data; 5920 var children = vnode.children; 5921 var tag = vnode.tag; 5922 if (isDef(tag)) { 5923 { 5924 if (data && data.pre) { 5925 creatingElmInVPre++; 5926 } 5927 if (isUnknownElement$$1(vnode, creatingElmInVPre)) { 5928 warn( 5929 'Unknown custom element: <' + tag + '> - did you ' + 5930 'register the component correctly? For recursive components, ' + 5931 'make sure to provide the "name" option.', 5932 vnode.context 5933 ); 5934 } 5935 } 5936 5937 vnode.elm = vnode.ns 5938 ? nodeOps.createElementNS(vnode.ns, tag) 5939 : nodeOps.createElement(tag, vnode); 5940 setScope(vnode); 5941 5942 /* istanbul ignore if */ 5943 { 5944 createChildren(vnode, children, insertedVnodeQueue); 5945 if (isDef(data)) { 5946 invokeCreateHooks(vnode, insertedVnodeQueue); 5947 } 5948 insert(parentElm, vnode.elm, refElm); 5949 } 5950 5951 if (data && data.pre) { 5952 creatingElmInVPre--; 5953 } 5954 } else if (isTrue(vnode.isComment)) { 5955 vnode.elm = nodeOps.createComment(vnode.text); 5956 insert(parentElm, vnode.elm, refElm); 5957 } else { 5958 vnode.elm = nodeOps.createTextNode(vnode.text); 5959 insert(parentElm, vnode.elm, refElm); 5960 } 5961 } 5962 5963 function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) { 5964 var i = vnode.data; 5965 if (isDef(i)) { 5966 var isReactivated = isDef(vnode.componentInstance) && i.keepAlive; 5967 if (isDef(i = i.hook) && isDef(i = i.init)) { 5968 i(vnode, false /* hydrating */); 5969 } 5970 // after calling the init hook, if the vnode is a child component 5971 // it should've created a child instance and mounted it. the child 5972 // component also has set the placeholder vnode's elm. 5973 // in that case we can just return the element and be done.
vendor: 11,353 bytes, lines 5974-6223
5974 if (isDef(vnode.componentInstance)) { 5975 initComponent(vnode, insertedVnodeQueue); 5976 insert(parentElm, vnode.elm, refElm); 5977 if (isTrue(isReactivated)) { 5978 reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm); 5979 } 5980 return true 5981 } 5982 } 5983 } 5984 5985 function initComponent (vnode, insertedVnodeQueue) { 5986 if (isDef(vnode.data.pendingInsert)) { 5987 insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert); 5988 vnode.data.pendingInsert = null; 5989 } 5990 vnode.elm = vnode.componentInstance.$el; 5991 if (isPatchable(vnode)) { 5992 invokeCreateHooks(vnode, insertedVnodeQueue); 5993 setScope(vnode); 5994 } else { 5995 // empty component root. 5996 // skip all element-related modules except for ref (#3455) 5997 registerRef(vnode); 5998 // make sure to invoke the insert hook 5999 insertedVnodeQueue.push(vnode); 6000 } 6001 } 6002 6003 function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) { 6004 var i; 6005 // hack for #4339: a reactivated component with inner transition 6006 // does not trigger because the inner node's created hooks are not called 6007 // again. It's not ideal to involve module-specific logic in here but 6008 // there doesn't seem to be a better way to do it. 6009 var innerNode = vnode; 6010 while (innerNode.componentInstance) { 6011 innerNode = innerNode.componentInstance._vnode; 6012 if (isDef(i = innerNode.data) && isDef(i = i.transition)) { 6013 for (i = 0; i < cbs.activate.length; ++i) { 6014 cbs.activate[i](emptyNode, innerNode); 6015 } 6016 insertedVnodeQueue.push(innerNode); 6017 break 6018 } 6019 } 6020 // unlike a newly created component, 6021 // a reactivated keep-alive component doesn't insert itself 6022 insert(parentElm, vnode.elm, refElm); 6023 } 6024 6025 function insert (parent, elm, ref$$1) { 6026 if (isDef(parent)) { 6027 if (isDef(ref$$1)) { 6028 if (nodeOps.parentNode(ref$$1) === parent) { 6029 nodeOps.insertBefore(parent, elm, ref$$1); 6030 } 6031 } else { 6032 nodeOps.appendChild(parent, elm); 6033 } 6034 } 6035 } 6036 6037 function createChildren (vnode, children, insertedVnodeQueue) { 6038 if (Array.isArray(children)) { 6039 { 6040 checkDuplicateKeys(children); 6041 } 6042 for (var i = 0; i < children.length; ++i) { 6043 createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i); 6044 } 6045 } else if (isPrimitive(vnode.text)) { 6046 nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text))); 6047 } 6048 } 6049 6050 function isPatchable (vnode) { 6051 while (vnode.componentInstance) { 6052 vnode = vnode.componentInstance._vnode; 6053 } 6054 return isDef(vnode.tag) 6055 } 6056 6057 function invokeCreateHooks (vnode, insertedVnodeQueue) { 6058 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) { 6059 cbs.create[i$1](emptyNode, vnode); 6060 } 6061 i = vnode.data.hook; // Reuse variable 6062 if (isDef(i)) { 6063 if (isDef(i.create)) { i.create(emptyNode, vnode); } 6064 if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); } 6065 } 6066 } 6067 6068 // set scope id attribute for scoped CSS. 6069 // this is implemented as a special case to avoid the overhead 6070 // of going through the normal attribute patching process. 6071 function setScope (vnode) { 6072 var i; 6073 if (isDef(i = vnode.fnScopeId)) { 6074 nodeOps.setStyleScope(vnode.elm, i); 6075 } else { 6076 var ancestor = vnode; 6077 while (ancestor) { 6078 if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) { 6079 nodeOps.setStyleScope(vnode.elm, i); 6080 } 6081 ancestor = ancestor.parent; 6082 } 6083 } 6084 // for slot content they should also get the scopeId from the host instance. 6085 if (isDef(i = activeInstance) && 6086 i !== vnode.context && 6087 i !== vnode.fnContext && 6088 isDef(i = i.$options._scopeId) 6089 ) { 6090 nodeOps.setStyleScope(vnode.elm, i); 6091 } 6092 } 6093 6094 function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) { 6095 for (; startIdx <= endIdx; ++startIdx) { 6096 createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx); 6097 } 6098 } 6099 6100 function invokeDestroyHook (vnode) { 6101 var i, j; 6102 var data = vnode.data; 6103 if (isDef(data)) { 6104 if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); } 6105 for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); } 6106 } 6107 if (isDef(i = vnode.children)) { 6108 for (j = 0; j < vnode.children.length; ++j) { 6109 invokeDestroyHook(vnode.children[j]); 6110 } 6111 } 6112 } 6113 6114 function removeVnodes (parentElm, vnodes, startIdx, endIdx) { 6115 for (; startIdx <= endIdx; ++startIdx) { 6116 var ch = vnodes[startIdx]; 6117 if (isDef(ch)) { 6118 if (isDef(ch.tag)) { 6119 removeAndInvokeRemoveHook(ch); 6120 invokeDestroyHook(ch); 6121 } else { // Text node 6122 removeNode(ch.elm); 6123 } 6124 } 6125 } 6126 } 6127 6128 function removeAndInvokeRemoveHook (vnode, rm) { 6129 if (isDef(rm) || isDef(vnode.data)) { 6130 var i; 6131 var listeners = cbs.remove.length + 1; 6132 if (isDef(rm)) { 6133 // we have a recursively passed down rm callback 6134 // increase the listeners count 6135 rm.listeners += listeners; 6136 } else { 6137 // directly removing 6138 rm = createRmCb(vnode.elm, listeners); 6139 } 6140 // recursively invoke hooks on child component root node 6141 if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) { 6142 removeAndInvokeRemoveHook(i, rm); 6143 } 6144 for (i = 0; i < cbs.remove.length; ++i) { 6145 cbs.remove[i](vnode, rm); 6146 } 6147 if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) { 6148 i(vnode, rm); 6149 } else { 6150 rm(); 6151 } 6152 } else { 6153 removeNode(vnode.elm); 6154 } 6155 } 6156 6157 function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) { 6158 var oldStartIdx = 0; 6159 var newStartIdx = 0; 6160 var oldEndIdx = oldCh.length - 1; 6161 var oldStartVnode = oldCh[0]; 6162 var oldEndVnode = oldCh[oldEndIdx]; 6163 var newEndIdx = newCh.length - 1; 6164 var newStartVnode = newCh[0]; 6165 var newEndVnode = newCh[newEndIdx]; 6166 var oldKeyToIdx, idxInOld, vnodeToMove, refElm; 6167 6168 // removeOnly is a special flag used only by <transition-group> 6169 // to ensure removed elements stay in correct relative positions 6170 // during leaving transitions 6171 var canMove = !removeOnly; 6172 6173 { 6174 checkDuplicateKeys(newCh); 6175 } 6176 6177 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) { 6178 if (isUndef(oldStartVnode)) { 6179 oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left 6180 } else if (isUndef(oldEndVnode)) { 6181 oldEndVnode = oldCh[--oldEndIdx]; 6182 } else if (sameVnode(oldStartVnode, newStartVnode)) { 6183 patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx); 6184 oldStartVnode = oldCh[++oldStartIdx]; 6185 newStartVnode = newCh[++newStartIdx]; 6186 } else if (sameVnode(oldEndVnode, newEndVnode)) { 6187 patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx); 6188 oldEndVnode = oldCh[--oldEndIdx]; 6189 newEndVnode = newCh[--newEndIdx]; 6190 } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right 6191 patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx); 6192 canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm)); 6193 oldStartVnode = oldCh[++oldStartIdx]; 6194 newEndVnode = newCh[--newEndIdx]; 6195 } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left 6196 patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx); 6197 canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm); 6198 oldEndVnode = oldCh[--oldEndIdx]; 6199 newStartVnode = newCh[++newStartIdx]; 6200 } else { 6201 if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); } 6202 idxInOld = isDef(newStartVnode.key) 6203 ? oldKeyToIdx[newStartVnode.key] 6204 : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx); 6205 if (isUndef(idxInOld)) { // New element 6206 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); 6207 } else { 6208 vnodeToMove = oldCh[idxInOld]; 6209 if (sameVnode(vnodeToMove, newStartVnode)) { 6210 patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx); 6211 oldCh[idxInOld] = undefined; 6212 canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm); 6213 } else { 6214 // same key but different element. treat as new element 6215 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); 6216 } 6217 } 6218 newStartVnode = newCh[++newStartIdx]; 6219 } 6220 } 6221 if (oldStartIdx > oldEndIdx) { 6222 refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm; 6223 addVnodes(parentElm, refElm, newCh, newStartIdx, newEnd
6223Idx, insertedVnodeQueue); 6224 } else if (newStartIdx > newEndIdx) { 6225 removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx); 6226 } 6227 } 6228 6229 function checkDuplicateKeys (children) { 6230 var seenKeys = {}; 6231 for (var i = 0; i < children.length; i++) { 6232 var vnode = children[i]; 6233 var key = vnode.key; 6234 if (isDef(key)) { 6235 if (seenKeys[key]) { 6236 warn( 6237 ("Duplicate keys detected: '" + key + "'. This may cause an update error."), 6238 vnode.context 6239 ); 6240 } else { 6241 seenKeys[key] = true; 6242 } 6243 } 6244 } 6245 } 6246 6247 function findIdxInOld (node, oldCh, start, end) { 6248 for (var i = start; i < end; i++) { 6249 var c = oldCh[i]; 6250 if (isDef(c) && sameVnode(node, c)) { return i } 6251 } 6252 } 6253 6254 function patchVnode ( 6255 oldVnode, 6256 vnode, 6257 insertedVnodeQueue, 6258 ownerArray, 6259 index, 6260 removeOnly 6261 ) { 6262 if (oldVnode === vnode) { 6263 return 6264 } 6265
vendor: 11,600 bytes, lines 6266-6514
6266 if (isDef(vnode.elm) && isDef(ownerArray)) { 6267 // clone reused vnode 6268 vnode = ownerArray[index] = cloneVNode(vnode); 6269 } 6270 6271 var elm = vnode.elm = oldVnode.elm; 6272 6273 if (isTrue(oldVnode.isAsyncPlaceholder)) { 6274 if (isDef(vnode.asyncFactory.resolved)) { 6275 hydrate(oldVnode.elm, vnode, insertedVnodeQueue); 6276 } else { 6277 vnode.isAsyncPlaceholder = true; 6278 } 6279 return 6280 } 6281 6282 // reuse element for static trees. 6283 // note we only do this if the vnode is cloned - 6284 // if the new node is not cloned it means the render functions have been 6285 // reset by the hot-reload-api and we need to do a proper re-render. 6286 if (isTrue(vnode.isStatic) && 6287 isTrue(oldVnode.isStatic) && 6288 vnode.key === oldVnode.key && 6289 (isTrue(vnode.isCloned) || isTrue(vnode.isOnce)) 6290 ) { 6291 vnode.componentInstance = oldVnode.componentInstance; 6292 return 6293 } 6294 6295 var i; 6296 var data = vnode.data; 6297 if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) { 6298 i(oldVnode, vnode); 6299 } 6300 6301 var oldCh = oldVnode.children; 6302 var ch = vnode.children; 6303 if (isDef(data) && isPatchable(vnode)) { 6304 for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); } 6305 if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); } 6306 } 6307 if (isUndef(vnode.text)) { 6308 if (isDef(oldCh) && isDef(ch)) { 6309 if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); } 6310 } else if (isDef(ch)) { 6311 { 6312 checkDuplicateKeys(ch); 6313 } 6314 if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); } 6315 addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue); 6316 } else if (isDef(oldCh)) { 6317 removeVnodes(elm, oldCh, 0, oldCh.length - 1); 6318 } else if (isDef(oldVnode.text)) { 6319 nodeOps.setTextContent(elm, ''); 6320 } 6321 } else if (oldVnode.text !== vnode.text) { 6322 nodeOps.setTextContent(elm, vnode.text); 6323 } 6324 if (isDef(data)) { 6325 if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); } 6326 } 6327 } 6328 6329 function invokeInsertHook (vnode, queue, initial) { 6330 // delay insert hooks for component root nodes, invoke them after the 6331 // element is really inserted 6332 if (isTrue(initial) && isDef(vnode.parent)) { 6333 vnode.parent.data.pendingInsert = queue; 6334 } else { 6335 for (var i = 0; i < queue.length; ++i) { 6336 queue[i].data.hook.insert(queue[i]); 6337 } 6338 } 6339 } 6340 6341 var hydrationBailed = false; 6342 // list of modules that can skip create hook during hydration because they 6343 // are already rendered on the client or has no need for initialization 6344 // Note: style is excluded because it relies on initial clone for future 6345 // deep updates (#7063). 6346 var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key'); 6347 6348 // Note: this is a browser-only function so we can assume elms are DOM nodes. 6349 function hydrate (elm, vnode, insertedVnodeQueue, inVPre) { 6350 var i; 6351 var tag = vnode.tag; 6352 var data = vnode.data; 6353 var children = vnode.children; 6354 inVPre = inVPre || (data && data.pre); 6355 vnode.elm = elm; 6356 6357 if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) { 6358 vnode.isAsyncPlaceholder = true; 6359 return true 6360 } 6361 // assert node match 6362 { 6363 if (!assertNodeMatch(elm, vnode, inVPre)) { 6364 return false 6365 } 6366 } 6367 if (isDef(data)) { 6368 if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); } 6369 if (isDef(i = vnode.componentInstance)) { 6370 // child component. it should have hydrated its own tree. 6371 initComponent(vnode, insertedVnodeQueue); 6372 return true 6373 } 6374 } 6375 if (isDef(tag)) { 6376 if (isDef(children)) { 6377 // empty element, allow client to pick up and populate children 6378 if (!elm.hasChildNodes()) { 6379 createChildren(vnode, children, insertedVnodeQueue); 6380 } else { 6381 // v-html and domProps: innerHTML 6382 if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) { 6383 if (i !== elm.innerHTML) { 6384 /* istanbul ignore if */ 6385 if (typeof console !== 'undefined' && 6386 !hydrationBailed 6387 ) { 6388 hydrationBailed = true; 6389 console.warn('Parent: ', elm); 6390 console.warn('server innerHTML: ', i); 6391 console.warn('client innerHTML: ', elm.innerHTML); 6392 } 6393 return false 6394 } 6395 } else { 6396 // iterate and compare children lists 6397 var childrenMatch = true; 6398 var childNode = elm.firstChild; 6399 for (var i$1 = 0; i$1 < children.length; i$1++) { 6400 if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) { 6401 childrenMatch = false; 6402 break 6403 } 6404 childNode = childNode.nextSibling; 6405 } 6406 // if childNode is not null, it means the actual childNodes list is 6407 // longer than the virtual children list. 6408 if (!childrenMatch || childNode) { 6409 /* istanbul ignore if */ 6410 if (typeof console !== 'undefined' && 6411 !hydrationBailed 6412 ) { 6413 hydrationBailed = true; 6414 console.warn('Parent: ', elm); 6415 console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); 6416 } 6417 return false 6418 } 6419 } 6420 } 6421 } 6422 if (isDef(data)) { 6423 var fullInvoke = false; 6424 for (var key in data) { 6425 if (!isRenderedModule(key)) { 6426 fullInvoke = true; 6427 invokeCreateHooks(vnode, insertedVnodeQueue); 6428 break 6429 } 6430 } 6431 if (!fullInvoke && data['class']) { 6432 // ensure collecting deps for deep class bindings for future updates 6433 traverse(data['class']); 6434 } 6435 } 6436 } else if (elm.data !== vnode.text) { 6437 elm.data = vnode.text; 6438 } 6439 return true 6440 } 6441 6442 function assertNodeMatch (node, vnode, inVPre) { 6443 if (isDef(vnode.tag)) { 6444 return vnode.tag.indexOf('vue-component') === 0 || ( 6445 !isUnknownElement$$1(vnode, inVPre) && 6446 vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase()) 6447 ) 6448 } else { 6449 return node.nodeType === (vnode.isComment ? 8 : 3) 6450 } 6451 } 6452 6453 return function patch (oldVnode, vnode, hydrating, removeOnly) { 6454 if (isUndef(vnode)) { 6455 if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); } 6456 return 6457 } 6458 6459 var isInitialPatch = false; 6460 var insertedVnodeQueue = []; 6461 6462 if (isUndef(oldVnode)) { 6463 // empty mount (likely as component), create new root element 6464 isInitialPatch = true; 6465 createElm(vnode, insertedVnodeQueue); 6466 } else { 6467 var isRealElement = isDef(oldVnode.nodeType); 6468 if (!isRealElement && sameVnode(oldVnode, vnode)) { 6469 // patch existing root node 6470 patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly); 6471 } else { 6472 if (isRealElement) { 6473 // mounting to a real element 6474 // check if this is server-rendered content and if we can perform 6475 // a successful hydration. 6476 if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) { 6477 oldVnode.removeAttribute(SSR_ATTR); 6478 hydrating = true; 6479 } 6480 if (isTrue(hydrating)) { 6481 if (hydrate(oldVnode, vnode, insertedVnodeQueue)) { 6482 invokeInsertHook(vnode, insertedVnodeQueue, true); 6483 return oldVnode 6484 } else { 6485 warn( 6486 'The client-side rendered virtual DOM tree is not matching ' + 6487 'server-rendered content. This is likely caused by incorrect ' + 6488 'HTML markup, for example nesting block-level elements inside ' + 6489 '<p>, or missing <tbody>. Bailing hydration and performing ' + 6490 'full client-side render.' 6491 ); 6492 } 6493 } 6494 // either not server-rendered, or hydration failed. 6495 // create an empty node and replace it 6496 oldVnode = emptyNodeAt(oldVnode); 6497 } 6498 6499 // replacing existing element 6500 var oldElm = oldVnode.elm; 6501 var parentElm = nodeOps.parentNode(oldElm); 6502 6503 // create new node 6504 createElm( 6505 vnode, 6506 insertedVnodeQueue, 6507 // extremely rare edge case: do not insert if old element is in a 6508 // leaving transition. Only happens when combining transition + 6509 // keep-alive + HOCs. (#4590) 6510 oldElm._leaveCb ? null : parentElm, 6511 nodeOps.nextSibling(oldElm) 6512 ); 6513 6514 // update parent placeholder node element, recursively
vendor: 7,813 bytes, lines 6515-6735
6515 if (isDef(vnode.parent)) { 6516 var ancestor = vnode.parent; 6517 var patchable = isPatchable(vnode); 6518 while (ancestor) { 6519 for (var i = 0; i < cbs.destroy.length; ++i) { 6520 cbs.destroy[i](ancestor); 6521 } 6522 ancestor.elm = vnode.elm; 6523 if (patchable) { 6524 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) { 6525 cbs.create[i$1](emptyNode, ancestor); 6526 } 6527 // #6513 6528 // invoke insert hooks that may have been merged by create hooks. 6529 // e.g. for directives that uses the "inserted" hook. 6530 var insert = ancestor.data.hook.insert; 6531 if (insert.merged) { 6532 // start at index 1 to avoid re-invoking component mounted hook 6533 for (var i$2 = 1; i$2 < insert.fns.length; i$2++) { 6534 insert.fns[i$2](); 6535 } 6536 } 6537 } else { 6538 registerRef(ancestor); 6539 } 6540 ancestor = ancestor.parent; 6541 } 6542 } 6543 6544 // destroy old node 6545 if (isDef(parentElm)) { 6546 removeVnodes(parentElm, [oldVnode], 0, 0); 6547 } else if (isDef(oldVnode.tag)) { 6548 invokeDestroyHook(oldVnode); 6549 } 6550 } 6551 } 6552 6553 invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch); 6554 return vnode.elm 6555 } 6556 } 6557 6558 /* */ 6559 6560 var directives = { 6561 create: updateDirectives, 6562 update: updateDirectives, 6563 destroy: function unbindDirectives (vnode) { 6564 updateDirectives(vnode, emptyNode); 6565 } 6566 }; 6567 6568 function updateDirectives (oldVnode, vnode) { 6569 if (oldVnode.data.directives || vnode.data.directives) { 6570 _update(oldVnode, vnode); 6571 } 6572 } 6573 6574 function _update (oldVnode, vnode) { 6575 var isCreate = oldVnode === emptyNode; 6576 var isDestroy = vnode === emptyNode; 6577 var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context); 6578 var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context); 6579 6580 var dirsWithInsert = []; 6581 var dirsWithPostpatch = []; 6582 6583 var key, oldDir, dir; 6584 for (key in newDirs) { 6585 oldDir = oldDirs[key]; 6586 dir = newDirs[key]; 6587 if (!oldDir) { 6588 // new directive, bind 6589 callHook$1(dir, 'bind', vnode, oldVnode); 6590 if (dir.def && dir.def.inserted) { 6591 dirsWithInsert.push(dir); 6592 } 6593 } else { 6594 // existing directive, update 6595 dir.oldValue = oldDir.value; 6596 dir.oldArg = oldDir.arg; 6597 callHook$1(dir, 'update', vnode, oldVnode); 6598 if (dir.def && dir.def.componentUpdated) { 6599 dirsWithPostpatch.push(dir); 6600 } 6601 } 6602 } 6603 6604 if (dirsWithInsert.length) { 6605 var callInsert = function () { 6606 for (var i = 0; i < dirsWithInsert.length; i++) { 6607 callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode); 6608 } 6609 }; 6610 if (isCreate) { 6611 mergeVNodeHook(vnode, 'insert', callInsert); 6612 } else { 6613 callInsert(); 6614 } 6615 } 6616 6617 if (dirsWithPostpatch.length) { 6618 mergeVNodeHook(vnode, 'postpatch', function () { 6619 for (var i = 0; i < dirsWithPostpatch.length; i++) { 6620 callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode); 6621 } 6622 }); 6623 } 6624 6625 if (!isCreate) { 6626 for (key in oldDirs) { 6627 if (!newDirs[key]) { 6628 // no longer present, unbind 6629 callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy); 6630 } 6631 } 6632 } 6633 } 6634 6635 var emptyModifiers = Object.create(null); 6636 6637 function normalizeDirectives$1 ( 6638 dirs, 6639 vm 6640 ) { 6641 var res = Object.create(null); 6642 if (!dirs) { 6643 // $flow-disable-line 6644 return res 6645 } 6646 var i, dir; 6647 for (i = 0; i < dirs.length; i++) { 6648 dir = dirs[i]; 6649 if (!dir.modifiers) { 6650 // $flow-disable-line 6651 dir.modifiers = emptyModifiers; 6652 } 6653 res[getRawDirName(dir)] = dir; 6654 dir.def = resolveAsset(vm.$options, 'directives', dir.name, true); 6655 } 6656 // $flow-disable-line 6657 return res 6658 } 6659 6660 function getRawDirName (dir) { 6661 return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.'))) 6662 } 6663 6664 function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) { 6665 var fn = dir.def && dir.def[hook]; 6666 if (fn) { 6667 try { 6668 fn(vnode.elm, dir, vnode, oldVnode, isDestroy); 6669 } catch (e) { 6670 handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook")); 6671 } 6672 } 6673 } 6674 6675 var baseModules = [ 6676 ref, 6677 directives 6678 ]; 6679 6680 /* */ 6681 6682 function updateAttrs (oldVnode, vnode) { 6683 var opts = vnode.componentOptions; 6684 if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) { 6685 return 6686 } 6687 if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) { 6688 return 6689 } 6690 var key, cur, old; 6691 var elm = vnode.elm; 6692 var oldAttrs = oldVnode.data.attrs || {}; 6693 var attrs = vnode.data.attrs || {}; 6694 // clone observed objects, as the user probably wants to mutate it 6695 if (isDef(attrs.__ob__)) { 6696 attrs = vnode.data.attrs = extend({}, attrs); 6697 } 6698 6699 for (key in attrs) { 6700 cur = attrs[key]; 6701 old = oldAttrs[key]; 6702 if (old !== cur) { 6703 setAttr(elm, key, cur); 6704 } 6705 } 6706 // #4391: in IE9, setting type can reset value for input[type=radio] 6707 // #6666: IE/Edge forces progress value down to 1 before setting a max 6708 /* istanbul ignore if */ 6709 if ((isIE || isEdge) && attrs.value !== oldAttrs.value) { 6710 setAttr(elm, 'value', attrs.value); 6711 } 6712 for (key in oldAttrs) { 6713 if (isUndef(attrs[key])) { 6714 if (isXlink(key)) { 6715 elm.removeAttributeNS(xlinkNS, getXlinkProp(key)); 6716 } else if (!isEnumeratedAttr(key)) { 6717 elm.removeAttribute(key); 6718 } 6719 } 6720 } 6721 } 6722 6723 function setAttr (el, key, value) { 6724 if (el.tagName.indexOf('-') > -1) { 6725 baseSetAttr(el, key, value); 6726 } else if (isBooleanAttr(key)) { 6727 // set attribute for blank value 6728 // e.g. <option disabled>Select one</option> 6729 if (isFalsyAttrValue(value)) { 6730 el.removeAttribute(key); 6731 } else { 6732 // technically allowfullscreen is a boolean attribute for <iframe>, 6733 // but Flash expects a value of "true" when used on <embed> tag 6734 value = key === 'allowfullscreen' && el.tagName === 'EMBED' 6735 ? 'true'
6736 : key; 6737 el.setAttribute(key, value); 6738 } 6739 } else if (isEnumeratedAttr(key)) { 6740 el.setAttribute(key, convertEnumeratedValue(key, value)); 6741 } else if (isXlink(key)) { 6742 if (isFalsyAttrValue(value)) { 6743 el.removeAttributeNS(xlinkNS, getXlinkProp(key)); 6744 } else { 6745 el.setAttributeNS(xlinkNS, key, value); 6746 } 6747 } else { 6748 baseSetAttr(el, key, value); 6749 } 6750 } 6751 6752 function baseSetAttr (el, key, value) { 6753 if (isFalsyAttrValue(value)) { 6754 el.removeAttribute(key); 6755 } else { 6756 // #7138: IE10 & 11 fires input event when setting placeholder on 6757 // <textarea>... block the first input event and remove the blocker 6758 // immediately. 6759 /* istanbul ignore if */ 6760 if ( 6761 isIE && !isIE9 && 6762 el.tagName === 'TEXTAREA' && 6763 key === 'placeholder' && value !== '' && !el.__ieph 6764 ) { 6765 var blocker = function (e) { 6766 e.stopImmediatePropagation(); 6767 el.removeEventListener('input', blocker); 6768 }; 6769 el.addEventListener('input', blocker); 6770 // $flow-disable-line 6771 el.__ieph = true; /* IE placeholder patched */ 6772 } 6773 el.setAttribute(key, value); 6774 } 6775 } 6776 6777 var attrs = { 6778 create: updateAttrs, 6779 update: updateAttrs 6780 }; 6781 6782 /* */ 6783 6784 function updateClass (oldVnode, vnode) { 6785 var el = vnode.elm; 6786 var data = vnode.data; 6787 var oldData = oldVnode.data; 6788 if ( 6789 isUndef(data.staticClass) && 6790 isUndef(data.class) && ( 6791 isUndef(oldData) || ( 6792 isUndef(oldData.staticClass) && 6793 isUndef(oldData.class) 6794 ) 6795 ) 6796 ) { 6797 return 6798 } 6799 6800 var cls = genClassForVnode(vnode); 6801 6802 // handle transition classes 6803 var transitionClass = el._transitionClasses; 6804 if (isDef(transitionClass)) { 6805 cls = concat(cls, stringifyClass(transitionClass)); 6806 } 6807 6808 // set the class 6809 if (cls !== el._prevClass) { 6810 el.setAttribute('class', cls); 6811 el._prevClass = cls; 6812 } 6813 } 6814 6815 var klass = { 6816 create: updateClass, 6817 update: updateClass 6818 }; 6819 6820 /* */ 6821 6822 var validDivisionCharRE = /[\w).+\-_$\]]/; 6823 6824 function parseFilters (exp) { 6825 var inSingle = false; 6826 var inDouble = false; 6827 var inTemplateString = false; 6828 var inRegex = false; 6829 var curly = 0; 6830 var square = 0; 6831 var paren = 0; 6832 var lastFilterIndex = 0; 6833 var c, prev, i, expression, filters; 6834 6835 for (i = 0; i < exp.length; i++) { 6836 prev = c; 6837 c = exp.charCodeAt(i); 6838 if (inSingle) { 6839 if (c === 0x27 && prev !== 0x5C) { inSingle = false; } 6840 } else if (inDouble) { 6841 if (c === 0x22 && prev !== 0x5C) { inDouble = false; } 6842 } else if (inTemplateString) { 6843 if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; } 6844 } else if (inRegex) { 6845 if (c === 0x2f && prev !== 0x5C) { inRegex = false; } 6846 } else if ( 6847 c === 0x7C && // pipe 6848 exp.charCodeAt(i + 1) !== 0x7C && 6849 exp.charCodeAt(i - 1) !== 0x7C && 6850 !curly && !square && !paren 6851 ) { 6852 if (expression === undefined) { 6853 // first filter, end of expression 6854 lastFilterIndex = i + 1; 6855 expression = exp.slice(0, i).trim(); 6856 } else { 6857 pushFilter(); 6858 } 6859 } else { 6860 switch (c) { 6861 case 0x22: inDouble = true; break // " 6862 case 0x27: inSingle = true; break // ' 6863 case 0x60: inTemplateString = true; break // ` 6864 case 0x28: paren++; break // ( 6865 case 0x29: paren--; break // ) 6866 case 0x5B: square++; break // [ 6867 case 0x5D: square--; break // ] 6868 case 0x7B: curly++; break // { 6869 case 0x7D: curly--; break // } 6870 } 6871 if (c === 0x2f) { // /
6872 var j = i - 1; 6873 var p = (void 0); 6874 // find first non-whitespace prev char 6875 for (; j >= 0; j--) { 6876 p = exp.charAt(j); 6877 if (p !== ' ') { break } 6878 } 6879 if (!p || !validDivisionCharRE.test(p)) { 6880 inRegex = true; 6881 } 6882 } 6883 } 6884 } 6885 6886 if (expression === undefined) { 6887 expression = exp.slice(0, i).trim(); 6888 } else if (lastFilterIndex !== 0) { 6889 pushFilter(); 6890 } 6891 6892 function pushFilter () { 6893 (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim()); 6894 lastFilterIndex = i + 1; 6895 } 6896 6897 if (filters) { 6898 for (i = 0; i < filters.length; i++) { 6899 expression = wrapFilter(expression, filters[i]); 6900 } 6901 } 6902 6903 return expression 6904 } 6905 6906 function wrapFilter (exp, filter) { 6907 var i = filter.indexOf('('); 6908 if (i < 0) { 6909 // _f: resolveFilter 6910 return ("_f(\"" + filter + "\")(" + exp + ")") 6911 } else { 6912 var name = filter.slice(0, i); 6913 var args = filter.slice(i + 1); 6914 return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args)) 6915 } 6916 } 6917 6918 /* */ 6919 6920 6921 6922 /* eslint-disable no-unused-vars */ 6923 function baseWarn (msg, range) { 6924 console.error(("[Vue compiler]: " + msg)); 6925 } 6926 /* eslint-enable no-unused-vars */ 6927 6928 function pluckModuleFunction ( 6929 modules, 6930 key 6931 ) { 6932 return modules 6933 ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; }) 6934 : [] 6935 } 6936 6937 function addProp (el, name, value, range, dynamic) { 6938 (el.props || (el.props = [])).push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range)); 6939 el.plain = false; 6940 } 6941 6942 function addAttr (el, name, value, range, dynamic) { 6943 var attrs = dynamic 6944 ? (el.dynamicAttrs || (el.dynamicAttrs = [])) 6945 : (el.attrs || (el.attrs = [])); 6946 attrs.push(rangeSetItem({ name: name, value: value, dynamic: dynamic }, range)); 6947 el.plain = false; 6948 } 6949 6950 // add a raw attr (use this in preTransforms) 6951 function addRawAttr (el, name, value, range) { 6952 el.attrsMap[name] = value; 6953 el.attrsList.push(rangeSetItem({ name: name, value: value }, range)); 6954 } 6955 6956 function addDirective ( 6957 el, 6958 name, 6959 rawName, 6960 value, 6961 arg, 6962 isDynamicArg, 6963 modifiers, 6964 range 6965 ) { 6966 (el.directives || (el.directives = [])).push(rangeSetItem({ 6967 name: name, 6968 rawName: rawName, 6969 value: value, 6970 arg: arg, 6971 isDynamicArg: isDynamicArg, 6972 modifiers: modifiers 6973 }, range)); 6974 el.plain = false; 6975 } 6976 6977 function prependModifierMarker (symbol, name, dynamic) { 6978 return dynamic 6979 ? ("_p(" + name + ",\"" + symbol + "\")") 6980 : symbol + name // mark the event as captured 6981 } 6982 6983 function addHandler ( 6984 el, 6985 name, 6986 value, 6987 modifiers, 6988 important, 6989 warn, 6990 range, 6991 dynamic 6992 ) { 6993 modifiers = modifiers || emptyObject; 6994 // warn prevent and passive modifier 6995 /* istanbul ignore if */ 6996 if ( 6997 warn && 6998 modifiers.prevent && modifiers.passive 6999 ) { 7000 warn( 7001 'passive and prevent can\'t be used together. ' + 7002 'Passive handler can\'t prevent default event.', 7003 range 7004 ); 7005 } 7006 7007 // normalize click.right and click.middle since they don't actually fire 7008 // this is technically browser-specific, but at least for now browsers are 7009 // the only target envs that have right/middle clicks. 7010 if (modifiers.right) { 7011 if (dynamic) { 7012 name = "(" + name + ")==='click'?'contextmenu':(" + name + ")"; 7013 } else if (name === 'click') { 7014 name = 'contextmenu'; 7015 delete modifiers.right; 7016 } 7017 } else if (modifiers.middle) { 7018 if (dynamic) { 7019 name = "(" + name + ")==='click'?'mouseup':(" + name + ")"; 7020 } else if (name === 'click') { 7021 name = 'mouseup'; 7022 } 7023 } 7024 7025 // check capture modifier 7026 if (modifiers.capture) { 7027 delete modifiers.capture; 7028 name = prependModifierMarker('!', name, dynamic); 7029 } 7030 if (modifiers.once) { 7031 delete modifiers.once; 7032 name = prependModifierMarker('~', name, dynamic); 7033 } 7034 /* istanbul ignore if */ 7035 if (modifiers.passive) { 7036 delete modifiers.passive; 7037 name = prependModifierMarker('&', name, dynamic); 7038 } 7039 7040 var events; 7041 if (modifiers.native) { 7042 delete modifiers.native; 7043 events = el.nativeEvents || (el.nativeEvents = {}); 7044 } else { 7045 events = el.events || (el.events = {}); 7046 } 7047 7048 var newHandler = rangeSetItem({ value: value.trim(), dynamic: dynamic }, range); 7049 if (modifiers !== emptyObject) { 7050 newHandler.modifiers = modifiers; 7051 } 7052 7053 var handlers = events[name]; 7054 /* istanbul ignore if */ 7055 if (Array.isArray(handlers)) { 7056 important ? handlers.unshift(newHandler) : handlers.push(newHandler); 7057 } else if (handlers) { 7058 events[name] = important ? [newHandler, handlers] : [handlers, newHandler]; 7059 } else { 7060 events[name] = newHandler; 7061 } 7062 7063 el.plain = false;
7064 } 7065 7066 function getRawBindingAttr ( 7067 el, 7068 name 7069 ) { 7070 return el.rawAttrsMap[':' + name] || 7071 el.rawAttrsMap['v-bind:' + name] || 7072 el.rawAttrsMap[name] 7073 } 7074 7075 function getBindingAttr ( 7076 el, 7077 name, 7078 getStatic 7079 ) { 7080 var dynamicValue = 7081 getAndRemoveAttr(el, ':' + name) || 7082 getAndRemoveAttr(el, 'v-bind:' + name); 7083 if (dynamicValue != null) { 7084 return parseFilters(dynamicValue) 7085 } else if (getStatic !== false) { 7086 var staticValue = getAndRemoveAttr(el, name); 7087 if (staticValue != null) { 7088 return JSON.stringify(staticValue) 7089 } 7090 } 7091 } 7092 7093 // note: this only removes the attr from the Array (attrsList) so that it 7094 // doesn't get processed by processAttrs. 7095 // By default it does NOT remove it from the map (attrsMap) because the map is 7096 // needed during codegen. 7097 function getAndRemoveAttr ( 7098 el, 7099 name, 7100 removeFromMap 7101 ) { 7102 var val; 7103 if ((val = el.attrsMap[name]) != null) { 7104 var list = el.attrsList; 7105 for (var i = 0, l = list.length; i < l; i++) { 7106 if (list[i].name === name) { 7107 list.splice(i, 1); 7108 break 7109 } 7110 } 7111 } 7112 if (removeFromMap) { 7113 delete el.attrsMap[name]; 7114 } 7115 return val 7116 } 7117 7118 function getAndRemoveAttrByRegex ( 7119 el, 7120 name 7121 ) { 7122 var list = el.attrsList; 7123 for (var i = 0, l = list.length; i < l; i++) { 7124 var attr = list[i]; 7125 if (name.test(attr.name)) { 7126 list.splice(i, 1); 7127 return attr 7128 } 7129 } 7130 } 7131 7132 function rangeSetItem ( 7133 item, 7134 range 7135 ) { 7136 if (range) { 7137 if (range.start != null) { 7138 item.start = range.start; 7139 } 7140 if (range.end != null) { 7141 item.end = range.end; 7142 } 7143 } 7144 return item 7145 } 7146 7147 /* */ 7148 7149 /** 7150 * Cross-platform code generation for component v-model 7151 */ 7152 function genComponentModel ( 7153 el, 7154 value, 7155 modifiers 7156 ) { 7157 var ref = modifiers || {}; 7158 var number = ref.number; 7159 var trim = ref.trim; 7160 7161 var baseValueExpression = '$$v'; 7162 var valueExpression = baseValueExpression; 7163 if (trim) { 7164 valueExpression = 7165 "(typeof " + baseValueExpression + " === 'string'" + 7166 "? " + baseValueExpression + ".trim()" + 7167 ": " + baseValueExpression + ")"; 7168 } 7169 if (number) { 7170 valueExpression = "_n(" + valueExpression + ")"; 7171 } 7172 var assignment = genAssignmentCode(value, valueExpression); 7173 7174 el.model = { 7175 value: ("(" + value + ")"), 7176 expression: JSON.stringify(value), 7177 callback: ("function (" + baseValueExpression + ") {" + assignment + "}") 7178 }; 7179 } 7180 7181 /** 7182 * Cross-platform codegen helper for generating v-model value assignment code. 7183 */ 7184 function genAssignmentCode ( 7185 value, 7186 assignment 7187 ) { 7188 var res = parseModel(value); 7189 if (res.key === null) { 7190 return (value + "=" + assignment) 7191 } else { 7192 return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")") 7193 } 7194 } 7195 7196 /** 7197 * Parse a v-model expression into a base path and a final key segment. 7198 * Handles both dot-path and possible square brackets. 7199 * 7200 * Possible cases: 7201 * 7202 * - test 7203 * - test[key] 7204 * - test[test1[key]] 7205 * - test["a"][key] 7206 * - xxx.test[a[a].test1[key]] 7207 * - test.xxx.a["asa"][test1[key]] 7208 * 7209 */ 7210 7211 var len, str, chr, index$1, expressionPos, expressionEndPos; 7212 7213 7214 7215 function parseModel (val) { 7216 // Fix https://github.com/vuejs/vue/pull/7730 7217 // allow v-model="obj.val " (trailing whitespace) 7218 val = val.trim(); 7219 len = val.length; 7220 7221 if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) { 7222 index$1 = val.lastIndexOf('.'); 7223 if (index$1 > -1) { 7224 return { 7225 exp: val.slice(0, index$1), 7226 key: '"' + val.slice(index$1 + 1) + '"' 7227 } 7228 } else { 7229 return { 7230 exp: val, 7231 key: null 7232 } 7233 } 7234 } 7235 7236 str = val; 7237 index$1 = expressionPos = expressionEndPos = 0; 7238 7239 while (!eof()) { 7240 chr = next(); 7241 /* istanbul ignore if */ 7242 if (isStringStart(chr)) { 7243 parseString(chr); 7244 } else if (chr === 0x5B) { 7245 parseBracket(chr); 7246 } 7247 } 7248 7249 return { 7250 exp: val.slice(0, expressionPos), 7251 key: val.slice(expressionPos + 1, expressionEndPos) 7252 } 7253 } 7254 7255 function next () { 7256 return str.charCodeAt(++index$1) 7257 } 7258 7259 function eof () { 7260 return index$1 >= len 7261 } 7262 7263 function isStringStart (chr) { 7264 return chr === 0x22 || chr === 0x27 7265 } 7266 7267 function parseBracket (chr) { 7268 var inBracket = 1; 7269 expressionPos = index$1; 7270 while (!eof()) { 7271 chr = next(); 7272 if (isStringStart(chr)) { 7273 parseString(chr); 7274 continue 7275 } 7276 if (chr === 0x5B) { inBracket++; } 7277 if (chr === 0x5D) { inBracket--; } 7278 if (inBracket === 0) { 7279 expressionEndPos = index$1; 7280 break 7281 } 7282 } 7283 } 7284 7285 function parseString (chr) { 7286 var stringQuote = chr; 7287 while (!eof()) { 7288 chr = next(); 7289 if (chr === stringQuote) { 7290 break 7291 } 7292 } 7293 } 7294 7295 /* */ 7296 7297 var warn$1; 7298 7299 // in some cases, the event used has to be determined at runtime 7300 // so we used some reserved tokens during compile. 7301 var RANGE_TOKEN = '__r'; 7302 var CHECKBOX_RADIO_TOKEN = '__c'; 7303 7304 function model ( 7305 el, 7306 dir, 7307 _warn 7308 ) { 7309 warn$1 = _warn; 7310 var value = dir.value; 7311 var modifiers = dir.modifiers; 7312 var tag = el.tag; 7313 var type = el.attrsMap.type; 7314 7315 { 7316 // inputs with type="file" are read only and setting the input's 7317 // value will throw an error. 7318 if (tag === 'input' && type === 'file') { 7319 warn$1( 7320 "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" + 7321 "File inputs are read only. Use a v-on:change listener instead.", 7322 el.rawAttrsMap['v-model'] 7323 ); 7324 } 7325 } 7326 7327 if (el.component) { 7328 genComponentModel(el, value, modifiers); 7329 // component v-model doesn't need extra runtime 7330 return false 7331 } else if (tag === 'select') { 7332 genSelect(el, value, modifiers); 7333 } else if (tag === 'input' && type === 'checkbox') {
7334 genCheckboxModel(el, value, modifiers); 7335 } else if (tag === 'input' && type === 'radio') { 7336 genRadioModel(el, value, modifiers); 7337 } else if (tag === 'input' || tag === 'textarea') { 7338 genDefaultModel(el, value, modifiers); 7339 } else if (!config.isReservedTag(tag)) { 7340 genComponentModel(el, value, modifiers); 7341 // component v-model doesn't need extra runtime 7342 return false 7343 } else { 7344 warn$1( 7345 "<" + (el.tag) + " v-model=\"" + value + "\">: " + 7346 "v-model is not supported on this element type. " + 7347 'If you are working with contenteditable, it\'s recommended to ' + 7348 'wrap a library dedicated for that purpose inside a custom component.', 7349 el.rawAttrsMap['v-model'] 7350 ); 7351 } 7352 7353 // ensure runtime directive metadata 7354 return true 7355 } 7356 7357 function genCheckboxModel ( 7358 el, 7359 value, 7360 modifiers 7361 ) { 7362 var number = modifiers && modifiers.number; 7363 var valueBinding = getBindingAttr(el, 'value') || 'null'; 7364 var trueValueBinding = getBindingAttr(el, 'true-value') || 'true'; 7365 var falseValueBinding = getBindingAttr(el, 'false-value') || 'false'; 7366 addProp(el, 'checked', 7367 "Array.isArray(" + value + ")" + 7368 "?_i(" + value + "," + valueBinding + ")>-1" + ( 7369 trueValueBinding === 'true' 7370 ? (":(" + value + ")") 7371 : (":_q(" + value + "," + trueValueBinding + ")") 7372 ) 7373 ); 7374 addHandler(el, 'change', 7375 "var $$a=" + value + "," + 7376 '$$el=$event.target,' + 7377 "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" + 7378 'if(Array.isArray($$a)){' + 7379 "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," + 7380 '$$i=_i($$a,$$v);' + 7381 "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" + 7382 "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" + 7383 "}else{" + (genAssignmentCode(value, '$$c')) + "}", 7384 null, true 7385 ); 7386 } 7387 7388 function genRadioModel ( 7389 el, 7390 value, 7391 modifiers 7392 ) { 7393 var number = modifiers && modifiers.number; 7394 var valueBinding = getBindingAttr(el, 'value') || 'null'; 7395 valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding; 7396 addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")")); 7397 addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true); 7398 } 7399 7400 function genSelect ( 7401 el, 7402 value, 7403 modifiers 7404 ) { 7405 var number = modifiers && modifiers.number; 7406 var selectedVal = "Array.prototype.filter" + 7407 ".call($event.target.options,function(o){return o.selected})" + 7408 ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" + 7409 "return " + (number ? '_n(val)' : 'val') + "})"; 7410 7411 var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]'; 7412 var code = "var $$selectedVal = " + selectedVal + ";"; 7413 code = code + " " + (genAssignmentCode(value, assignment)); 7414 addHandler(el, 'change', code, null, true); 7415 } 7416 7417 function genDefaultModel ( 7418 el, 7419 value, 7420 modifiers 7421 ) { 7422 var type = el.attrsMap.type; 7423 7424 // warn if v-bind:value conflicts with v-model 7425 // except for inputs with v-bind:type 7426 { 7427 var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value']; 7428 var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type']; 7429 if (value$1 && !typeBinding) { 7430 var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value'; 7431 warn$1( 7432 binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " + 7433 'because the latter already expands to a value binding internally', 7434 el.rawAttrsMap[binding] 7435 ); 7436 } 7437 } 7438 7439 var ref = modifiers || {}; 7440 var lazy = ref.lazy; 7441 var number = ref.number; 7442 var trim = ref.trim; 7443 var needCompositionGuard = !lazy && type !== 'range'; 7444 var event = lazy 7445 ? 'change' 7446 : type === 'range' 7447 ? RANGE_TOKEN 7448 : 'input'; 7449 7450 var valueExpression = '$event.target.value'; 7451 if (trim) { 7452 valueExpression = "$event.target.value.trim()"; 7453 } 7454 if (number) { 7455 valueExpression = "_n(" + valueExpression + ")"; 7456 } 7457
vendor: 48,698 bytes, lines 7458-8889
7458 var code = genAssignmentCode(value, valueExpression); 7459 if (needCompositionGuard) { 7460 code = "if($event.target.composing)return;" + code; 7461 } 7462 7463 addProp(el, 'value', ("(" + value + ")")); 7464 addHandler(el, event, code, null, true); 7465 if (trim || number) { 7466 addHandler(el, 'blur', '$forceUpdate()'); 7467 } 7468 } 7469 7470 /* */ 7471 7472 // normalize v-model event tokens that can only be determined at runtime. 7473 // it's important to place the event as the first in the array because 7474 // the whole point is ensuring the v-model callback gets called before 7475 // user-attached handlers. 7476 function normalizeEvents (on) { 7477 /* istanbul ignore if */ 7478 if (isDef(on[RANGE_TOKEN])) { 7479 // IE input[type=range] only supports `change` event 7480 var event = isIE ? 'change' : 'input'; 7481 on[event] = [].concat(on[RANGE_TOKEN], on[event] || []); 7482 delete on[RANGE_TOKEN]; 7483 } 7484 // This was originally intended to fix #4521 but no longer necessary 7485 // after 2.5. Keeping it for backwards compat with generated code from < 2.4 7486 /* istanbul ignore if */ 7487 if (isDef(on[CHECKBOX_RADIO_TOKEN])) { 7488 on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []); 7489 delete on[CHECKBOX_RADIO_TOKEN]; 7490 } 7491 } 7492 7493 var target$1; 7494 7495 function createOnceHandler$1 (event, handler, capture) { 7496 var _target = target$1; // save current target element in closure 7497 return function onceHandler () { 7498 var res = handler.apply(null, arguments); 7499 if (res !== null) { 7500 remove$2(event, onceHandler, capture, _target); 7501 } 7502 } 7503 } 7504 7505 // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp 7506 // implementation and does not fire microtasks in between event propagation, so 7507 // safe to exclude. 7508 var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53); 7509 7510 function add$1 ( 7511 name, 7512 handler, 7513 capture, 7514 passive 7515 ) { 7516 // async edge case #6566: inner click event triggers patch, event handler 7517 // attached to outer element during patch, and triggered again. This 7518 // happens because browsers fire microtask ticks between event propagation. 7519 // the solution is simple: we save the timestamp when a handler is attached, 7520 // and the handler would only fire if the event passed to it was fired 7521 // AFTER it was attached. 7522 if (useMicrotaskFix) { 7523 var attachedTimestamp = currentFlushTimestamp; 7524 var original = handler; 7525 handler = original._wrapper = function (e) { 7526 if ( 7527 // no bubbling, should always fire. 7528 // this is just a safety net in case event.timeStamp is unreliable in 7529 // certain weird environments... 7530 e.target === e.currentTarget || 7531 // event is fired after handler attachment 7532 e.timeStamp >= attachedTimestamp || 7533 // bail for environments that have buggy event.timeStamp implementations 7534 // #9462 iOS 9 bug: event.timeStamp is 0 after history.pushState 7535 // #9681 QtWebEngine event.timeStamp is negative value 7536 e.timeStamp <= 0 || 7537 // #9448 bail if event is fired in another document in a multi-page 7538 // electron/nw.js app, since event.timeStamp will be using a different 7539 // starting reference 7540 e.target.ownerDocument !== document 7541 ) { 7542 return original.apply(this, arguments) 7543 } 7544 }; 7545 } 7546 target$1.addEventListener( 7547 name, 7548 handler, 7549 supportsPassive 7550 ? { capture: capture, passive: passive } 7551 : capture 7552 ); 7553 } 7554 7555 function remove$2 ( 7556 name, 7557 handler, 7558 capture, 7559 _target 7560 ) { 7561 (_target || target$1).removeEventListener( 7562 name, 7563 handler._wrapper || handler, 7564 capture 7565 ); 7566 } 7567 7568 function updateDOMListeners (oldVnode, vnode) { 7569 if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) { 7570 return 7571 } 7572 var on = vnode.data.on || {}; 7573 var oldOn = oldVnode.data.on || {}; 7574 target$1 = vnode.elm; 7575 normalizeEvents(on); 7576 updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context); 7577 target$1 = undefined; 7578 } 7579 7580 var events = { 7581 create: updateDOMListeners, 7582 update: updateDOMListeners 7583 }; 7584 7585 /* */ 7586 7587 var svgContainer; 7588 7589 function updateDOMProps (oldVnode, vnode) { 7590 if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) { 7591 return 7592 } 7593 var key, cur; 7594 var elm = vnode.elm; 7595 var oldProps = oldVnode.data.domProps || {}; 7596 var props = vnode.data.domProps || {}; 7597 // clone observed objects, as the user probably wants to mutate it 7598 if (isDef(props.__ob__)) { 7599 props = vnode.data.domProps = extend({}, props); 7600 } 7601 7602 for (key in oldProps) { 7603 if (!(key in props)) { 7604 elm[key] = ''; 7605 } 7606 } 7607 7608 for (key in props) { 7609 cur = props[key]; 7610 // ignore children if the node has textContent or innerHTML, 7611 // as these will throw away existing DOM nodes and cause removal errors 7612 // on subsequent patches (#3360) 7613 if (key === 'textContent' || key === 'innerHTML') { 7614 if (vnode.children) { vnode.children.length = 0; } 7615 if (cur === oldProps[key]) { continue } 7616 // #6601 work around Chrome version <= 55 bug where single textNode 7617 // replaced by innerHTML/textContent retains its parentNode property 7618 if (elm.childNodes.length === 1) { 7619 elm.removeChild(elm.childNodes[0]); 7620 } 7621 } 7622 7623 if (key === 'value' && elm.tagName !== 'PROGRESS') { 7624 // store value as _value as well since 7625 // non-string values will be stringified 7626 elm._value = cur; 7627 // avoid resetting cursor position when value is the same 7628 var strCur = isUndef(cur) ? '' : String(cur); 7629 if (shouldUpdateValue(elm, strCur)) { 7630 elm.value = strCur; 7631 } 7632 } else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) { 7633 // IE doesn't support innerHTML for SVG elements 7634 svgContainer = svgContainer || document.createElement('div'); 7635 svgContainer.innerHTML = "<svg>" + cur + "</svg>"; 7636 var svg = svgContainer.firstChild; 7637 while (elm.firstChild) { 7638 elm.removeChild(elm.firstChild); 7639 } 7640 while (svg.firstChild) { 7641 elm.appendChild(svg.firstChild); 7642 } 7643 } else if ( 7644 // skip the update if old and new VDOM state is the same. 7645 // `value` is handled separately because the DOM value may be temporarily 7646 // out of sync with VDOM state due to focus, composition and modifiers. 7647 // This #4521 by skipping the unnecesarry `checked` update. 7648 cur !== oldProps[key] 7649 ) { 7650 // some property updates can throw 7651 // e.g. `value` on <progress> w/ non-finite value 7652 try { 7653 elm[key] = cur; 7654 } catch (e) {} 7655 } 7656 } 7657 } 7658 7659 // check platforms/web/util/attrs.js acceptValue 7660 7661 7662 function shouldUpdateValue (elm, checkVal) { 7663 return (!elm.composing && ( 7664 elm.tagName === 'OPTION' || 7665 isNotInFocusAndDirty(elm, checkVal) || 7666 isDirtyWithModifiers(elm, checkVal) 7667 )) 7668 } 7669 7670 function isNotInFocusAndDirty (elm, checkVal) { 7671 // return true when textbox (.number and .trim) loses focus and its value is 7672 // not equal to the updated value 7673 var notInFocus = true; 7674 // #6157 7675 // work around IE bug when accessing document.activeElement in an iframe 7676 try { notInFocus = document.activeElement !== elm; } catch (e) {} 7677 return notInFocus && elm.value !== checkVal 7678 } 7679 7680 function isDirtyWithModifiers (elm, newVal) { 7681 var value = elm.value; 7682 var modifiers = elm._vModifiers; // injected by v-model runtime 7683 if (isDef(modifiers)) { 7684 if (modifiers.number) { 7685 return toNumber(value) !== toNumber(newVal) 7686 } 7687 if (modifiers.trim) { 7688 return value.trim() !== newVal.trim() 7689 } 7690 } 7691 return value !== newVal 7692 } 7693 7694 var domProps = { 7695 create: updateDOMProps, 7696 update: updateDOMProps 7697 }; 7698 7699 /* */ 7700 7701 var parseStyleText = cached(function (cssText) { 7702 var res = {}; 7703 var listDelimiter = /;(?![^(]*\))/g; 7704 var propertyDelimiter = /:(.+)/; 7705 cssText.split(listDelimiter).forEach(function (item) { 7706 if (item) { 7707 var tmp = item.split(propertyDelimiter); 7708 tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim()); 7709 } 7710 }); 7711 return res 7712 }); 7713 7714 // merge static and dynamic style data on the same vnode 7715 function normalizeStyleData (data) { 7716 var style = normalizeStyleBinding(data.style); 7717 // static style is pre-processed into an object during compilation 7718 // and is always a fresh object, so it's safe to merge into it 7719 return data.staticStyle 7720 ? extend(data.staticStyle, style) 7721 : style 7722 } 7723 7724 // normalize possible array / string values into Object 7725 function normalizeStyleBinding (bindingStyle) { 7726 if (Array.isArray(bindingStyle)) { 7727 return toObject(bindingStyle) 7728 } 7729 if (typeof bindingStyle === 'string') { 7730 return parseStyleText(bindingStyle) 7731 } 7732 return bindingStyle 7733 } 7734 7735 /** 7736 * parent component style should be after child's 7737 * so that parent component's style could override it 7738 */ 7739 function getStyle (vnode, checkChild) { 7740 var res = {}; 7741 var styleData; 7742 7743 if (checkChild) { 7744 var childNode = vnode; 7745 while (childNode.componentInstance) { 7746 childNode = childNode.componentInstance._vnode; 7747 if ( 7748 childNode && childNode.data && 7749 (styleData = normalizeStyleData(childNode.data)) 7750 ) { 7751 extend(res, styleData); 7752 } 7753 } 7754 } 7755 7756 if ((styleData = normalizeStyleData(vnode.data))) { 7757 extend(res, styleData); 7758 } 7759 7760 var parentNode = vnode; 7761 while ((parentNode = parentNode.parent)) { 7762 if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) { 7763 extend(res, styleData); 7764 } 7765 } 7766 return res 7767 } 7768 7769 /* */ 7770 7771 var cssVarRE = /^--/; 7772 var importantRE = /\s*!important$/; 7773 var setProp = function (el, name, val) { 7774 /* istanbul ignore if */ 7775 if (cssVarRE.test(name)) { 7776 el.style.setProperty(name, val); 7777 } else if (importantRE.test(val)) { 7778 el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important'); 7779 } else { 7780 var normalizedName = normalize(name); 7781 if (Array.isArray(val)) { 7782 // Support values array created by autoprefixer, e.g. 7783 // {display: ["-webkit-box", "-ms-flexbox", "flex"]} 7784 // Set them one by one, and the browser will only set those it can recognize 7785 for (var i = 0, len = val.length; i < len; i++) { 7786 el.style[normalizedName] = val[i]; 7787 } 7788 } else { 7789 el.style[normalizedName] = val; 7790 } 7791 } 7792 }; 7793 7794 var vendorNames = ['Webkit', 'Moz', 'ms']; 7795 7796 var emptyStyle; 7797 var normalize = cached(function (prop) { 7798 emptyStyle = emptyStyle || document.createElement('div').style; 7799 prop = camelize(prop); 7800 if (prop !== 'filter' && (prop in emptyStyle)) { 7801 return prop 7802 } 7803 var capName = prop.charAt(0).toUpperCase() + prop.slice(1); 7804 for (var i = 0; i < vendorNames.length; i++) { 7805 var name = vendorNames[i] + capName; 7806 if (name in emptyStyle) { 7807 return name 7808 } 7809 } 7810 }); 7811 7812 function updateStyle (oldVnode, vnode) { 7813 var data = vnode.data; 7814 var oldData = oldVnode.data; 7815 7816 if (isUndef(data.staticStyle) && isUndef(data.style) && 7817 isUndef(oldData.staticStyle) && isUndef(oldData.style) 7818 ) { 7819 return 7820 } 7821 7822 var cur, name; 7823 var el = vnode.elm; 7824 var oldStaticStyle = oldData.staticStyle; 7825 var oldStyleBinding = oldData.normalizedStyle || oldData.style || {}; 7826 7827 // if static style exists, stylebinding already merged into it when doing normalizeStyleData 7828 var oldStyle = oldStaticStyle || oldStyleBinding; 7829 7830 var style = normalizeStyleBinding(vnode.data.style) || {}; 7831 7832 // store normalized style under a different key for next diff 7833 // make sure to clone it if it's reactive, since the user likely wants 7834 // to mutate it. 7835 vnode.data.normalizedStyle = isDef(style.__ob__) 7836 ? extend({}, style) 7837 : style; 7838 7839 var newStyle = getStyle(vnode, true); 7840 7841 for (name in oldStyle) { 7842 if (isUndef(newStyle[name])) { 7843 setProp(el, name, ''); 7844 } 7845 } 7846 for (name in newStyle) { 7847 cur = newStyle[name]; 7848 if (cur !== oldStyle[name]) { 7849 // ie9 setting to null has no effect, must use empty string 7850 setProp(el, name, cur == null ? '' : cur); 7851 } 7852 } 7853 } 7854 7855 var style = { 7856 create: updateStyle, 7857 update: updateStyle 7858 }; 7859 7860 /* */ 7861 7862 var whitespaceRE = /\s+/; 7863 7864 /** 7865 * Add class with compatibility for SVG since classList is not supported on 7866 * SVG elements in IE 7867 */ 7868 function addClass (el, cls) { 7869 /* istanbul ignore if */ 7870 if (!cls || !(cls = cls.trim())) { 7871 return 7872 } 7873 7874 /* istanbul ignore else */ 7875 if (el.classList) { 7876 if (cls.indexOf(' ') > -1) { 7877 cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); }); 7878 } else { 7879 el.classList.add(cls); 7880 } 7881 } else { 7882 var cur = " " + (el.getAttribute('class') || '') + " "; 7883 if (cur.indexOf(' ' + cls + ' ') < 0) { 7884 el.setAttribute('class', (cur + cls).trim()); 7885 } 7886 } 7887 } 7888 7889 /** 7890 * Remove class with compatibility for SVG since classList is not supported on 7891 * SVG elements in IE 7892 */ 7893 function removeClass (el, cls) { 7894 /* istanbul ignore if */ 7895 if (!cls || !(cls = cls.trim())) { 7896 return 7897 } 7898 7899 /* istanbul ignore else */ 7900 if (el.classList) { 7901 if (cls.indexOf(' ') > -1) { 7902 cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); }); 7903 } else { 7904 el.classList.remove(cls); 7905 } 7906 if (!el.classList.length) { 7907 el.removeAttribute('class'); 7908 } 7909 } else { 7910 var cur = " " + (el.getAttribute('class') || '') + " "; 7911 var tar = ' ' + cls + ' '; 7912 while (cur.indexOf(tar) >= 0) { 7913 cur = cur.replace(tar, ' '); 7914 } 7915 cur = cur.trim(); 7916 if (cur) { 7917 el.setAttribute('class', cur); 7918 } else { 7919 el.removeAttribute('class'); 7920 } 7921 } 7922 } 7923 7924 /* */ 7925 7926 function resolveTransition (def$$1) { 7927 if (!def$$1) { 7928 return 7929 } 7930 /* istanbul ignore else */ 7931 if (typeof def$$1 === 'object') { 7932 var res = {}; 7933 if (def$$1.css !== false) { 7934 extend(res, autoCssTransition(def$$1.name || 'v')); 7935 } 7936 extend(res, def$$1); 7937 return res 7938 } else if (typeof def$$1 === 'string') { 7939 return autoCssTransition(def$$1) 7940 } 7941 } 7942 7943 var autoCssTransition = cached(function (name) { 7944 return { 7945 enterClass: (name + "-enter"), 7946 enterToClass: (name + "-enter-to"), 7947 enterActiveClass: (name + "-enter-active"), 7948 leaveClass: (name + "-leave"), 7949 leaveToClass: (name + "-leave-to"), 7950 leaveActiveClass: (name + "-leave-active") 7951 } 7952 }); 7953 7954 var hasTransition = inBrowser && !isIE9; 7955 var TRANSITION = 'transition'; 7956 var ANIMATION = 'animation'; 7957 7958 // Transition property/event sniffing 7959 var transitionProp = 'transition'; 7960 var transitionEndEvent = 'transitionend'; 7961 var animationProp = 'animation'; 7962 var animationEndEvent = 'animationend'; 7963 if (hasTransition) { 7964 /* istanbul ignore if */ 7965 if (window.ontransitionend === undefined && 7966 window.onwebkittransitionend !== undefined 7967 ) { 7968 transitionProp = 'WebkitTransition'; 7969 transitionEndEvent = 'webkitTransitionEnd'; 7970 } 7971 if (window.onanimationend === undefined && 7972 window.onwebkitanimationend !== undefined 7973 ) { 7974 animationProp = 'WebkitAnimation'; 7975 animationEndEvent = 'webkitAnimationEnd'; 7976 } 7977 } 7978 7979 // binding to window is necessary to make hot reload work in IE in strict mode 7980 var raf = inBrowser 7981 ? window.requestAnimationFrame 7982 ? window.requestAnimationFrame.bind(window) 7983 : setTimeout 7984 : /* istanbul ignore next */ function (fn) { return fn(); }; 7985 7986 function nextFrame (fn) { 7987 raf(function () { 7988 raf(fn); 7989 }); 7990 } 7991 7992 function addTransitionClass (el, cls) { 7993 var transitionClasses = el._transitionClasses || (el._transitionClasses = []); 7994 if (transitionClasses.indexOf(cls) < 0) { 7995 transitionClasses.push(cls); 7996 addClass(el, cls); 7997 } 7998 } 7999 8000 function removeTransitionClass (el, cls) { 8001 if (el._transitionClasses) { 8002 remove(el._transitionClasses, cls); 8003 } 8004 removeClass(el, cls); 8005 } 8006 8007 function whenTransitionEnds ( 8008 el, 8009 expectedType, 8010 cb 8011 ) { 8012 var ref = getTransitionInfo(el, expectedType); 8013 var type = ref.type; 8014 var timeout = ref.timeout; 8015 var propCount = ref.propCount; 8016 if (!type) { return cb() } 8017 var event = type === TRANSITION ? transitionEndEvent : animationEndEvent; 8018 var ended = 0; 8019 var end = function () { 8020 el.removeEventListener(event, onEnd); 8021 cb(); 8022 }; 8023 var onEnd = function (e) { 8024 if (e.target === el) { 8025 if (++ended >= propCount) { 8026 end(); 8027 } 8028 } 8029 }; 8030 setTimeout(function () { 8031 if (ended < propCount) { 8032 end(); 8033 } 8034 }, timeout + 1); 8035 el.addEventListener(event, onEnd); 8036 } 8037 8038 var transformRE = /\b(transform|all)(,|$)/; 8039 8040 function getTransitionInfo (el, expectedType) { 8041 var styles = window.getComputedStyle(el); 8042 // JSDOM may return undefined for transition properties 8043 var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', '); 8044 var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', '); 8045 var transitionTimeout = getTimeout(transitionDelays, transitionDurations); 8046 var animationDelays = (styles[animationProp + 'Delay'] || '').split(', '); 8047 var animationDurations = (styles[animationProp + 'Duration'] || '').split(', '); 8048 var animationTimeout = getTimeout(animationDelays, animationDurations); 8049 8050 var type; 8051 var timeout = 0; 8052 var propCount = 0; 8053 /* istanbul ignore if */ 8054 if (expectedType === TRANSITION) { 8055 if (transitionTimeout > 0) { 8056 type = TRANSITION; 8057 timeout = transitionTimeout; 8058 propCount = transitionDurations.length; 8059 } 8060 } else if (expectedType === ANIMATION) { 8061 if (animationTimeout > 0) { 8062 type = ANIMATION; 8063 timeout = animationTimeout; 8064 propCount = animationDurations.length; 8065 } 8066 } else { 8067 timeout = Math.max(transitionTimeout, animationTimeout); 8068 type = timeout > 0 8069 ? transitionTimeout > animationTimeout 8070 ? TRANSITION 8071 : ANIMATION 8072 : null; 8073 propCount = type 8074 ? type === TRANSITION 8075 ? transitionDurations.length 8076 : animationDurations.length 8077 : 0; 8078 } 8079 var hasTransform = 8080 type === TRANSITION && 8081 transformRE.test(styles[transitionProp + 'Property']); 8082 return { 8083 type: type, 8084 timeout: timeout, 8085 propCount: propCount, 8086 hasTransform: hasTransform 8087 } 8088 } 8089 8090 function getTimeout (delays, durations) { 8091 /* istanbul ignore next */ 8092 while (delays.length < durations.length) { 8093 delays = delays.concat(delays); 8094 } 8095 8096 return Math.max.apply(null, durations.map(function (d, i) { 8097 return toMs(d) + toMs(delays[i]) 8098 })) 8099 } 8100 8101 // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers 8102 // in a locale-dependent way, using a comma instead of a dot. 8103 // If comma is not replaced with a dot, the input will be rounded down (i.e. acting 8104 // as a floor function) causing unexpected behaviors 8105 function toMs (s) { 8106 return Number(s.slice(0, -1).replace(',', '.')) * 1000 8107 } 8108 8109 /* */ 8110 8111 function enter (vnode, toggleDisplay) { 8112 var el = vnode.elm; 8113 8114 // call leave callback now 8115 if (isDef(el._leaveCb)) { 8116 el._leaveCb.cancelled = true; 8117 el._leaveCb(); 8118 } 8119 8120 var data = resolveTransition(vnode.data.transition); 8121 if (isUndef(data)) { 8122 return 8123 } 8124 8125 /* istanbul ignore if */ 8126 if (isDef(el._enterCb) || el.nodeType !== 1) { 8127 return 8128 } 8129 8130 var css = data.css; 8131 var type = data.type; 8132 var enterClass = data.enterClass; 8133 var enterToClass = data.enterToClass; 8134 var enterActiveClass = data.enterActiveClass; 8135 var appearClass = data.appearClass; 8136 var appearToClass = data.appearToClass; 8137 var appearActiveClass = data.appearActiveClass; 8138 var beforeEnter = data.beforeEnter; 8139 var enter = data.enter; 8140 var afterEnter = data.afterEnter; 8141 var enterCancelled = data.enterCancelled; 8142 var beforeAppear = data.beforeAppear; 8143 var appear = data.appear; 8144 var afterAppear = data.afterAppear; 8145 var appearCancelled = data.appearCancelled; 8146 var duration = data.duration; 8147 8148 // activeInstance will always be the <transition> component managing this 8149 // transition. One edge case to check is when the <transition> is placed 8150 // as the root node of a child component. In that case we need to check 8151 // <transition>'s parent for appear check. 8152 var context = activeInstance; 8153 var transitionNode = activeInstance.$vnode; 8154 while (transitionNode && transitionNode.parent) { 8155 context = transitionNode.context; 8156 transitionNode = transitionNode.parent; 8157 } 8158 8159 var isAppear = !context._isMounted || !vnode.isRootInsert; 8160 8161 if (isAppear && !appear && appear !== '') { 8162 return 8163 } 8164 8165 var startClass = isAppear && appearClass 8166 ? appearClass 8167 : enterClass; 8168 var activeClass = isAppear && appearActiveClass 8169 ? appearActiveClass 8170 : enterActiveClass; 8171 var toClass = isAppear && appearToClass 8172 ? appearToClass 8173 : enterToClass; 8174 8175 var beforeEnterHook = isAppear 8176 ? (beforeAppear || beforeEnter) 8177 : beforeEnter; 8178 var enterHook = isAppear 8179 ? (typeof appear === 'function' ? appear : enter) 8180 : enter; 8181 var afterEnterHook = isAppear 8182 ? (afterAppear || afterEnter) 8183 : afterEnter; 8184 var enterCancelledHook = isAppear 8185 ? (appearCancelled || enterCancelled) 8186 : enterCancelled; 8187 8188 var explicitEnterDuration = toNumber( 8189 isObject(duration) 8190 ? duration.enter 8191 : duration 8192 ); 8193 8194 if (explicitEnterDuration != null) { 8195 checkDuration(explicitEnterDuration, 'enter', vnode); 8196 } 8197 8198 var expectsCSS = css !== false && !isIE9; 8199 var userWantsControl = getHookArgumentsLength(enterHook); 8200 8201 var cb = el._enterCb = once(function () { 8202 if (expectsCSS) { 8203 removeTransitionClass(el, toClass); 8204 removeTransitionClass(el, activeClass); 8205 } 8206 if (cb.cancelled) { 8207 if (expectsCSS) { 8208 removeTransitionClass(el, startClass); 8209 } 8210 enterCancelledHook && enterCancelledHook(el); 8211 } else { 8212 afterEnterHook && afterEnterHook(el); 8213 } 8214 el._enterCb = null; 8215 }); 8216 8217 if (!vnode.data.show) { 8218 // remove pending leave element on enter by injecting an insert hook 8219 mergeVNodeHook(vnode, 'insert', function () { 8220 var parent = el.parentNode; 8221 var pendingNode = parent && parent._pending && parent._pending[vnode.key]; 8222 if (pendingNode && 8223 pendingNode.tag === vnode.tag && 8224 pendingNode.elm._leaveCb 8225 ) { 8226 pendingNode.elm._leaveCb(); 8227 } 8228 enterHook && enterHook(el, cb); 8229 }); 8230 } 8231 8232 // start enter transition 8233 beforeEnterHook && beforeEnterHook(el); 8234 if (expectsCSS) { 8235 addTransitionClass(el, startClass); 8236 addTransitionClass(el, activeClass); 8237 nextFrame(function () { 8238 removeTransitionClass(el, startClass); 8239 if (!cb.cancelled) { 8240 addTransitionClass(el, toClass); 8241 if (!userWantsControl) { 8242 if (isValidDuration(explicitEnterDuration)) { 8243 setTimeout(cb, explicitEnterDuration); 8244 } else { 8245 whenTransitionEnds(el, type, cb); 8246 } 8247 } 8248 } 8249 }); 8250 } 8251 8252 if (vnode.data.show) { 8253 toggleDisplay && toggleDisplay(); 8254 enterHook && enterHook(el, cb); 8255 } 8256 8257 if (!expectsCSS && !userWantsControl) { 8258 cb(); 8259 } 8260 } 8261 8262 function leave (vnode, rm) { 8263 var el = vnode.elm; 8264 8265 // call enter callback now 8266 if (isDef(el._enterCb)) { 8267 el._enterCb.cancelled = true; 8268 el._enterCb(); 8269 } 8270 8271 var data = resolveTransition(vnode.data.transition); 8272 if (isUndef(data) || el.nodeType !== 1) { 8273 return rm() 8274 } 8275 8276 /* istanbul ignore if */ 8277 if (isDef(el._leaveCb)) { 8278 return 8279 } 8280 8281 var css = data.css; 8282 var type = data.type; 8283 var leaveClass = data.leaveClass; 8284 var leaveToClass = data.leaveToClass; 8285 var leaveActiveClass = data.leaveActiveClass; 8286 var beforeLeave = data.beforeLeave; 8287 var leave = data.leave; 8288 var afterLeave = data.afterLeave; 8289 var leaveCancelled = data.leaveCancelled; 8290 var delayLeave = data.delayLeave; 8291 var duration = data.duration; 8292 8293 var expectsCSS = css !== false && !isIE9; 8294 var userWantsControl = getHookArgumentsLength(leave); 8295 8296 var explicitLeaveDuration = toNumber( 8297 isObject(duration) 8298 ? duration.leave 8299 : duration 8300 ); 8301 8302 if (isDef(explicitLeaveDuration)) { 8303 checkDuration(explicitLeaveDuration, 'leave', vnode); 8304 } 8305 8306 var cb = el._leaveCb = once(function () { 8307 if (el.parentNode && el.parentNode._pending) { 8308 el.parentNode._pending[vnode.key] = null; 8309 } 8310 if (expectsCSS) { 8311 removeTransitionClass(el, leaveToClass); 8312 removeTransitionClass(el, leaveActiveClass); 8313 } 8314 if (cb.cancelled) { 8315 if (expectsCSS) { 8316 removeTransitionClass(el, leaveClass); 8317 } 8318 leaveCancelled && leaveCancelled(el); 8319 } else { 8320 rm(); 8321 afterLeave && afterLeave(el); 8322 } 8323 el._leaveCb = null; 8324 }); 8325 8326 if (delayLeave) { 8327 delayLeave(performLeave); 8328 } else { 8329 performLeave(); 8330 } 8331 8332 function performLeave () { 8333 // the delayed leave may have already been cancelled 8334 if (cb.cancelled) { 8335 return 8336 } 8337 // record leaving element 8338 if (!vnode.data.show && el.parentNode) { 8339 (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode; 8340 } 8341 beforeLeave && beforeLeave(el); 8342 if (expectsCSS) { 8343 addTransitionClass(el, leaveClass); 8344 addTransitionClass(el, leaveActiveClass); 8345 nextFrame(function () { 8346 removeTransitionClass(el, leaveClass); 8347 if (!cb.cancelled) { 8348 addTransitionClass(el, leaveToClass); 8349 if (!userWantsControl) { 8350 if (isValidDuration(explicitLeaveDuration)) { 8351 setTimeout(cb, explicitLeaveDuration); 8352 } else { 8353 whenTransitionEnds(el, type, cb); 8354 } 8355 } 8356 } 8357 }); 8358 } 8359 leave && leave(el, cb); 8360 if (!expectsCSS && !userWantsControl) { 8361 cb(); 8362 } 8363 } 8364 } 8365 8366 // only used in dev mode 8367 function checkDuration (val, name, vnode) { 8368 if (typeof val !== 'number') { 8369 warn( 8370 "<transition> explicit " + name + " duration is not a valid number - " + 8371 "got " + (JSON.stringify(val)) + ".", 8372 vnode.context 8373 ); 8374 } else if (isNaN(val)) { 8375 warn( 8376 "<transition> explicit " + name + " duration is NaN - " + 8377 'the duration expression might be incorrect.', 8378 vnode.context 8379 ); 8380 } 8381 } 8382 8383 function isValidDuration (val) { 8384 return typeof val === 'number' && !isNaN(val) 8385 } 8386 8387 /** 8388 * Normalize a transition hook's argument length. The hook may be: 8389 * - a merged hook (invoker) with the original in .fns 8390 * - a wrapped component method (check ._length) 8391 * - a plain function (.length) 8392 */ 8393 function getHookArgumentsLength (fn) { 8394 if (isUndef(fn)) { 8395 return false 8396 } 8397 var invokerFns = fn.fns; 8398 if (isDef(invokerFns)) { 8399 // invoker 8400 return getHookArgumentsLength( 8401 Array.isArray(invokerFns) 8402 ? invokerFns[0] 8403 : invokerFns 8404 ) 8405 } else { 8406 return (fn._length || fn.length) > 1 8407 } 8408 } 8409 8410 function _enter (_, vnode) { 8411 if (vnode.data.show !== true) { 8412 enter(vnode); 8413 } 8414 } 8415 8416 var transition = inBrowser ? { 8417 create: _enter, 8418 activate: _enter, 8419 remove: function remove$$1 (vnode, rm) { 8420 /* istanbul ignore else */ 8421 if (vnode.data.show !== true) { 8422 leave(vnode, rm); 8423 } else { 8424 rm(); 8425 } 8426 } 8427 } : {}; 8428 8429 var platformModules = [ 8430 attrs, 8431 klass, 8432 events, 8433 domProps, 8434 style, 8435 transition 8436 ]; 8437 8438 /* */ 8439 8440 // the directive module should be applied last, after all 8441 // built-in modules have been applied. 8442 var modules = platformModules.concat(baseModules); 8443 8444 var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules }); 8445 8446 /** 8447 * Not type checking this file because flow doesn't like attaching 8448 * properties to Elements. 8449 */ 8450 8451 /* istanbul ignore if */ 8452 if (isIE9) { 8453 // http://www.matts411.com/post/internet-explorer-9-oninput/ 8454 document.addEventListener('selectionchange', function () { 8455 var el = document.activeElement; 8456 if (el && el.vmodel) { 8457 trigger(el, 'input'); 8458 } 8459 }); 8460 } 8461 8462 var directive = { 8463 inserted: function inserted (el, binding, vnode, oldVnode) { 8464 if (vnode.tag === 'select') { 8465 // #6903 8466 if (oldVnode.elm && !oldVnode.elm._vOptions) { 8467 mergeVNodeHook(vnode, 'postpatch', function () { 8468 directive.componentUpdated(el, binding, vnode); 8469 }); 8470 } else { 8471 setSelected(el, binding, vnode.context); 8472 } 8473 el._vOptions = [].map.call(el.options, getValue); 8474 } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) { 8475 el._vModifiers = binding.modifiers; 8476 if (!binding.modifiers.lazy) { 8477 el.addEventListener('compositionstart', onCompositionStart); 8478 el.addEventListener('compositionend', onCompositionEnd); 8479 // Safari < 10.2 & UIWebView doesn't fire compositionend when 8480 // switching focus before confirming composition choice 8481 // this also fixes the issue where some browsers e.g. iOS Chrome 8482 // fires "change" instead of "input" on autocomplete. 8483 el.addEventListener('change', onCompositionEnd); 8484 /* istanbul ignore if */ 8485 if (isIE9) { 8486 el.vmodel = true; 8487 } 8488 } 8489 } 8490 }, 8491 8492 componentUpdated: function componentUpdated (el, binding, vnode) { 8493 if (vnode.tag === 'select') { 8494 setSelected(el, binding, vnode.context); 8495 // in case the options rendered by v-for have changed, 8496 // it's possible that the value is out-of-sync with the rendered options. 8497 // detect such cases and filter out values that no longer has a matching 8498 // option in the DOM. 8499 var prevOptions = el._vOptions; 8500 var curOptions = el._vOptions = [].map.call(el.options, getValue); 8501 if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) { 8502 // trigger change event if 8503 // no matching option found for at least one value 8504 var needReset = el.multiple 8505 ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); }) 8506 : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions); 8507 if (needReset) { 8508 trigger(el, 'change'); 8509 } 8510 } 8511 } 8512 } 8513 }; 8514 8515 function setSelected (el, binding, vm) { 8516 actuallySetSelected(el, binding, vm); 8517 /* istanbul ignore if */ 8518 if (isIE || isEdge) { 8519 setTimeout(function () { 8520 actuallySetSelected(el, binding, vm); 8521 }, 0); 8522 } 8523 } 8524 8525 function actuallySetSelected (el, binding, vm) { 8526 var value = binding.value; 8527 var isMultiple = el.multiple; 8528 if (isMultiple && !Array.isArray(value)) { 8529 warn( 8530 "<select multiple v-model=\"" + (binding.expression) + "\"> " + 8531 "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)), 8532 vm 8533 ); 8534 return 8535 } 8536 var selected, option; 8537 for (var i = 0, l = el.options.length; i < l; i++) { 8538 option = el.options[i]; 8539 if (isMultiple) { 8540 selected = looseIndexOf(value, getValue(option)) > -1; 8541 if (option.selected !== selected) { 8542 option.selected = selected; 8543 } 8544 } else { 8545 if (looseEqual(getValue(option), value)) { 8546 if (el.selectedIndex !== i) { 8547 el.selectedIndex = i; 8548 } 8549 return 8550 } 8551 } 8552 } 8553 if (!isMultiple) { 8554 el.selectedIndex = -1; 8555 } 8556 } 8557 8558 function hasNoMatchingOption (value, options) { 8559 return options.every(function (o) { return !looseEqual(o, value); }) 8560 } 8561 8562 function getValue (option) { 8563 return '_value' in option 8564 ? option._value 8565 : option.value 8566 } 8567 8568 function onCompositionStart (e) { 8569 e.target.composing = true; 8570 } 8571 8572 function onCompositionEnd (e) { 8573 // prevent triggering an input event for no reason 8574 if (!e.target.composing) { return } 8575 e.target.composing = false; 8576 trigger(e.target, 'input'); 8577 } 8578 8579 function trigger (el, type) { 8580 var e = document.createEvent('HTMLEvents'); 8581 e.initEvent(type, true, true); 8582 el.dispatchEvent(e); 8583 } 8584 8585 /* */ 8586 8587 // recursively search for possible transition defined inside the component root 8588 function locateNode (vnode) { 8589 return vnode.componentInstance && (!vnode.data || !vnode.data.transition) 8590 ? locateNode(vnode.componentInstance._vnode) 8591 : vnode 8592 } 8593 8594 var show = { 8595 bind: function bind (el, ref, vnode) { 8596 var value = ref.value; 8597 8598 vnode = locateNode(vnode); 8599 var transition$$1 = vnode.data && vnode.data.transition; 8600 var originalDisplay = el.__vOriginalDisplay = 8601 el.style.display === 'none' ? '' : el.style.display; 8602 if (value && transition$$1) { 8603 vnode.data.show = true; 8604 enter(vnode, function () { 8605 el.style.display = originalDisplay; 8606 }); 8607 } else { 8608 el.style.display = value ? originalDisplay : 'none'; 8609 } 8610 }, 8611 8612 update: function update (el, ref, vnode) { 8613 var value = ref.value; 8614 var oldValue = ref.oldValue; 8615 8616 /* istanbul ignore if */ 8617 if (!value === !oldValue) { return } 8618 vnode = locateNode(vnode); 8619 var transition$$1 = vnode.data && vnode.data.transition; 8620 if (transition$$1) { 8621 vnode.data.show = true; 8622 if (value) { 8623 enter(vnode, function () { 8624 el.style.display = el.__vOriginalDisplay; 8625 }); 8626 } else { 8627 leave(vnode, function () { 8628 el.style.display = 'none'; 8629 }); 8630 } 8631 } else { 8632 el.style.display = value ? el.__vOriginalDisplay : 'none'; 8633 } 8634 }, 8635 8636 unbind: function unbind ( 8637 el, 8638 binding, 8639 vnode, 8640 oldVnode, 8641 isDestroy 8642 ) { 8643 if (!isDestroy) { 8644 el.style.display = el.__vOriginalDisplay; 8645 } 8646 } 8647 }; 8648 8649 var platformDirectives = { 8650 model: directive, 8651 show: show 8652 }; 8653 8654 /* */ 8655 8656 var transitionProps = { 8657 name: String, 8658 appear: Boolean, 8659 css: Boolean, 8660 mode: String, 8661 type: String, 8662 enterClass: String, 8663 leaveClass: String, 8664 enterToClass: String, 8665 leaveToClass: String, 8666 enterActiveClass: String, 8667 leaveActiveClass: String, 8668 appearClass: String, 8669 appearActiveClass: String, 8670 appearToClass: String, 8671 duration: [Number, String, Object] 8672 }; 8673 8674 // in case the child is also an abstract component, e.g. <keep-alive> 8675 // we want to recursively retrieve the real component to be rendered 8676 function getRealChild (vnode) { 8677 var compOptions = vnode && vnode.componentOptions; 8678 if (compOptions && compOptions.Ctor.options.abstract) { 8679 return getRealChild(getFirstComponentChild(compOptions.children)) 8680 } else { 8681 return vnode 8682 } 8683 } 8684 8685 function extractTransitionData (comp) { 8686 var data = {}; 8687 var options = comp.$options; 8688 // props 8689 for (var key in options.propsData) { 8690 data[key] = comp[key]; 8691 } 8692 // events. 8693 // extract listeners and pass them directly to the transition methods 8694 var listeners = options._parentListeners; 8695 for (var key$1 in listeners) { 8696 data[camelize(key$1)] = listeners[key$1]; 8697 } 8698 return data 8699 } 8700 8701 function placeholder (h, rawChild) { 8702 if (/\d-keep-alive$/.test(rawChild.tag)) { 8703 return h('keep-alive', { 8704 props: rawChild.componentOptions.propsData 8705 }) 8706 } 8707 } 8708 8709 function hasParentTransition (vnode) { 8710 while ((vnode = vnode.parent)) { 8711 if (vnode.data.transition) { 8712 return true 8713 } 8714 } 8715 } 8716 8717 function isSameChild (child, oldChild) { 8718 return oldChild.key === child.key && oldChild.tag === child.tag 8719 } 8720 8721 var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); }; 8722 8723 var isVShowDirective = function (d) { return d.name === 'show'; }; 8724 8725 var Transition = { 8726 name: 'transition', 8727 props: transitionProps, 8728 abstract: true, 8729 8730 render: function render (h) { 8731 var this$1 = this; 8732 8733 var children = this.$slots.default; 8734 if (!children) { 8735 return 8736 } 8737 8738 // filter out text nodes (possible whitespaces) 8739 children = children.filter(isNotTextNode); 8740 /* istanbul ignore if */ 8741 if (!children.length) { 8742 return 8743 } 8744 8745 // warn multiple elements 8746 if (children.length > 1) { 8747 warn( 8748 '<transition> can only be used on a single element. Use ' + 8749 '<transition-group> for lists.', 8750 this.$parent 8751 ); 8752 } 8753 8754 var mode = this.mode; 8755 8756 // warn invalid mode 8757 if (mode && mode !== 'in-out' && mode !== 'out-in' 8758 ) { 8759 warn( 8760 'invalid <transition> mode: ' + mode, 8761 this.$parent 8762 ); 8763 } 8764 8765 var rawChild = children[0]; 8766 8767 // if this is a component root node and the component's 8768 // parent container node also has transition, skip. 8769 if (hasParentTransition(this.$vnode)) { 8770 return rawChild 8771 } 8772 8773 // apply transition data to child 8774 // use getRealChild() to ignore abstract components e.g. keep-alive 8775 var child = getRealChild(rawChild); 8776 /* istanbul ignore if */ 8777 if (!child) { 8778 return rawChild 8779 } 8780 8781 if (this._leaving) { 8782 return placeholder(h, rawChild) 8783 } 8784 8785 // ensure a key that is unique to the vnode type and to this transition 8786 // component instance. This key will be used to remove pending leaving nodes 8787 // during entering. 8788 var id = "__transition-" + (this._uid) + "-"; 8789 child.key = child.key == null 8790 ? child.isComment 8791 ? id + 'comment' 8792 : id + child.tag 8793 : isPrimitive(child.key) 8794 ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key) 8795 : child.key; 8796 8797 var data = (child.data || (child.data = {})).transition = extractTransitionData(this); 8798 var oldRawChild = this._vnode; 8799 var oldChild = getRealChild(oldRawChild); 8800 8801 // mark v-show 8802 // so that the transition module can hand over the control to the directive 8803 if (child.data.directives && child.data.directives.some(isVShowDirective)) { 8804 child.data.show = true; 8805 } 8806 8807 if ( 8808 oldChild && 8809 oldChild.data && 8810 !isSameChild(child, oldChild) && 8811 !isAsyncPlaceholder(oldChild) && 8812 // #6687 component root is a comment node 8813 !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment) 8814 ) { 8815 // replace old child transition data with fresh one 8816 // important for dynamic transitions! 8817 var oldData = oldChild.data.transition = extend({}, data); 8818 // handle transition mode 8819 if (mode === 'out-in') { 8820 // return placeholder node and queue update when leave finishes 8821 this._leaving = true; 8822 mergeVNodeHook(oldData, 'afterLeave', function () { 8823 this$1._leaving = false; 8824 this$1.$forceUpdate(); 8825 }); 8826 return placeholder(h, rawChild) 8827 } else if (mode === 'in-out') { 8828 if (isAsyncPlaceholder(child)) { 8829 return oldRawChild 8830 } 8831 var delayedLeave; 8832 var performLeave = function () { delayedLeave(); }; 8833 mergeVNodeHook(data, 'afterEnter', performLeave); 8834 mergeVNodeHook(data, 'enterCancelled', performLeave); 8835 mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; }); 8836 } 8837 } 8838 8839 return rawChild 8840 } 8841 }; 8842 8843 /* */ 8844 8845 var props = extend({ 8846 tag: String, 8847 moveClass: String 8848 }, transitionProps); 8849 8850 delete props.mode; 8851 8852 var TransitionGroup = { 8853 props: props, 8854 8855 beforeMount: function beforeMount () { 8856 var this$1 = this; 8857 8858 var update = this._update; 8859 this._update = function (vnode, hydrating) { 8860 var restoreActiveInstance = setActiveInstance(this$1); 8861 // force removing pass 8862 this$1.__patch__( 8863 this$1._vnode, 8864 this$1.kept, 8865 false, // hydrating 8866 true // removeOnly (!important, avoids unnecessary moves) 8867 ); 8868 this$1._vnode = this$1.kept; 8869 restoreActiveInstance(); 8870 update.call(this$1, vnode, hydrating); 8871 }; 8872 }, 8873 8874 render: function render (h) { 8875 var tag = this.tag || this.$vnode.data.tag || 'span'; 8876 var map = Object.create(null); 8877 var prevChildren = this.prevChildren = this.children; 8878 var rawChildren = this.$slots.default || []; 8879 var children = this.children = []; 8880 var transitionData = extractTransitionData(this); 8881 8882 for (var i = 0; i < rawChildren.length; i++) { 8883 var c = rawChildren[i]; 8884 if (c.tag) { 8885 if (c.key != null && String(c.key).indexOf('__vlist') !== 0) { 8886 children.push(c); 8887 map[c.key] = c 8888 ;(c.data || (c.data = {})).transition = transitionData; 8889 } else {
8890 var opts = c.componentOptions; 8891 var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag; 8892 warn(("<transition-group> children must be keyed: <" + name + ">")); 8893 } 8894 } 8895 } 8896 8897 if (prevChildren) { 8898 var kept = []; 8899 var removed = []; 8900 for (var i$1 = 0; i$1 < prevChildren.length; i$1++) { 8901 var c$1 = prevChildren[i$1]; 8902 c$1.data.transition = transitionData; 8903 c$1.data.pos = c$1.elm.getBoundingClientRect(); 8904 if (map[c$1.key]) { 8905 kept.push(c$1); 8906 } else { 8907 removed.push(c$1); 8908 } 8909 } 8910 this.kept = h(tag, null, kept); 8911 this.removed = removed; 8912 } 8913 8914 return h(tag, null, children) 8915 }, 8916 8917 updated: function updated () { 8918 var children = this.prevChildren; 8919 var moveClass = this.moveClass || ((this.name || 'v') + '-move'); 8920 if (!children.length || !this.hasMove(children[0].elm, moveClass)) { 8921 return 8922 } 8923 8924 // we divide the work into three loops to avoid mixing DOM reads and writes 8925 // in each iteration - which helps prevent layout thrashing. 8926 children.forEach(callPendingCbs); 8927 children.forEach(recordPosition); 8928 children.forEach(applyTranslation); 8929 8930 // force reflow to put everything in position 8931 // assign to this to avoid being removed in tree-shaking 8932 // $flow-disable-line 8933 this._reflow = document.body.offsetHeight; 8934 8935 children.forEach(function (c) { 8936 if (c.data.moved) { 8937 var el = c.elm; 8938 var s = el.style; 8939 addTransitionClass(el, moveClass); 8940 s.transform = s.WebkitTransform = s.transitionDuration = ''; 8941 el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) { 8942 if (e && e.target !== el) { 8943 return 8944 } 8945 if (!e || /transform$/.test(e.propertyName)) { 8946 el.removeEventListener(transitionEndEvent, cb); 8947 el._moveCb = null; 8948 removeTransitionClass(el, moveClass); 8949 } 8950 }); 8951 } 8952 }); 8953 }, 8954 8955 methods: { 8956 hasMove: function hasMove (el, moveClass) { 8957 /* istanbul ignore if */ 8958 if (!hasTransition) { 8959 return false 8960 } 8961 /* istanbul ignore if */ 8962 if (this._hasMove) { 8963 return this._hasMove 8964 } 8965 // Detect whether an element with the move class applied has 8966 // CSS transitions. Since the element may be inside an entering 8967 // transition at this very moment, we make a clone of it and remove 8968 // all other transition classes applied to ensure only the move class 8969 // is applied. 8970 var clone = el.cloneNode(); 8971 if (el._transitionClasses) { 8972 el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); }); 8973 } 8974 addClass(clone, moveClass); 8975 clone.style.display = 'none'; 8976 this.$el.appendChild(clone); 8977 var info = getTransitionInfo(clone); 8978 this.$el.removeChild(clone); 8979 return (this._hasMove = info.hasTransform) 8980 } 8981 } 8982 }; 8983 8984 function callPendingCbs (c) { 8985 /* istanbul ignore if */ 8986 if (c.elm._moveCb) { 8987 c.elm._moveCb(); 8988 } 8989 /* istanbul ignore if */ 8990 if (c.elm._enterCb) { 8991 c.elm._enterCb(); 8992 } 8993 } 8994 8995 function recordPosition (c) { 8996 c.data.newPos = c.elm.getBoundingClientRect(); 8997 } 8998 8999 function applyTranslation (c) { 9000 var oldPos = c.data.pos; 9001 var newPos = c.data.newPos; 9002 var dx = oldPos.left - newPos.left; 9003 var dy = oldPos.top - newPos.top; 9004 if (dx || dy) { 9005 c.data.moved = true; 9006 var s = c.elm.style; 9007 s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)"; 9008 s.transitionDuration = '0s'; 9009 } 9010 } 9011 9012 var platformComponents = { 9013 Transition: Transition, 9014 TransitionGroup: TransitionGroup 9015 }; 9016 9017 /* */ 9018 9019 // install platform specific utils 9020 Vue.config.mustUseProp = mustUseProp; 9021 Vue.config.isReservedTag = isReservedTag; 9022 Vue.config.isReservedAttr = isReservedAttr; 9023 Vue.config.getTagNamespace = getTagNamespace; 9024 Vue.config.isUnknownElement = isUnknownElement; 9025 9026 // install platform runtime directives & components 9027 extend(Vue.options.directives, platformDirectives); 9028 extend(Vue.options.components, platformComponents); 9029 9030 // install platform patch function 9031 Vue.prototype.__patch__ = inBrowser ? patch : noop; 9032 9033 // public mount method 9034 Vue.prototype.$mount = function ( 9035 el, 9036 hydrating 9037 ) { 9038 el = el && inBrowser ? query(el) : undefined; 9039 return mountComponent(this, el, hydrating) 9040 }; 9041 9042 // devtools global hook 9043 /* istanbul ignore next */ 9044 if (inBrowser) { 9045 setTimeout(function () { 9046 if (config.devtools) { 9047 if (devtools) { 9048 devtools.emit('init', Vue); 9049 } else { 9050 console[console.info ? 'info' : 'log']( 9051 'Download the Vue Devtools extension for a better development experience:\n' + 9052 'https://github.com/vuejs/vue-devtools' 9053 ); 9054 } 9055 } 9056 if (config.productionTip !== false && 9057 typeof console !== 'undefined' 9058 ) { 9059 console[console.info ? 'info' : 'log']( 9060 "You are running Vue in development mode.\n" + 9061 "Make sure to turn on production mode when deploying for production.\n" + 9062 "See more tips at https://vuejs.org/guide/deployment.html" 9063 ); 9064 } 9065 }, 0); 9066 } 9067 9068 /* */ 9069 9070 var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g; 9071 var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g; 9072 9073 var buildRegex = cached(function (delimiters) { 9074 var open = delimiters[0].replace(regexEscapeRE, '\\$&'); 9075 var close = delimiters[1].replace(regexEscapeRE, '\\$&'); 9076 return new RegExp(open + '((?:.|\\n)+?)' + close, 'g') 9077 }); 9078 9079 9080 9081 function parseText ( 9082 text, 9083 delimiters 9084 ) { 9085 var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE; 9086 if (!tagRE.test(text)) { 9087 return 9088 } 9089 var tokens = []; 9090 var rawTokens = []; 9091 var lastIndex = tagRE.lastIndex = 0; 9092 var match, index, tokenValue; 9093 while ((match = tagRE.exec(text))) { 9094 index = match.index; 9095 // push text token 9096 if (index > lastIndex) { 9097 rawTokens.push(tokenValue = text.slice(lastIndex, index)); 9098 tokens.push(JSON.stringify(tokenValue)); 9099 } 9100 // tag token 9101 var exp = parseFilters(match[1].trim()); 9102 tokens.push(("_s(" + exp + ")")); 9103 rawTokens.push({ '@binding': exp }); 9104 lastIndex = index + match[0].length; 9105 } 9106 if (lastIndex < text.length) { 9107 rawTokens.push(tokenValue = text.slice(lastIndex)); 9108 tokens.push(JSON.stringify(tokenValue)); 9109 } 9110 return { 9111 expression: tokens.join('+'), 9112 tokens: rawTokens 9113 } 9114 } 9115 9116 /* */ 9117 9118 function transformNode (el, options) { 9119 var warn = options.warn || baseWarn; 9120 var staticClass = getAndRemoveAttr(el, 'class'); 9121 if (staticClass) { 9122 var res = parseText(staticClass, options.delimiters); 9123 if (res) { 9124 warn( 9125 "class=\"" + staticClass + "\": " + 9126 'Interpolation inside attributes has been removed. ' + 9127 'Use v-bind or the colon shorthand instead. For example, ' + 9128 'instead of <div class="{{ val }}">, use <div :class="val">.', 9129 el.rawAttrsMap['class'] 9130 ); 9131 } 9132 } 9133 if (staticClass) { 9134 el.staticClass = JSON.stringify(staticClass); 9135 } 9136 var classBinding = getBindingAttr(el, 'class', false /* getStatic */); 9137 if (classBinding) { 9138 el.classBinding = classBinding; 9139 } 9140 } 9141 9142 function genData (el) { 9143 var data = ''; 9144 if (el.staticClass) { 9145 data += "staticClass:" + (el.staticClass) + ","; 9146 } 9147 if (el.classBinding) { 9148 data += "class:" + (el.classBinding) + ","; 9149 } 9150 return data 9151 } 9152 9153 var klass$1 = { 9154 staticKeys: ['staticClass'], 9155 transformNode: transformNode, 9156 genData: genData 9157 }; 9158 9159 /* */ 9160 9161 function transformNode$1 (el, options) { 9162 var warn = options.warn || baseWarn; 9163 var staticStyle = getAndRemoveAttr(el, 'style'); 9164 if (staticStyle) { 9165 /* istanbul ignore if */ 9166 { 9167 var res = parseText(staticStyle, options.delimiters); 9168 if (res) { 9169 warn( 9170 "style=\"" + staticStyle + "\": " + 9171 'Interpolation inside attributes has been removed. ' + 9172 'Use v-bind or the colon shorthand instead. For example, ' + 9173 'instead of <div style="{{ val }}">, use <div :style="val">.', 9174 el.rawAttrsMap['style'] 9175 ); 9176 } 9177 } 9178 el.staticStyle = JSON.stringify(parseStyleText(staticStyle)); 9179 } 9180 9181 var styleBinding = getBindingAttr(el, 'style', false /* getStatic */); 9182 if (styleBinding) { 9183 el.styleBinding = styleBinding; 9184 } 9185 } 9186 9187 function genData$1 (el) { 9188 var data = ''; 9189 if (el.staticStyle) { 9190 data += "staticStyle:" + (el.staticStyle) + ","; 9191 } 9192 if (el.styleBinding) { 9193 data += "style:(" + (el.styleBinding) + "),"; 9194 } 9195 return data 9196 } 9197 9198 var style$1 = { 9199 staticKeys: ['staticStyle'], 9200 transformNode: transformNode$1, 9201 genData: genData$1 9202 }; 9203 9204 /* */ 9205 9206 var decoder; 9207 9208 var he = { 9209 decode: function decode (html) { 9210 decoder = decoder || document.createElement('div'); 9211 decoder.innerHTML = html; 9212 return decoder.textContent 9213 } 9214 }; 9215 9216 /* */ 9217 9218 var isUnaryTag = makeMap( 9219 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + 9220 'link,meta,param,source,track,wbr' 9221 ); 9222 9223 // Elements that you can, intentionally, leave open 9224 // (and which close themselves) 9225 var canBeLeftOpenTag = makeMap( 9226 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source' 9227 ); 9228 9229 // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3 9230 // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content 9231 var isNonPhrasingTag = makeMap( 9232 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' + 9233 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' + 9234 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' + 9235 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' + 9236 'title,tr,track' 9237 ); 9238 9239 /** 9240 * Not type-checking this file because it's mostly vendor code. 9241 */ 9242 9243 // Regular Expressions for parsing tags and attributes 9244 var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; 9245 var dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; 9246 var ncname = "[a-zA-Z_][\\-\\.0-9_a-zA-Z" + (unicodeRegExp.source) + "]*"; 9247 var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")"; 9248 var startTagOpen = new RegExp(("^<" + qnameCapture)); 9249 var startTagClose = /^\s*(\/?)>/; 9250 var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>")); 9251 var doctype = /^<!DOCTYPE [^>]+>/i; 9252 // #7298: escape - to avoid being pased as HTML comment when inlined in page 9253 var comment = /^<!\--/; 9254 var conditionalComment = /^<!\[/; 9255 9256 // Special Elements (can contain anything) 9257 var isPlainTextElement = makeMap('script,style,textarea', true); 9258 var reCache = {}; 9259 9260 var decodingMap = { 9261 '<': '<', 9262 '>': '>', 9263 '"': '"', 9264 '&': '&', 9265 ' ': '\n', 9266 '	': '\t', 9267 ''': "'" 9268 }; 9269 var encodedAttr = /&(?:lt|gt|quot|amp|#39);/g; 9270 var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g; 9271 9272 // #5992 9273 var isIgnoreNewlineTag = makeMap('pre,textarea', true); 9274 var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; }; 9275 9276 function decodeAttr (value, shouldDecodeNewlines) { 9277 var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr; 9278 return value.replace(re, function (match) { return decodingMap[match]; }) 9279 } 9280 9281 function parseHTML (html, options) { 9282 var stack = [];
9283 var expectHTML = options.expectHTML; 9284 var isUnaryTag$$1 = options.isUnaryTag || no; 9285 var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no; 9286 var index = 0; 9287 var last, lastTag; 9288 while (html) { 9289 last = html; 9290 // Make sure we're not in a plaintext content element like script/style 9291 if (!lastTag || !isPlainTextElement(lastTag)) { 9292 var textEnd = html.indexOf('<'); 9293 if (textEnd === 0) { 9294 // Comment: 9295 if (comment.test(html)) { 9296 var commentEnd = html.indexOf('-->'); 9297 9298 if (commentEnd >= 0) { 9299 if (options.shouldKeepComment) { 9300 options.comment(html.substring(4, commentEnd), index, index + commentEnd + 3); 9301 } 9302 advance(commentEnd + 3); 9303 continue 9304 } 9305 } 9306 9307 // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment 9308 if (conditionalComment.test(html)) { 9309 var conditionalEnd = html.indexOf(']>'); 9310 9311 if (conditionalEnd >= 0) { 9312 advance(conditionalEnd + 2); 9313 continue 9314 } 9315 } 9316 9317 // Doctype: 9318 var doctypeMatch = html.match(doctype); 9319 if (doctypeMatch) { 9320 advance(doctypeMatch[0].length); 9321 continue 9322 } 9323 9324 // End tag: 9325 var endTagMatch = html.match(endTag); 9326 if (endTagMatch) { 9327 var curIndex = index; 9328 advance(endTagMatch[0].length); 9329 parseEndTag(endTagMatch[1], curIndex, index); 9330 continue 9331 } 9332 9333 // Start tag: 9334 var startTagMatch = parseStartTag(); 9335 if (startTagMatch) { 9336 handleStartTag(startTagMatch); 9337 if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) { 9338 advance(1); 9339 } 9340 continue 9341 } 9342 } 9343 9344 var text = (void 0), rest = (void 0), next = (void 0); 9345 if (textEnd >= 0) { 9346 rest = html.slice(textEnd); 9347 while ( 9348 !endTag.test(rest) && 9349 !startTagOpen.test(rest) && 9350 !comment.test(rest) && 9351 !conditionalComment.test(rest) 9352 ) { 9353 // < in plain text, be forgiving and treat it as text 9354 next = rest.indexOf('<', 1); 9355 if (next < 0) { break } 9356 textEnd += next; 9357 rest = html.slice(textEnd); 9358 } 9359 text = html.substring(0, textEnd); 9360 } 9361 9362 if (textEnd < 0) { 9363 text = html; 9364 } 9365 9366 if (text) { 9367 advance(text.length); 9368 } 9369 9370 if (options.chars && text) { 9371 options.chars(text, index - text.length, index); 9372 } 9373 } else { 9374 var endTagLength = 0; 9375 var stackedTag = lastTag.toLowerCase(); 9376 var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i')); 9377 var rest$1 = html.replace(reStackedTag, function (all, text, endTag) { 9378 endTagLength = endTag.length; 9379 if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') { 9380 text = text 9381 .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298 9382 .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1'); 9383 } 9384 if (shouldIgnoreFirstNewline(stackedTag, text)) { 9385 text = text.slice(1); 9386 } 9387 if (options.chars) { 9388 options.chars(text); 9389 } 9390 return '' 9391 }); 9392 index += html.length - rest$1.length; 9393 html = rest$1; 9394 parseEndTag(stackedTag, index - endTagLength, index); 9395 } 9396 9397 if (html === last) { 9398 options.chars && options.chars(html); 9399 if (!stack.length && options.warn) { 9400 options.warn(("Mal-formatted tag at end of template: \"" + html + "\""), { start: index + html.length }); 9401 } 9402 break 9403 } 9404 } 9405 9406 // Clean up any remaining tags 9407 parseEndTag(); 9408 9409 function advance (n) { 9410 index += n; 9411 html = html.substring(n); 9412 } 9413 9414 function parseStartTag () { 9415 var start = html.match(startTagOpen); 9416 if (start) { 9417 var match = { 9418 tagName: start[1], 9419 attrs: [], 9420 start: index 9421 }; 9422 advance(start[0].length); 9423 var end, attr; 9424 while (!(end = html.match(startTagClose)) && (attr = html.match(dynamicArgAttribute) || html.match(attribute))) { 9425 attr.start = index; 9426 advance(attr[0].length); 9427 attr.end = index; 9428 match.attrs.push(attr); 9429 } 9430 if (end) { 9431 match.unarySlash = end[1]; 9432 advance(end[0].length); 9433 match.end = index; 9434 return match 9435 } 9436 } 9437 } 9438 9439 function handleStartTag (match) { 9440 var tagName = match.tagName; 9441 var unarySlash = match.unarySlash; 9442 9443 if (expectHTML) { 9444 if (lastTag === 'p' && isNonPhrasingTag(tagName)) { 9445 parseEndTag(lastTag); 9446 } 9447 if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) { 9448 parseEndTag(tagName); 9449 } 9450 } 9451 9452 var unary = isUnaryTag$$1(tagName) || !!unarySlash; 9453 9454 var l = match.attrs.length; 9455 var attrs = new Array(l); 9456 for (var i = 0; i < l; i++) { 9457 var args = match.attrs[i]; 9458 var value = args[3] || args[4] || args[5] || ''; 9459 var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href' 9460 ? options.shouldDecodeNewlinesForHref 9461 : options.shouldDecodeNewlines; 9462 attrs[i] = { 9463 name: args[1], 9464 value: decodeAttr(value, shouldDecodeNewlines) 9465 }; 9466 if (options.outputSourceRange) { 9467 attrs[i].start = args.start + args[0].match(/^\s*/).length; 9468 attrs[i].end = args.end; 9469 } 9470 } 9471 9472 if (!unary) { 9473 stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, end: match.end }); 9474 lastTag = tagName; 9475 } 9476 9477 if (options.start) { 9478 options.start(tagName, attrs, unary, match.start, match.end); 9479 } 9480 } 9481 9482 function parseEndTag (tagName, start, end) { 9483 var pos, lowerCasedTagName; 9484 if (start == null) { start = index; } 9485 if (end == null) { end = index; } 9486 9487 // Find the closest opened tag of the same type 9488 if (tagName) { 9489 lowerCasedTagName = tagName.toLowerCase(); 9490 for (pos = stack.length - 1; pos >= 0; pos--) { 9491 if (stack[pos].lowerCasedTag === lowerCasedTagName) { 9492 break 9493 } 9494 } 9495 } else { 9496 // If no tag name is provided, clean shop 9497 pos = 0; 9498 } 9499 9500 if (pos >= 0) { 9501 // Close all the open elements, up the stack 9502 for (var i = stack.length - 1; i >= pos; i--) { 9503 if (i > pos || !tagName && 9504 options.warn 9505 ) { 9506 options.warn( 9507 ("tag <" + (stack[i].tag) + "> has no matching end tag."), 9508 { start: stack[i].start, end: stack[i].end } 9509 ); 9510 } 9511 if (options.end) { 9512 options.end(stack[i].tag, start, end); 9513 } 9514 } 9515 9516 // Remove the open elements from the stack 9517 stack.length = pos; 9518 lastTag = pos && stack[pos - 1].tag; 9519 } else if (lowerCasedTagName === 'br') { 9520 if (options.start) { 9521 options.start(tagName, [], true, start, end); 9522 } 9523 } else if (lowerCasedTagName === 'p') { 9524 if (options.start) { 9525 options.start(tagName, [], false, start, end); 9526 } 9527 if (options.end) { 9528 options.end(tagName, start, end); 9529 } 9530 } 9531 } 9532 } 9533 9534 /* */ 9535 9536 var onRE = /^@|^v-on:/; 9537 var dirRE = /^v-|^@|^:/; 9538 var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/; 9539 var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; 9540 var stripParensRE = /^\(|\)$/g; 9541 var dynamicArgRE = /^\[.*\]$/; 9542 9543 var argRE = /:(.*)$/; 9544 var bindRE = /^:|^\.|^v-bind:/; 9545 var modifierRE = /\.[^.\]]+(?=[^\]]*$)/g; 9546 9547 var slotRE = /^v-slot(:|$)|^#/; 9548 9549 var lineBreakRE = /[\r\n]/; 9550 var whitespaceRE$1 = /\s+/g; 9551 9552 var invalidAttributeRE = /[\s"'<>\/=]/; 9553
9554 var decodeHTMLCached = cached(he.decode); 9555 9556 var emptySlotScopeToken = "_empty_"; 9557 9558 // configurable state 9559 var warn$2; 9560 var delimiters; 9561 var transforms; 9562 var preTransforms; 9563 var postTransforms; 9564 var platformIsPreTag; 9565 var platformMustUseProp; 9566 var platformGetTagNamespace; 9567 var maybeComponent; 9568 9569 function createASTElement ( 9570 tag, 9571 attrs, 9572 parent 9573 ) { 9574 return { 9575 type: 1, 9576 tag: tag, 9577 attrsList: attrs, 9578 attrsMap: makeAttrsMap(attrs), 9579 rawAttrsMap: {}, 9580 parent: parent, 9581 children: [] 9582 } 9583 } 9584 9585 /** 9586 * Convert HTML string to AST. 9587 */ 9588 function parse ( 9589 template, 9590 options 9591 ) { 9592 warn$2 = options.warn || baseWarn; 9593 9594 platformIsPreTag = options.isPreTag || no; 9595 platformMustUseProp = options.mustUseProp || no; 9596 platformGetTagNamespace = options.getTagNamespace || no; 9597 var isReservedTag = options.isReservedTag || no; 9598 maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); }; 9599 9600 transforms = pluckModuleFunction(options.modules, 'transformNode'); 9601 preTransforms = pluckModuleFunction(options.modules, 'preTransformNode'); 9602 postTransforms = pluckModuleFunction(options.modules, 'postTransformNode'); 9603 9604 delimiters = options.delimiters; 9605 9606 var stack = []; 9607 var preserveWhitespace = options.preserveWhitespace !== false; 9608 var whitespaceOption = options.whitespace; 9609 var root; 9610 var currentParent; 9611 var inVPre = false; 9612 var inPre = false; 9613 var warned = false; 9614 9615 function warnOnce (msg, range) { 9616 if (!warned) { 9617 warned = true; 9618 warn$2(msg, range); 9619 } 9620 } 9621 9622 function closeElement (element) { 9623 trimEndingWhitespace(element); 9624 if (!inVPre && !element.processed) { 9625 element = processElement(element, options); 9626 } 9627 // tree management 9628 if (!stack.length && element !== root) { 9629 // allow root elements with v-if, v-else-if and v-else 9630 if (root.if && (element.elseif || element.else)) { 9631 { 9632 checkRootConstraints(element); 9633 } 9634 addIfCondition(root, { 9635 exp: element.elseif, 9636 block: element 9637 }); 9638 } else { 9639 warnOnce( 9640 "Component template should contain exactly one root element. " + 9641 "If you are using v-if on multiple elements, " + 9642 "use v-else-if to chain them instead.", 9643 { start: element.start } 9644 ); 9645 } 9646 } 9647 if (currentParent && !element.forbidden) { 9648 if (element.elseif || element.else) { 9649 processIfConditions(element, currentParent); 9650 } else { 9651 if (element.slotScope) { 9652 // scoped slot 9653 // keep it in the children list so that v-else(-if) conditions can 9654 // find it as the prev node. 9655 var name = element.slotTarget || '"default"' 9656 ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element; 9657 } 9658 currentParent.children.push(element); 9659 element.parent = currentParent; 9660 } 9661 } 9662 9663 // final children cleanup 9664 // filter out scoped slots 9665 element.children = element.children.filter(function (c) { return !(c).slotScope; }); 9666 // remove trailing whitespace node again 9667 trimEndingWhitespace(element); 9668 9669 // check pre state 9670 if (element.pre) { 9671 inVPre = false; 9672 } 9673 if (platformIsPreTag(element.tag)) { 9674 inPre = false;
9675 } 9676 // apply post-transforms 9677 for (var i = 0; i < postTransforms.length; i++) { 9678 postTransforms[i](element, options); 9679 } 9680 } 9681 9682 function trimEndingWhitespace (el) { 9683 // remove trailing whitespace node 9684 if (!inPre) { 9685 var lastNode; 9686 while ( 9687 (lastNode = el.children[el.children.length - 1]) && 9688 lastNode.type === 3 && 9689 lastNode.text === ' ' 9690 ) { 9691 el.children.pop(); 9692 } 9693 } 9694 } 9695 9696 function checkRootConstraints (el) { 9697 if (el.tag === 'slot' || el.tag === 'template') { 9698 warnOnce( 9699 "Cannot use <" + (el.tag) + "> as component root element because it may " + 9700 'contain multiple nodes.', 9701 { start: el.start } 9702 ); 9703 } 9704 if (el.attrsMap.hasOwnProperty('v-for')) { 9705 warnOnce( 9706 'Cannot use v-for on stateful component root element because ' + 9707 'it renders multiple elements.', 9708 el.rawAttrsMap['v-for'] 9709 ); 9710 } 9711 } 9712 9713 parseHTML(template, { 9714 warn: warn$2, 9715 expectHTML: options.expectHTML, 9716 isUnaryTag: options.isUnaryTag, 9717 canBeLeftOpenTag: options.canBeLeftOpenTag, 9718 shouldDecodeNewlines: options.shouldDecodeNewlines, 9719 shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref, 9720 shouldKeepComment: options.comments, 9721 outputSourceRange: options.outputSourceRange, 9722 start: function start (tag, attrs, unary, start$1, end) { 9723 // check namespace. 9724 // inherit parent ns if there is one 9725 var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag); 9726 9727 // handle IE svg bug 9728 /* istanbul ignore if */ 9729 if (isIE && ns === 'svg') { 9730 attrs = guardIESVGBug(attrs); 9731 } 9732 9733 var element = createASTElement(tag, attrs, currentParent); 9734 if (ns) { 9735 element.ns = ns; 9736 } 9737 9738 { 9739 if (options.outputSourceRange) { 9740 element.start = start$1; 9741 element.end = end; 9742 element.rawAttrsMap = element.attrsList.reduce(function (cumulated, attr) { 9743 cumulated[attr.name] = attr; 9744 return cumulated 9745 }, {}); 9746 } 9747 attrs.forEach(function (attr) { 9748 if (invalidAttributeRE.test(attr.name)) { 9749 warn$2( 9750 "Invalid dynamic argument expression: attribute names cannot contain " + 9751 "spaces, quotes, <, >, / or =.", 9752 { 9753 start: attr.start + attr.name.indexOf("["), 9754 end: attr.start + attr.name.length 9755 } 9756 ); 9757 } 9758 }); 9759 } 9760 9761 if (isForbiddenTag(element) && !isServerRendering()) { 9762 element.forbidden = true; 9763 warn$2( 9764 'Templates should only be responsible for mapping the state to the ' + 9765 'UI. Avoid placing tags with side-effects in your templates, such as ' + 9766 "<" + tag + ">" + ', as they will not be parsed.', 9767 { start: element.start } 9768 ); 9769 } 9770 9771 // apply pre-transforms 9772 for (var i = 0; i < preTransforms.length; i++) { 9773 element = preTransforms[i](element, options) || element; 9774 } 9775 9776 if (!inVPre) { 9777 processPre(element); 9778 if (element.pre) { 9779 inVPre = true; 9780 } 9781 } 9782 if (platformIsPreTag(element.tag)) { 9783 inPre = true; 9784 } 9785 if (inVPre) { 9786 processRawAttrs(element); 9787 } else if (!element.processed) { 9788 // structural directives 9789 processFor(element); 9790 processIf(element); 9791 processOnce(element); 9792 } 9793 9794 if (!root) { 9795 root = element; 9796 { 9797 checkRootConstraints(root); 9798 } 9799 } 9800 9801 if (!unary) { 9802 currentParent = element; 9803 stack.push(element); 9804 } else { 9805 closeElement(element); 9806 } 9807 }, 9808 9809 end: function end (tag, start, end$1) { 9810 var element = stack[stack.length - 1]; 9811 // pop stack 9812 stack.length -= 1; 9813 currentParent = stack[stack.length - 1]; 9814 if (options.outputSourceRange) { 9815 element.end = end$1; 9816 } 9817 closeElement(element); 9818 }, 9819 9820 chars: function chars (text, start, end) { 9821 if (!currentParent) { 9822 { 9823 if (text === template) { 9824 warnOnce( 9825 'Component template requires a root element, rather than just text.', 9826 { start: start } 9827 ); 9828 } else if ((text = text.trim())) { 9829 warnOnce(
9830 ("text \"" + text + "\" outside root element will be ignored."), 9831 { start: start } 9832 ); 9833 } 9834 } 9835 return 9836 } 9837 // IE textarea placeholder bug 9838 /* istanbul ignore if */ 9839 if (isIE && 9840 currentParent.tag === 'textarea' && 9841 currentParent.attrsMap.placeholder === text 9842 ) { 9843 return 9844 } 9845 var children = currentParent.children; 9846 if (inPre || text.trim()) { 9847 text = isTextTag(currentParent) ? text : decodeHTMLCached(text); 9848 } else if (!children.length) { 9849 // remove the whitespace-only node right after an opening tag 9850 text = ''; 9851 } else if (whitespaceOption) { 9852 if (whitespaceOption === 'condense') { 9853 // in condense mode, remove the whitespace node if it contains 9854 // line break, otherwise condense to a single space 9855 text = lineBreakRE.test(text) ? '' : ' '; 9856 } else { 9857 text = ' '; 9858 } 9859 } else { 9860 text = preserveWhitespace ? ' ' : ''; 9861 } 9862 if (text) { 9863 if (!inPre && whitespaceOption === 'condense') { 9864 // condense consecutive whitespaces into single space 9865 text = text.replace(whitespaceRE$1, ' '); 9866 } 9867 var res; 9868 var child; 9869 if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) { 9870 child = { 9871 type: 2, 9872 expression: res.expression, 9873 tokens: res.tokens, 9874 text: text 9875 }; 9876 } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') { 9877 child = { 9878 type: 3, 9879 text: text 9880 }; 9881 } 9882 if (child) { 9883 if (options.outputSourceRange) { 9884 child.start = start; 9885 child.end = end; 9886 } 9887 children.push(child); 9888 } 9889 } 9890 }, 9891 comment: function comment (text, start, end) { 9892 // adding anyting as a sibling to the root node is forbidden 9893 // comments should still be allowed, but ignored 9894 if (currentParent) { 9895 var child = { 9896 type: 3, 9897 text: text, 9898 isComment: true 9899 }; 9900 if (options.outputSourceRange) { 9901 child.start = start; 9902 child.end = end; 9903 } 9904 currentParent.children.push(child); 9905 } 9906 } 9907 }); 9908 return root 9909 } 9910 9911 function processPre (el) { 9912 if (getAndRemoveAttr(el, 'v-pre') != null) { 9913 el.pre = true; 9914 } 9915 } 9916 9917 function processRawAttrs (el) { 9918 var list = el.attrsList; 9919 var len = list.length; 9920 if (len) { 9921 var attrs = el.attrs = new Array(len); 9922 for (var i = 0; i < len; i++) { 9923 attrs[i] = { 9924 name: list[i].name, 9925 value: JSON.stringify(list[i].value) 9926 }; 9927 if (list[i].start != null) { 9928 attrs[i].start = list[i].start; 9929 attrs[i].end = list[i].end; 9930 } 9931 } 9932 } else if (!el.pre) {
9933 // non root node in pre blocks with no attributes 9934 el.plain = true; 9935 } 9936 } 9937 9938 function processElement ( 9939 element, 9940 options 9941 ) { 9942 processKey(element); 9943 9944 // determine whether this is a plain element after 9945 // removing structural attributes 9946 element.plain = ( 9947 !element.key && 9948 !element.scopedSlots && 9949 !element.attrsList.length 9950 ); 9951 9952 processRef(element); 9953 processSlotContent(element); 9954 processSlotOutlet(element); 9955 processComponent(element); 9956 for (var i = 0; i < transforms.length; i++) { 9957 element = transforms[i](element, options) || element; 9958 } 9959 processAttrs(element); 9960 return element 9961 } 9962 9963 function processKey (el) { 9964 var exp = getBindingAttr(el, 'key'); 9965 if (exp) { 9966 { 9967 if (el.tag === 'template') { 9968 warn$2( 9969 "<template> cannot be keyed. Place the key on real elements instead.", 9970 getRawBindingAttr(el, 'key') 9971 ); 9972 } 9973 if (el.for) { 9974 var iterator = el.iterator2 || el.iterator1; 9975 var parent = el.parent; 9976 if (iterator && iterator === exp && parent && parent.tag === 'transition-group') { 9977 warn$2( 9978 "Do not use v-for index as key on <transition-group> children, " + 9979 "this is the same as not using keys.", 9980 getRawBindingAttr(el, 'key'), 9981 true /* tip */ 9982 ); 9983 } 9984 } 9985 } 9986 el.key = exp; 9987 } 9988 } 9989 9990 function processRef (el) { 9991 var ref = getBindingAttr(el, 'ref'); 9992 if (ref) { 9993 el.ref = ref; 9994 el.refInFor = checkInFor(el); 9995 } 9996 } 9997 9998 function processFor (el) { 9999 var exp; 10000 if ((exp = getAndRemoveAttr(el, 'v-for'))) { 10001 var res = parseFor(exp); 10002 if (res) { 10003 extend(el, res); 10004 } else { 10005 warn$2( 10006 ("Invalid v-for expression: " + exp), 10007 el.rawAttrsMap['v-for'] 10008 ); 10009 } 10010 } 10011 } 10012 10013 10014 10015 function parseFor (exp) { 10016 var inMatch = exp.match(forAliasRE); 10017 if (!inMatch) { return } 10018 var res = {}; 10019 res.for = inMatch[2].trim(); 10020 var alias = inMatch[1].trim().replace(stripParensRE, ''); 10021 var iteratorMatch = alias.match(forIteratorRE); 10022 if (iteratorMatch) { 10023 res.alias = alias.replace(forIteratorRE, '').trim(); 10024 res.iterator1 = iteratorMatch[1].trim(); 10025 if (iteratorMatch[2]) { 10026 res.iterator2 = iteratorMatch[2].trim(); 10027 } 10028 } else { 10029 res.alias = alias; 10030 } 10031 return res 10032 } 10033 10034 function processIf (el) { 10035 var exp = getAndRemoveAttr(el, 'v-if'); 10036 if (exp) { 10037 el.if = exp; 10038 addIfCondition(el, { 10039 exp: exp, 10040 block: el 10041 }); 10042 } else { 10043 if (getAndRemoveAttr(el, 'v-else') != null) { 10044 el.else = true; 10045 } 10046 var elseif = getAndRemoveAttr(el, 'v-else-if'); 10047 if (elseif) { 10048 el.elseif = elseif; 10049 } 10050 } 10051 } 10052 10053 function processIfConditions (el, parent) { 10054 var prev = findPrevElement(parent.children); 10055 if (prev && prev.if) { 10056 addIfCondition(prev, { 10057 exp: el.elseif, 10058 block: el 10059 }); 10060 } else { 10061 warn$2( 10062 "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " + 10063 "used on element <" + (el.tag) + "> without corresponding v-if.", 10064 el.rawAttrsMap[el.elseif ? 'v-else-if' : 'v-else'] 10065 ); 10066 } 10067 } 10068 10069 function findPrevElement (children) { 10070 var i = children.length; 10071 while (i--) { 10072 if (children[i].type === 1) { 10073 return children[i] 10074 } else { 10075 if (children[i].text !== ' ') { 10076 warn$2( 10077 "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " + 10078 "will be ignored.", 10079 children[i] 10080 ); 10081 } 10082 children.pop(); 10083 } 10084 } 10085 } 10086 10087 function addIfCondition (el, condition) { 10088 if (!el.ifConditions) { 10089 el.ifConditions = []; 10090 } 10091 el.ifConditions.push(condition); 10092 } 10093 10094 function processOnce (el) { 10095 var once$$1 = getAndRemoveAttr(el, 'v-once'); 10096 if (once$$1 != null) { 10097 el.once = true; 10098 } 10099 } 10100 10101 // handle content being passed to a component as slot,
10102 // e.g. <template slot="xxx">, <div slot-scope="xxx"> 10103 function processSlotContent (el) { 10104 var slotScope; 10105 if (el.tag === 'template') { 10106 slotScope = getAndRemoveAttr(el, 'scope'); 10107 /* istanbul ignore if */ 10108 if (slotScope) { 10109 warn$2( 10110 "the \"scope\" attribute for scoped slots have been deprecated and " + 10111 "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " + 10112 "can also be used on plain elements in addition to <template> to " + 10113 "denote scoped slots.", 10114 el.rawAttrsMap['scope'], 10115 true 10116 ); 10117 } 10118 el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope'); 10119 } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) { 10120 /* istanbul ignore if */ 10121 if (el.attrsMap['v-for']) { 10122 warn$2( 10123 "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " + 10124 "(v-for takes higher priority). Use a wrapper <template> for the " + 10125 "scoped slot to make it clearer.", 10126 el.rawAttrsMap['slot-scope'], 10127 true 10128 ); 10129 } 10130 el.slotScope = slotScope; 10131 } 10132 10133 // slot="xxx" 10134 var slotTarget = getBindingAttr(el, 'slot'); 10135 if (slotTarget) { 10136 el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget; 10137 el.slotTargetDynamic = !!(el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']); 10138 // preserve slot as an attribute for native shadow DOM compat 10139 // only for non-scoped slots. 10140 if (el.tag !== 'template' && !el.slotScope) { 10141 addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot')); 10142 } 10143 } 10144 10145 // 2.6 v-slot syntax 10146 { 10147 if (el.tag === 'template') { 10148 // v-slot on <template> 10149 var slotBinding = getAndRemoveAttrByRegex(el, slotRE); 10150 if (slotBinding) { 10151 { 10152 if (el.slotTarget || el.slotScope) { 10153 warn$2( 10154 "Unexpected mixed usage of different slot syntaxes.", 10155 el 10156 ); 10157 } 10158 if (el.parent && !maybeComponent(el.parent)) { 10159 warn$2( 10160 "<template v-slot> can only appear at the root level inside " + 10161 "the receiving the component", 10162 el 10163 ); 10164 } 10165 } 10166 var ref = getSlotName(slotBinding); 10167 var name = ref.name; 10168 var dynamic = ref.dynamic; 10169 el.slotTarget = name; 10170 el.slotTargetDynamic = dynamic; 10171 el.slotScope = slotBinding.value || emptySlotScopeToken; // force it into a scoped slot for perf 10172 } 10173 } else { 10174 // v-slot on component, denotes default slot 10175 var slotBinding$1 = getAndRemoveAttrByRegex(el, slotRE); 10176 if (slotBinding$1) { 10177 { 10178 if (!maybeComponent(el)) { 10179 warn$2( 10180 "v-slot can only be used on components or <template>.", 10181 slotBinding$1 10182 ); 10183 } 10184 if (el.slotScope || el.slotTarget) { 10185 warn$2( 10186 "Unexpected mixed usage of different slot syntaxes.", 10187 el 10188 ); 10189 } 10190 if (el.scopedSlots) { 10191 warn$2( 10192 "To avoid scope ambiguity, the default slot should also use " + 10193 "<template> syntax when there are other named slots.", 10194 slotBinding$1 10195 ); 10196 } 10197 } 10198 // add the component's children to its default slot 10199 var slots = el.scopedSlots || (el.scopedSlots = {}); 10200 var ref$1 = getSlotName(slotBinding$1); 10201 var name$1 = ref$1.name; 10202 var dynamic$1 = ref$1.dynamic; 10203 var slotContainer = slots[name$1] = createASTElement('template', [], el);
10204 slotContainer.slotTarget = name$1; 10205 slotContainer.slotTargetDynamic = dynamic$1; 10206 slotContainer.children = el.children.filter(function (c) { 10207 if (!c.slotScope) { 10208 c.parent = slotContainer; 10209 return true 10210 } 10211 }); 10212 slotContainer.slotScope = slotBinding$1.value || emptySlotScopeToken; 10213 // remove children as they are returned from scopedSlots now 10214 el.children = []; 10215 // mark el non-plain so data gets generated 10216 el.plain = false; 10217 } 10218 } 10219 } 10220 } 10221 10222 function getSlotName (binding) { 10223 var name = binding.name.replace(slotRE, ''); 10224 if (!name) { 10225 if (binding.name[0] !== '#') { 10226 name = 'default'; 10227 } else { 10228 warn$2( 10229 "v-slot shorthand syntax requires a slot name.", 10230 binding 10231 ); 10232 } 10233 } 10234 return dynamicArgRE.test(name) 10235 // dynamic [name] 10236 ? { name: name.slice(1, -1), dynamic: true } 10237 // static name 10238 : { name: ("\"" + name + "\""), dynamic: false } 10239 } 10240 10241 // handle <slot/> outlets 10242 function processSlotOutlet (el) { 10243 if (el.tag === 'slot') { 10244 el.slotName = getBindingAttr(el, 'name'); 10245 if (el.key) { 10246 warn$2( 10247 "`key` does not work on <slot> because slots are abstract outlets " + 10248 "and can possibly expand into multiple elements. " + 10249 "Use the key on a wrapping element instead.", 10250 getRawBindingAttr(el, 'key') 10251 ); 10252 } 10253 } 10254 } 10255 10256 function processComponent (el) { 10257 var binding; 10258 if ((binding = getBindingAttr(el, 'is'))) { 10259 el.component = binding; 10260 } 10261 if (getAndRemoveAttr(el, 'inline-template') != null) { 10262 el.inlineTemplate = true; 10263 } 10264 } 10265 10266 function processAttrs (el) { 10267 var list = el.attrsList; 10268 var i, l, name, rawName, value, modifiers, syncGen, isDynamic; 10269 for (i = 0, l = list.length; i < l; i++) { 10270 name = rawName = list[i].name; 10271 value = list[i].value; 10272 if (dirRE.test(name)) { 10273 // mark element as dynamic 10274 el.hasBindings = true; 10275 // modifiers 10276 modifiers = parseModifiers(name.replace(dirRE, '')); 10277 // support .foo shorthand syntax for the .prop modifier 10278 if (modifiers) { 10279 name = name.replace(modifierRE, ''); 10280 } 10281 if (bindRE.test(name)) { // v-bind 10282 name = name.replace(bindRE, ''); 10283 value = parseFilters(value); 10284 isDynamic = dynamicArgRE.test(name); 10285 if (isDynamic) { 10286 name = name.slice(1, -1); 10287 } 10288 if ( 10289 value.trim().length === 0 10290 ) { 10291 warn$2( 10292 ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"") 10293 ); 10294 } 10295 if (modifiers) { 10296 if (modifiers.prop && !isDynamic) { 10297 name = camelize(name); 10298 if (name === 'innerHtml') { name = 'innerHTML'; } 10299 } 10300 if (modifiers.camel && !isDynamic) { 10301 name = camelize(name); 10302 } 10303 if (modifiers.sync) { 10304 syncGen = genAssignmentCode(value, "$event"); 10305 if (!isDynamic) { 10306 addHandler( 10307 el, 10308 ("update:" + (camelize(name))), 10309 syncGen, 10310 null, 10311 false, 10312 warn$2, 10313 list[i] 10314 ); 10315 if (hyphenate(name) !== camelize(name)) { 10316 addHandler( 10317 el, 10318 ("update:" + (hyphenate(name))), 10319 syncGen, 10320 null, 10321 false, 10322 warn$2, 10323 list[i] 10324 ); 10325 } 10326 } else { 10327 // handler w/ dynamic event name 10328 addHandler( 10329 el, 10330 ("\"update:\"+(" + name + ")"), 10331 syncGen, 10332 null, 10333 false, 10334 warn$2, 10335 list[i], 10336 true // dynamic 10337 ); 10338 } 10339 } 10340 } 10341 if ((modifiers && modifiers.prop) || ( 10342 !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name) 10343 )) { 10344 addProp(el, name, value, list[i], isDynamic); 10345 } else { 10346 addAttr(el, name, value, list[i], isDynamic); 10347 } 10348 } else if (onRE.test(name)) { // v-on 10349 name = name.replace(onRE, ''); 10350 isDynamic = dynamicArgRE.test(name); 10351 if (isDynamic) { 10352 name = name.slice(1, -1); 10353 } 10354 addHandler(el, name, value, modifiers, false, warn$2, list[i], isDynamic); 10355 } else { // normal directives 10356 name = name.replace(dirRE, ''); 10357 // parse arg 10358 var argMatch = name.match(argRE); 10359 var arg = argMatch && argMatch[1]; 10360 isDynamic = false;
10361 if (arg) { 10362 name = name.slice(0, -(arg.length + 1)); 10363 if (dynamicArgRE.test(arg)) { 10364 arg = arg.slice(1, -1); 10365 isDynamic = true; 10366 } 10367 } 10368 addDirective(el, name, rawName, value, arg, isDynamic, modifiers, list[i]); 10369 if (name === 'model') { 10370 checkForAliasModel(el, value); 10371 } 10372 } 10373 } else { 10374 // literal attribute 10375 { 10376 var res = parseText(value, delimiters); 10377 if (res) { 10378 warn$2( 10379 name + "=\"" + value + "\": " + 10380 'Interpolation inside attributes has been removed. ' + 10381 'Use v-bind or the colon shorthand instead. For example, ' + 10382 'instead of <div id="{{ val }}">, use <div :id="val">.', 10383 list[i] 10384 ); 10385 } 10386 } 10387 addAttr(el, name, JSON.stringify(value), list[i]); 10388 // #6887 firefox doesn't update muted state if set via attribute 10389 // even immediately after element creation 10390 if (!el.component && 10391 name === 'muted' && 10392 platformMustUseProp(el.tag, el.attrsMap.type, name)) { 10393 addProp(el, name, 'true', list[i]); 10394 } 10395 } 10396 } 10397 } 10398 10399 function checkInFor (el) { 10400 var parent = el; 10401 while (parent) { 10402 if (parent.for !== undefined) { 10403 return true 10404 } 10405 parent = parent.parent; 10406 } 10407 return false 10408 } 10409 10410 function parseModifiers (name) { 10411 var match = name.match(modifierRE); 10412 if (match) { 10413 var ret = {}; 10414 match.forEach(function (m) { ret[m.slice(1)] = true; }); 10415 return ret 10416 } 10417 } 10418 10419 function makeAttrsMap (attrs) { 10420 var map = {}; 10421 for (var i = 0, l = attrs.length; i < l; i++) { 10422 if ( 10423 map[attrs[i].name] && !isIE && !isEdge 10424 ) { 10425 warn$2('duplicate attribute: ' + attrs[i].name, attrs[i]); 10426 } 10427 map[attrs[i].name] = attrs[i].value; 10428 } 10429 return map 10430 } 10431 10432 // for script (e.g. type="x/template") or style, do not decode content 10433 function isTextTag (el) { 10434 return el.tag === 'script' || el.tag === 'style' 10435 } 10436 10437 function isForbiddenTag (el) { 10438 return ( 10439 el.tag === 'style' || 10440 (el.tag === 'script' && ( 10441 !el.attrsMap.type || 10442 el.attrsMap.type === 'text/javascript' 10443 )) 10444 ) 10445 } 10446 10447 var ieNSBug = /^xmlns:NS\d+/; 10448 var ieNSPrefix = /^NS\d+:/; 10449 10450 /* istanbul ignore next */ 10451 function guardIESVGBug (attrs) { 10452 var res = []; 10453 for (var i = 0; i < attrs.length; i++) { 10454 var attr = attrs[i]; 10455 if (!ieNSBug.test(attr.name)) { 10456 attr.name = attr.name.replace(ieNSPrefix, ''); 10457 res.push(attr); 10458 } 10459 } 10460 return res 10461 } 10462 10463 function checkForAliasModel (el, value) { 10464 var _el = el; 10465 while (_el) { 10466 if (_el.for && _el.alias === value) { 10467 warn$2( 10468 "<" + (el.tag) + " v-model=\"" + value + "\">: " + 10469 "You are binding v-model directly to a v-for iteration alias. " + 10470 "This will not be able to modify the v-for source array because " + 10471 "writing to the alias is like modifying a function local variable. " + 10472 "Consider using an array of objects and use v-model on an object property instead.", 10473 el.rawAttrsMap['v-model'] 10474 ); 10475 } 10476 _el = _el.parent; 10477 } 10478 } 10479 10480 /* */ 10481 10482 function preTransformNode (el, options) { 10483 if (el.tag === 'input') { 10484 var map = el.attrsMap; 10485 if (!map['v-model']) { 10486 return 10487 } 10488 10489 var typeBinding; 10490 if (map[':type'] || map['v-bind:type']) { 10491 typeBinding = getBindingAttr(el, 'type'); 10492 } 10493 if (!map.type && !typeBinding && map['v-bind']) { 10494 typeBinding = "(" + (map['v-bind']) + ").type"; 10495 } 10496 10497 if (typeBinding) { 10498 var ifCondition = getAndRemoveAttr(el, 'v-if', true); 10499 var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : ""; 10500 var hasElse = getAndRemoveAttr(el, 'v-else', true) != null; 10501 var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true); 10502 // 1. checkbox 10503 var branch0 = cloneASTElement(el); 10504 // process for on the main node 10505 processFor(branch0); 10506 addRawAttr(branch0, 'type', 'checkbox'); 10507 processElement(branch0, options); 10508 branch0.processed = true; // prevent it from double-processed 10509 branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra; 10510 addIfCondition(branch0, { 10511 exp: branch0.if, 10512 block: branch0 10513 }); 10514 // 2. add radio else-if condition 10515 var branch1 = cloneASTElement(el); 10516 getAndRemoveAttr(branch1, 'v-for', true); 10517 addRawAttr(branch1, 'type', 'radio'); 10518 processElement(branch1, options); 10519 addIfCondition(branch0, { 10520 exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra, 10521 block: branch1 10522 }); 10523 // 3. other 10524 var branch2 = cloneASTElement(el); 10525 getAndRemoveAttr(branch2, 'v-for', true); 10526 addRawAttr(branch2, ':type', typeBinding); 10527 processElement(branch2, options); 10528 addIfCondition(branch0, { 10529 exp: ifCondition, 10530 block: branch2 10531 }); 10532 10533 if (hasElse) { 10534 branch0.else = true; 10535 } else if (elseIfCondition) { 10536 branch0.elseif = elseIfCondition; 10537 } 10538 10539 return branch0 10540 } 10541 } 10542 } 10543 10544 function cloneASTElement (el) { 10545 return createASTElement(el.tag, el.attrsList.slice(), el.parent) 10546 } 10547 10548 var model$1 = { 10549 preTransformNode: preTransformNode 10550 }; 10551 10552 var modules$1 = [ 10553 klass$1, 10554 style$1, 10555 model$1 10556 ]; 10557 10558 /* */ 10559 10560 function text (el, dir) { 10561 if (dir.value) { 10562 addProp(el, 'textContent', ("_s(" + (dir.value) + ")"), dir); 10563 } 10564 } 10565 10566 /* */ 10567 10568 function html (el, dir) { 10569 if (dir.value) { 10570 addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"), dir); 10571 } 10572 } 10573 10574 var directives$1 = { 10575 model: model, 10576 text: text, 10577 html: html 10578 }; 10579 10580 /* */ 10581 10582 var baseOptions = { 10583 expectHTML: true, 10584 modules: modules$1, 10585 directives: directives$1, 10586 isPreTag: isPreTag, 10587 isUnaryTag: isUnaryTag, 10588 mustUseProp: mustUseProp, 10589 canBeLeftOpenTag: canBeLeftOpenTag, 10590 isReservedTag: isReservedTag, 10591 getTagNamespace: getTagNamespace, 10592 staticKeys: genStaticKeys(modules$1) 10593 }; 10594 10595 /* */ 10596 10597 var isStaticKey; 10598 var isPlatformReservedTag; 10599
10600 var genStaticKeysCached = cached(genStaticKeys$1); 10601 10602 /** 10603 * Goal of the optimizer: walk the generated template AST tree 10604 * and detect sub-trees that are purely static, i.e. parts of 10605 * the DOM that never needs to change. 10606 * 10607 * Once we detect these sub-trees, we can: 10608 * 10609 * 1. Hoist them into constants, so that we no longer need to 10610 * create fresh nodes for them on each re-render; 10611 * 2. Completely skip them in the patching process. 10612 */ 10613 function optimize (root, options) { 10614 if (!root) { return } 10615 isStaticKey = genStaticKeysCached(options.staticKeys || ''); 10616 isPlatformReservedTag = options.isReservedTag || no; 10617 // first pass: mark all non-static nodes. 10618 markStatic$1(root); 10619 // second pass: mark static roots. 10620 markStaticRoots(root, false); 10621 } 10622 10623 function genStaticKeys$1 (keys) { 10624 return makeMap( 10625 'type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap' + 10626 (keys ? ',' + keys : '') 10627 ) 10628 } 10629 10630 function markStatic$1 (node) { 10631 node.static = isStatic(node); 10632 if (node.type === 1) { 10633 // do not make component slot content static. this avoids 10634 // 1. components not able to mutate slot nodes 10635 // 2. static slot content fails for hot-reloading 10636 if ( 10637 !isPlatformReservedTag(node.tag) && 10638 node.tag !== 'slot' && 10639 node.attrsMap['inline-template'] == null 10640 ) { 10641 return 10642 } 10643 for (var i = 0, l = node.children.length; i < l; i++) { 10644 var child = node.children[i]; 10645 markStatic$1(child); 10646 if (!child.static) { 10647 node.static = false; 10648 } 10649 } 10650 if (node.ifConditions) { 10651 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) { 10652 var block = node.ifConditions[i$1].block; 10653 markStatic$1(block); 10654 if (!block.static) { 10655 node.static = false; 10656 } 10657 } 10658 } 10659 } 10660 } 10661 10662 function markStaticRoots (node, isInFor) { 10663 if (node.type === 1) { 10664 if (node.static || node.once) { 10665 node.staticInFor = isInFor; 10666 } 10667 // For a node to qualify as a static root, it should have children that 10668 // are not just static text. Otherwise the cost of hoisting out will 10669 // outweigh the benefits and it's better off to just always render it fresh. 10670 if (node.static && node.children.length && !( 10671 node.children.length === 1 && 10672 node.children[0].type === 3 10673 )) { 10674 node.staticRoot = true; 10675 return 10676 } else { 10677 node.staticRoot = false; 10678 } 10679 if (node.children) { 10680 for (var i = 0, l = node.children.length; i < l; i++) { 10681 markStaticRoots(node.children[i], isInFor || !!node.for); 10682 } 10683 } 10684 if (node.ifConditions) { 10685 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) { 10686 markStaticRoots(node.ifConditions[i$1].block, isInFor); 10687 } 10688 } 10689 } 10690 } 10691 10692 function isStatic (node) { 10693 if (node.type === 2) { // expression 10694 return false 10695 } 10696 if (node.type === 3) { // text 10697 return true 10698 } 10699 return !!(node.pre || ( 10700 !node.hasBindings && // no dynamic bindings 10701 !node.if && !node.for && // not v-if or v-for or v-else 10702 !isBuiltInTag(node.tag) && // not a built-in 10703 isPlatformReservedTag(node.tag) && // not a component 10704 !isDirectChildOfTemplateFor(node) && 10705 Object.keys(node).every(isStaticKey) 10706 )) 10707 } 10708 10709 function isDirectChildOfTemplateFor (node) { 10710 while (node.parent) { 10711 node = node.parent; 10712 if (node.tag !== 'template') { 10713 return false 10714 } 10715 if (node.for) { 10716 return true 10717 } 10718 } 10719 return false 10720 } 10721 10722 /* */ 10723 10724 var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/; 10725 var fnInvokeRE = /\([^)]*?\);*$/; 10726 var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; 10727 10728 // KeyboardEvent.keyCode aliases 10729 var keyCodes = { 10730 esc: 27, 10731 tab: 9, 10732 enter: 13, 10733 space: 32, 10734 up: 38, 10735 left: 37, 10736 right: 39, 10737 down: 40, 10738 'delete': [8, 46] 10739 }; 10740 10741 // KeyboardEvent.key aliases 10742 var keyNames = { 10743 // #7880: IE11 and Edge use `Esc` for Escape key name. 10744 esc: ['Esc', 'Escape'], 10745 tab: 'Tab', 10746 enter: 'Enter', 10747 // #9112: IE11 uses `Spacebar` for Space key name. 10748 space: [' ', 'Spacebar'], 10749 // #7806: IE11 uses key names without `Arrow` prefix for arrow keys. 10750 up: ['Up', 'ArrowUp'], 10751 left: ['Left', 'ArrowLeft'], 10752 right: ['Right', 'ArrowRight'],
10753 down: ['Down', 'ArrowDown'], 10754 // #9112: IE11 uses `Del` for Delete key name. 10755 'delete': ['Backspace', 'Delete', 'Del'] 10756 }; 10757 10758 // #4868: modifiers that prevent the execution of the listener 10759 // need to explicitly return null so that we can determine whether to remove 10760 // the listener for .once 10761 var genGuard = function (condition) { return ("if(" + condition + ")return null;"); }; 10762 10763 var modifierCode = { 10764 stop: '$event.stopPropagation();', 10765 prevent: '$event.preventDefault();', 10766 self: genGuard("$event.target !== $event.currentTarget"), 10767 ctrl: genGuard("!$event.ctrlKey"), 10768 shift: genGuard("!$event.shiftKey"), 10769 alt: genGuard("!$event.altKey"), 10770 meta: genGuard("!$event.metaKey"), 10771 left: genGuard("'button' in $event && $event.button !== 0"), 10772 middle: genGuard("'button' in $event && $event.button !== 1"), 10773 right: genGuard("'button' in $event && $event.button !== 2") 10774 }; 10775 10776 function genHandlers ( 10777 events, 10778 isNative 10779 ) { 10780 var prefix = isNative ? 'nativeOn:' : 'on:'; 10781 var staticHandlers = ""; 10782 var dynamicHandlers = ""; 10783 for (var name in events) { 10784 var handlerCode = genHandler(events[name]); 10785 if (events[name] && events[name].dynamic) { 10786 dynamicHandlers += name + "," + handlerCode + ","; 10787 } else { 10788 staticHandlers += "\"" + name + "\":" + handlerCode + ","; 10789 } 10790 } 10791 staticHandlers = "{" + (staticHandlers.slice(0, -1)) + "}"; 10792 if (dynamicHandlers) { 10793 return prefix + "_d(" + staticHandlers + ",[" + (dynamicHandlers.slice(0, -1)) + "])" 10794 } else { 10795 return prefix + staticHandlers 10796 } 10797 } 10798 10799 function genHandler (handler) { 10800 if (!handler) { 10801 return 'function(){}' 10802 } 10803 10804 if (Array.isArray(handler)) { 10805 return ("[" + (handler.map(function (handler) { return genHandler(handler); }).join(',')) + "]") 10806 } 10807 10808 var isMethodPath = simplePathRE.test(handler.value); 10809 var isFunctionExpression = fnExpRE.test(handler.value); 10810 var isFunctionInvocation = simplePathRE.test(handler.value.replace(fnInvokeRE, '')); 10811 10812 if (!handler.modifiers) { 10813 if (isMethodPath || isFunctionExpression) { 10814 return handler.value 10815 } 10816 return ("function($event){" + (isFunctionInvocation ? ("return " + (handler.value)) : handler.value) + "}") // inline statement 10817 } else { 10818 var code = ''; 10819 var genModifierCode = ''; 10820 var keys = []; 10821 for (var key in handler.modifiers) { 10822 if (modifierCode[key]) { 10823 genModifierCode += modifierCode[key]; 10824 // left/right 10825 if (keyCodes[key]) { 10826 keys.push(key); 10827 } 10828 } else if (key === 'exact') { 10829 var modifiers = (handler.modifiers); 10830 genModifierCode += genGuard( 10831 ['ctrl', 'shift', 'alt', 'meta'] 10832 .filter(function (keyModifier) { return !modifiers[keyModifier]; }) 10833 .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); }) 10834 .join('||') 10835 ); 10836 } else { 10837 keys.push(key); 10838 } 10839 } 10840 if (keys.length) { 10841 code += genKeyFilter(keys); 10842 } 10843 // Make sure modifiers like prevent and stop get executed after key filtering 10844 if (genModifierCode) { 10845 code += genModifierCode; 10846 } 10847 var handlerCode = isMethodPath 10848 ? ("return " + (handler.value) + "($event)") 10849 : isFunctionExpression 10850 ? ("return (" + (handler.value) + ")($event)") 10851 : isFunctionInvocation 10852 ? ("return " + (handler.value)) 10853 : handler.value; 10854 return ("function($event){" + code + handlerCode + "}") 10855 } 10856 } 10857 10858 function genKeyFilter (keys) { 10859 return ( 10860 // make sure the key filters only apply to KeyboardEvents 10861 // #9441: can't use 'keyCode' in $event because Chrome autofill fires fake 10862 // key events that do not have keyCode property... 10863 "if(!$event.type.indexOf('key')&&" + 10864 (keys.map(genFilterCode).join('&&')) + ")return null;" 10865 ) 10866 } 10867 10868 function genFilterCode (key) { 10869 var keyVal = parseInt(key, 10); 10870 if (keyVal) { 10871 return ("$event.keyCode!==" + keyVal) 10872 } 10873 var keyCode = keyCodes[key]; 10874 var keyName = keyNames[key]; 10875 return ( 10876 "_k($event.keyCode," + 10877 (JSON.stringify(key)) + "," + 10878 (JSON.stringify(keyCode)) + "," + 10879 "$event.key," + 10880 "" + (JSON.stringify(keyName)) + 10881 ")" 10882 ) 10883 } 10884 10885 /* */ 10886 10887 function on (el, dir) { 10888 if (dir.modifiers) { 10889 warn("v-on without argument does not support modifiers."); 10890 } 10891 el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); }; 10892 } 10893 10894 /* */ 10895 10896 function bind$1 (el, dir) { 10897 el.wrapData = function (code) { 10898 return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")") 10899 }; 10900 } 10901 10902 /* */ 10903 10904 var baseDirectives = { 10905 on: on, 10906 bind: bind$1, 10907 cloak: noop 10908 }; 10909 10910 /* */ 10911 10912 10913 10914 10915 10916 var CodegenState = function CodegenState (options) { 10917 this.options = options; 10918 this.warn = options.warn || baseWarn; 10919 this.transforms = pluckModuleFunction(options.modules, 'transformCode'); 10920 this.dataGenFns = pluckModuleFunction(options.modules, 'genData'); 10921 this.directives = extend(extend({}, baseDirectives), options.directives); 10922 var isReservedTag = options.isReservedTag || no; 10923 this.maybeComponent = function (el) { return !!el.component || !isReservedTag(el.tag); }; 10924 this.onceId = 0; 10925 this.staticRenderFns = []; 10926 this.pre = false;
10927 }; 10928 10929 10930 10931 function generate ( 10932 ast, 10933 options 10934 ) { 10935 var state = new CodegenState(options); 10936 var code = ast ? genElement(ast, state) : '_c("div")'; 10937 return { 10938 render: ("with(this){return " + code + "}"), 10939 staticRenderFns: state.staticRenderFns 10940 } 10941 } 10942 10943 function genElement (el, state) { 10944 if (el.parent) { 10945 el.pre = el.pre || el.parent.pre; 10946 } 10947 10948 if (el.staticRoot && !el.staticProcessed) { 10949 return genStatic(el, state) 10950 } else if (el.once && !el.onceProcessed) { 10951 return genOnce(el, state) 10952 } else if (el.for && !el.forProcessed) { 10953 return genFor(el, state) 10954 } else if (el.if && !el.ifProcessed) { 10955 return genIf(el, state) 10956 } else if (el.tag === 'template' && !el.slotTarget && !state.pre) { 10957 return genChildren(el, state) || 'void 0' 10958 } else if (el.tag === 'slot') { 10959 return genSlot(el, state) 10960 } else { 10961 // component or element 10962 var code; 10963 if (el.component) { 10964 code = genComponent(el.component, el, state); 10965 } else { 10966 var data; 10967 if (!el.plain || (el.pre && state.maybeComponent(el))) { 10968 data = genData$2(el, state); 10969 } 10970 10971 var children = el.inlineTemplate ? null : genChildren(el, state, true); 10972 code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; 10973 } 10974 // module transforms 10975 for (var i = 0; i < state.transforms.length; i++) { 10976 code = state.transforms[i](el, code); 10977 } 10978 return code 10979 } 10980 } 10981 10982 // hoist static sub-trees out 10983 function genStatic (el, state) { 10984 el.staticProcessed = true; 10985 // Some elements (templates) need to behave differently inside of a v-pre 10986 // node. All pre nodes are static roots, so we can use this as a location to 10987 // wrap a state change and reset it upon exiting the pre node. 10988 var originalPreState = state.pre; 10989 if (el.pre) { 10990 state.pre = el.pre; 10991 } 10992 state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}")); 10993 state.pre = originalPreState; 10994 return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")") 10995 } 10996 10997 // v-once 10998 function genOnce (el, state) { 10999 el.onceProcessed = true; 11000 if (el.if && !el.ifProcessed) { 11001 return genIf(el, state) 11002 } else if (el.staticInFor) { 11003 var key = ''; 11004 var parent = el.parent; 11005 while (parent) { 11006 if (parent.for) { 11007 key = parent.key; 11008 break 11009 } 11010 parent = parent.parent; 11011 } 11012 if (!key) { 11013 state.warn( 11014 "v-once can only be used inside v-for that is keyed. ", 11015 el.rawAttrsMap['v-once'] 11016 ); 11017 return genElement(el, state) 11018 } 11019 return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")") 11020 } else { 11021 return genStatic(el, state) 11022 } 11023 } 11024 11025 function genIf ( 11026 el, 11027 state, 11028 altGen, 11029 altEmpty 11030 ) { 11031 el.ifProcessed = true; // avoid recursion 11032 return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty) 11033 } 11034 11035 function genIfConditions ( 11036 conditions, 11037 state, 11038 altGen, 11039 altEmpty 11040 ) { 11041 if (!conditions.length) { 11042 return altEmpty || '_e()' 11043 } 11044 11045 var condition = conditions.shift(); 11046 if (condition.exp) { 11047 return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty))) 11048 } else { 11049 return ("" + (genTernaryExp(condition.block))) 11050 } 11051 11052 // v-if with v-once should generate code like (a)?_m(0):_m(1) 11053 function genTernaryExp (el) { 11054 return altGen 11055 ? altGen(el, state) 11056 : el.once 11057 ? genOnce(el, state) 11058 : genElement(el, state) 11059 } 11060 } 11061 11062 function genFor ( 11063 el, 11064 state, 11065 altGen, 11066 altHelper 11067 ) { 11068 var exp = el.for; 11069 var alias = el.alias; 11070 var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; 11071 var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; 11072 11073 if (state.maybeComponent(el) && 11074 el.tag !== 'slot' && 11075 el.tag !== 'template' && 11076 !el.key 11077 ) { 11078 state.warn( 11079 "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " + 11080 "v-for should have explicit keys. " + 11081 "See https://vuejs.org/guide/list.html#key for more info.", 11082 el.rawAttrsMap['v-for'], 11083 true /* tip */ 11084 ); 11085 } 11086 11087 el.forProcessed = true; // avoid recursion 11088 return (altHelper || '_l') + "((" + exp + ")," + 11089 "function(" + alias + iterator1 + iterator2 + "){" + 11090 "return " + ((altGen || genElement)(el, state)) + 11091 '})' 11092 } 11093 11094 function genData$2 (el, state) { 11095 var data = '{'; 11096 11097 // directives first. 11098 // directives may mutate the el's other properties before they are generated. 11099 var dirs = genDirectives(el, state); 11100 if (dirs) { data += dirs + ','; } 11101 11102 // key 11103 if (el.key) { 11104 data += "key:" + (el.key) + ","; 11105 } 11106 // ref 11107 if (el.ref) { 11108 data += "ref:" + (el.ref) + ","; 11109 } 11110 if (el.refInFor) { 11111 data += "refInFor:true,"; 11112 } 11113 // pre 11114 if (el.pre) { 11115 data += "pre:true,"; 11116 } 11117 // record original tag name for components using "is" attribute 11118 if (el.component) { 11119 data += "tag:\"" + (el.tag) + "\","; 11120 } 11121 // module data generation functions 11122 for (var i = 0; i < state.dataGenFns.length; i++) { 11123 data += state.dataGenFns[i](el); 11124 } 11125 // attributes 11126 if (el.attrs) {
11127 data += "attrs:" + (genProps(el.attrs)) + ","; 11128 } 11129 // DOM props 11130 if (el.props) { 11131 data += "domProps:" + (genProps(el.props)) + ","; 11132 } 11133 // event handlers 11134 if (el.events) { 11135 data += (genHandlers(el.events, false)) + ","; 11136 } 11137 if (el.nativeEvents) { 11138 data += (genHandlers(el.nativeEvents, true)) + ","; 11139 } 11140 // slot target 11141 // only for non-scoped slots 11142 if (el.slotTarget && !el.slotScope) { 11143 data += "slot:" + (el.slotTarget) + ","; 11144 } 11145 // scoped slots 11146 if (el.scopedSlots) { 11147 data += (genScopedSlots(el, el.scopedSlots, state)) + ","; 11148 } 11149 // component v-model 11150 if (el.model) { 11151 data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},"; 11152 } 11153 // inline-template 11154 if (el.inlineTemplate) { 11155 var inlineTemplate = genInlineTemplate(el, state); 11156 if (inlineTemplate) { 11157 data += inlineTemplate + ","; 11158 } 11159 } 11160 data = data.replace(/,$/, '') + '}'; 11161 // v-bind dynamic argument wrap 11162 // v-bind with dynamic arguments must be applied using the same v-bind object 11163 // merge helper so that class/style/mustUseProp attrs are handled correctly. 11164 if (el.dynamicAttrs) { 11165 data = "_b(" + data + ",\"" + (el.tag) + "\"," + (genProps(el.dynamicAttrs)) + ")"; 11166 } 11167 // v-bind data wrap 11168 if (el.wrapData) { 11169 data = el.wrapData(data); 11170 } 11171 // v-on data wrap 11172 if (el.wrapListeners) { 11173 data = el.wrapListeners(data); 11174 } 11175 return data 11176 } 11177 11178 function genDirectives (el, state) { 11179 var dirs = el.directives; 11180 if (!dirs) { return } 11181 var res = 'directives:['; 11182 var hasRuntime = false; 11183 var i, l, dir, needRuntime; 11184 for (i = 0, l = dirs.length; i < l; i++) { 11185 dir = dirs[i]; 11186 needRuntime = true; 11187 var gen = state.directives[dir.name]; 11188 if (gen) { 11189 // compile-time directive that manipulates AST. 11190 // returns true if it also needs a runtime counterpart. 11191 needRuntime = !!gen(el, dir, state.warn); 11192 } 11193 if (needRuntime) { 11194 hasRuntime = true; 11195 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))) : '') + "},"; 11196 } 11197 } 11198 if (hasRuntime) { 11199 return res.slice(0, -1) + ']' 11200 } 11201 } 11202 11203 function genInlineTemplate (el, state) { 11204 var ast = el.children[0]; 11205 if (el.children.length !== 1 || ast.type !== 1) { 11206 state.warn( 11207 'Inline-template components must have exactly one child element.', 11208 { start: el.start } 11209 ); 11210 } 11211 if (ast && ast.type === 1) { 11212 var inlineRenderFns = generate(ast, state.options); 11213 return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}") 11214 } 11215 } 11216 11217 function genScopedSlots ( 11218 el, 11219 slots, 11220 state 11221 ) { 11222 // by default scoped slots are considered "stable", this allows child 11223 // components with only scoped slots to skip forced updates from parent. 11224 // but in some cases we have to bail-out of this optimization 11225 // for example if the slot contains dynamic names, has v-if or v-for on them... 11226 var needsForceUpdate = el.for || Object.keys(slots).some(function (key) { 11227 var slot = slots[key]; 11228 return ( 11229 slot.slotTargetDynamic || 11230 slot.if || 11231 slot.for || 11232 containsSlotChild(slot) // is passing down slot from parent which may be dynamic 11233 ) 11234 }); 11235 11236 // #9534: if a component with scoped slots is inside a conditional branch, 11237 // it's possible for the same component to be reused but with different 11238 // compiled slot content. To avoid that, we generate a unique key based on 11239 // the generated code of all the slot contents. 11240 var needsKey = !!el.if; 11241 11242 // OR when it is inside another scoped slot or v-for (the reactivity may be 11243 // disconnected due to the intermediate scope variable) 11244 // #9438, #9506 11245 // TODO: this can be further optimized by properly analyzing in-scope bindings 11246 // and skip force updating ones that do not actually use scope variables. 11247 if (!needsForceUpdate) { 11248 var parent = el.parent; 11249 while (parent) { 11250 if ( 11251 (parent.slotScope && parent.slotScope !== emptySlotScopeToken) || 11252 parent.for 11253 ) { 11254 needsForceUpdate = true; 11255 break 11256 } 11257 if (parent.if) { 11258 needsKey = true; 11259 } 11260 parent = parent.parent; 11261 } 11262 } 11263 11264 var generatedSlots = Object.keys(slots) 11265 .map(function (key) { return genScopedSlot(slots[key], state); }) 11266 .join(','); 11267 11268 return ("scopedSlots:_u([" + generatedSlots + "]" + (needsForceUpdate ? ",null,true" : "") + (!needsForceUpdate && needsKey ? (",null,fal
11268se," + (hash(generatedSlots))) : "") + ")") 11269 } 11270 11271 function hash(str) { 11272 var hash = 5381; 11273 var i = str.length; 11274 while(i) { 11275 hash = (hash * 33) ^ str.charCodeAt(--i); 11276 } 11277 return hash >>> 0 11278 } 11279 11280 function containsSlotChild (el) { 11281 if (el.type === 1) { 11282 if (el.tag === 'slot') { 11283 return true 11284 } 11285 return el.children.some(containsSlotChild) 11286 } 11287 return false 11288 } 11289 11290 function genScopedSlot ( 11291 el, 11292 state 11293 ) { 11294 var isLegacySyntax = el.attrsMap['slot-scope']; 11295 if (el.if && !el.ifProcessed && !isLegacySyntax) { 11296 return genIf(el, state, genScopedSlot, "null") 11297 } 11298 if (el.for && !el.forProcessed) { 11299 return genFor(el, state, genScopedSlot) 11300 } 11301 var slotScope = el.slotScope === emptySlotScopeToken 11302 ? "" 11303 : String(el.slotScope); 11304 var fn = "function(" + slotScope + "){" + 11305 "return " + (el.tag === 'template' 11306 ? el.if && isLegacySyntax 11307 ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined") 11308 : genChildren(el, state) || 'undefined' 11309 : genElement(el, state)) + "}"; 11310 // reverse proxy v-slot without scope on this.$slots 11311 var reverseProxy = slotScope ? "" : ",proxy:true"; 11312 return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}") 11313 } 11314 11315 function genChildren ( 11316 el, 11317 state, 11318 checkSkip, 11319 altGenElement, 11320 altGenNode 11321 ) { 11322 var children = el.children; 11323 if (children.length) { 11324 var el$1 = children[0]; 11325 // optimize single v-for 11326 if (children.length === 1 && 11327 el$1.for && 11328 el$1.tag !== 'template' && 11329 el$1.tag !== 'slot' 11330 ) { 11331 var normalizationType = checkSkip 11332 ? state.maybeComponent(el$1) ? ",1" : ",0" 11333 : ""; 11334 return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType) 11335 } 11336 var normalizationType$1 = checkSkip 11337 ? getNormalizationType(children, state.maybeComponent) 11338 : 0; 11339 var gen = altGenNode || genNode; 11340 return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : '')) 11341 } 11342 } 11343 11344 // determine the normalization needed for the children array. 11345 // 0: no normalization needed 11346 // 1: simple normalization needed (possible 1-level deep nested array) 11347 // 2: full normalization needed 11348 function getNormalizationType ( 11349 children, 11350 maybeComponent 11351 ) { 11352 var res = 0; 11353 for (var i = 0; i < children.length; i++) { 11354 var el = children[i]; 11355 if (el.type !== 1) { 11356 continue 11357 } 11358 if (needsNormalization(el) || 11359 (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) { 11360 res = 2; 11361 break 11362 } 11363 if (maybeComponent(el) || 11364 (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) { 11365 res = 1; 11366 } 11367 } 11368 return res 11369 } 11370 11371 function needsNormalization (el) { 11372 return el.for !== undefined || el.tag === 'template' || el.tag === 'slot' 11373 } 11374 11375 function genNode (node, state) { 11376 if (node.type === 1) { 11377 return genElement(node, state) 11378 } else if (node.type === 3 && node.isComment) { 11379 return genComment(node) 11380 } else { 11381 return genText(node) 11382 } 11383 } 11384 11385 function genText (text) { 11386 return ("_v(" + (text.type === 2 11387 ? text.expression // no need for () because already wrapped in _s() 11388 : transformSpecialNewlines(JSON.stringify(text.text))) + ")") 11389 } 11390 11391 function genComment (comment) { 11392 return ("_e(" + (JSON.stringify(comment.text)) + ")") 11393 } 11394 11395 function genSlot (el, state) { 11396 var slotName = el.slotName || '"default"'; 11397 var children = genChildren(el, state); 11398 var res = "_t(" + slotName + (children ? ("," + children) : ''); 11399 var attrs = el.attrs || el.dynamicAttrs 11400 ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({ 11401 // slot props are camelized 11402 name: camelize(attr.name), 11403 value: attr.value, 11404 dynamic: attr.dynamic 11405 }); })) 11406 : null; 11407 var bind$$1 = el.attrsMap['v-bind']; 11408 if ((attrs || bind$$1) && !children) { 11409 res += ",null"; 11410 } 11411 if (attrs) { 11412 res += "," + attrs; 11413 } 11414 if (bind$$1) { 11415 res += (attrs ? '' : ',null') + "," + bind$$1; 11416 } 11417 return res + ')' 11418 } 11419 11420 // componentName is el.component, take it as argument to shun flow's pessimistic refinement 11421 function genComponent ( 11422 componentName, 11423 el, 11424 state 11425 ) { 11426 var children = el.inlineTemplate ? null : genChildren(el, state, true); 11427 return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")") 11428 } 11429 11430 function genProps (props) { 11431 var staticProps = ""; 11432 var dynamicProps = ""; 11433 for (var i = 0; i < props.length; i++) { 11434 var prop = props[i]; 11435 var value = transformSpecialNewlines(prop.value); 11436 if (prop.dynamic) { 11437 dynamicProps += (prop.name) + "," + value + ","; 11438 } else { 11439 staticProps += "\"" + (prop.name) + "\":" + value + ","; 11440 } 11441 } 11442 staticProps = "{" + (staticProps.slice(0, -1)) + "}"; 11443 if (dynamicProps) { 11444 return ("_d(" + staticProps + ",[" + (dynamicProps.slice(0, -1)) + "])") 11445 } else { 11446 return staticProps 11447 } 11448 } 11449 11450 // #3895, #4268 11451 function transformSpecialNewlines (text) { 11452 return text 11453 .replace(/\u2028/g, '\\u2028') 11454 .replace(/\u2029/g, '\\u2029') 11455 } 11456 11457 /* */ 11458 11459 11460 11461 // these keywords should not appear inside expressions, but operators like 11462 // typeof, instanceof and in are allowed 11463 var prohibitedKeywordRE = new RegExp('\\b' + ( 11464 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' + 11465 'super,throw,while,yield,delete,export,import,return,switch,default,' + 11466 'extends,finally,continue,debugger,function,arguments' 11467 ).split(',').join('\\b|\\b') + '\\b'); 11468 11469 // these unary operators should not be used as property/method names 11470 var unaryOperatorsRE = new RegExp('\\b' + ( 11471 'delete,typeof,void' 11472 ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)'); 11473 11474 // strip strings in expressions 11475 var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g; 11476 11477 // detect problematic expressions in a template 11478 function detectErrors (ast, warn) { 11479 if (ast) { 11480 checkNode(ast, warn); 11481 } 11482 } 11483 11484 function checkNode (node, warn) { 11485 if (node.type === 1) { 11486 for (var name in node.attrsMap) { 11487 if (dirRE.test(name)) { 11488 var value = node.attrsMap[name]; 11489 if (value) { 11490 var range = node.rawAttrsMap[name]; 11491 if (name === 'v-for') { 11492 checkFor(node, ("v-for=\"" + value + "\""), warn, range); 11493 } else if (onRE.test(name)) { 11494 checkEvent(value, (name + "=\"" + value + "\""), warn, range); 11495 } else { 11496 checkExpression(value, (name + "=\"" + value + "\""), warn, range); 11497 } 11498 } 11499 } 11500 } 11501 if (node.children) { 11502 for (var i = 0; i < node.children.length; i++) { 11503 checkNode(node.children[i], warn); 11504 } 11505 } 11506 } else if (node.type === 2) { 11507 checkExpression(node.expression, node.text, warn, node); 11508 } 11509 } 11510 11511 function checkEvent (exp, text, warn, range) { 11512 var stipped = exp.replace(stripStringRE, ''); 11513 var keywordMatch = stipped.match(unaryOperatorsRE); 11514 if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') { 11515 warn( 11516 "avoid using JavaScript unary operator as property name: " + 11517 "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()), 11518 range 11519 ); 11520 } 11521 checkExpression(exp, text, warn, range); 11522 } 11523 11524 function checkFor (node, text, warn, range) { 11525 checkExpression(node.for || '', text, warn, range); 11526 checkIdentifier(node.alias, 'v-for alias', text, warn, range); 11527 checkIdentifier(node.iterator1, 'v-for iterator', text, warn, range); 11528 checkIdentifier(node.iterator2, 'v-for iterator', text, warn, range); 11529 } 11530 11531 function checkIdentifier ( 11532 ident, 11533 type, 11534 text, 11535 warn, 11536 range 11537 ) { 11538 if (typeof ident === 'string') { 11539 try { 11540 new Function(("var " + ident + "=_")); 11541 } catch (e) { 11542 warn(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())), range); 11543 } 11544 } 11545 } 11546 11547 function checkExpression (exp, text, warn, range) { 11548 try { 11549 new Function(("return " + exp)); 11550 } catch (e) { 11551 var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE); 11552 if (keywordMatch) { 11553 warn( 11554 "avoid using JavaScript keyword as property name: " + 11555 "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()), 11556 range 11557 ); 11558 } else { 11559 warn( 11560 "invalid expression: " + (e.message) + " in\n\n" + 11561 " " + exp + "\n\n" + 11562 " Raw expression: " + (text.trim()) + "\n", 11563 range 11564 ); 11565 } 11566 } 11567 } 11568 11569 /* */ 11570 11571 var range = 2; 11572 11573 function generateCodeFrame ( 11574 source, 11575 start, 11576 end 11577 ) { 11578 if ( start === void 0 ) start = 0; 11579 if ( end === void 0 ) end = source.length; 11580 11581 var lines = source.split(/\r?\n/); 11582 var count = 0; 11583 var res = []; 11584 for (var i = 0; i < lines.length; i++) { 11585 count += lines[i].length + 1; 11586 if (count >= start) {
11587 for (var j = i - range; j <= i + range || end > count; j++) { 11588 if (j < 0 || j >= lines.length) { continue } 11589 res.push(("" + (j + 1) + (repeat$1(" ", 3 - String(j + 1).length)) + "| " + (lines[j]))); 11590 var lineLength = lines[j].length; 11591 if (j === i) { 11592 // push underline 11593 var pad = start - (count - lineLength) + 1; 11594 var length = end > count ? lineLength - pad : end - start; 11595 res.push(" | " + repeat$1(" ", pad) + repeat$1("^", length)); 11596 } else if (j > i) { 11597 if (end > count) { 11598 var length$1 = Math.min(end - count, lineLength); 11599 res.push(" | " + repeat$1("^", length$1)); 11600 } 11601 count += lineLength + 1; 11602 } 11603 } 11604 break 11605 } 11606 } 11607 return res.join('\n') 11608 } 11609 11610 function repeat$1 (str, n) { 11611 var result = ''; 11612 if (n > 0) { 11613 while (true) { // eslint-disable-line 11614 if (n & 1) { result += str; } 11615 n >>>= 1; 11616 if (n <= 0) { break } 11617 str += str; 11618 } 11619 } 11620 return result 11621 } 11622 11623 /* */ 11624 11625 11626 11627 function createFunction (code, errors) { 11628 try { 11629 return new Function(code) 11630 } catch (err) { 11631 errors.push({ err: err, code: code }); 11632 return noop 11633 } 11634 } 11635 11636 function createCompileToFunctionFn (compile) { 11637 var cache = Object.create(null); 11638 11639 return function compileToFunctions ( 11640 template, 11641 options, 11642 vm 11643 ) { 11644 options = extend({}, options); 11645 var warn$$1 = options.warn || warn; 11646 delete options.warn; 11647 11648 /* istanbul ignore if */ 11649 { 11650 // detect possible CSP restriction 11651 try { 11652 new Function('return 1'); 11653 } catch (e) { 11654 if (e.toString().match(/unsafe-eval|CSP/)) { 11655 warn$$1( 11656 'It seems you are using the standalone build of Vue.js in an ' + 11657 'environment with Content Security Policy that prohibits unsafe-eval. ' + 11658 'The template compiler cannot work in this environment. Consider ' + 11659 'relaxing the policy to allow unsafe-eval or pre-compiling your ' + 11660 'templates into render functions.' 11661 ); 11662 } 11663 } 11664 } 11665 11666 // check cache 11667 var key = options.delimiters 11668 ? String(options.delimiters) + template 11669 : template; 11670 if (cache[key]) { 11671 return cache[key] 11672 } 11673 11674 // compile 11675 var compiled = compile(template, options); 11676 11677 // check compilation errors/tips 11678 { 11679 if (compiled.errors && compiled.errors.length) { 11680 if (options.outputSourceRange) { 11681 compiled.errors.forEach(function (e) { 11682 warn$$1( 11683 "Error compiling template:\n\n" + (e.msg) + "\n\n" + 11684 generateCodeFrame(template, e.start, e.end), 11685 vm 11686 ); 11687 }); 11688 } else { 11689 warn$$1( 11690 "Error compiling template:\n\n" + template + "\n\n" + 11691 compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n', 11692 vm 11693 ); 11694 } 11695 } 11696 if (compiled.tips && compiled.tips.length) { 11697 if (options.outputSourceRange) { 11698 compiled.tips.forEach(function (e) { return tip(e.msg, vm); }); 11699 } else { 11700 compiled.tips.forEach(function (msg) { return tip(msg, vm); }); 11701 } 11702 } 11703 } 11704 11705 // turn code into functions 11706 var res = {}; 11707 var fnGenErrors = []; 11708 res.render = createFunction(compiled.render, fnGenErrors); 11709 res.staticRenderFns = compiled.staticRenderFns.map(function (code) { 11710 return createFunction(code, fnGenErrors) 11711 }); 11712 11713 // check function generation errors. 11714 // this should only happen if there is a bug in the compiler itself. 11715 // mostly for codegen development use 11716 /* istanbul ignore if */ 11717 { 11718 if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) { 11719 warn$$1( 11720 "Failed to generate render function:\n\n" + 11721 fnGenErrors.map(function (ref) { 11722 var err = ref.err; 11723 var code = ref.code; 11724 11725 return ((err.toString()) + " in\n\n" + code + "\n"); 11726 }).join('\n'), 11727 vm 11728 ); 11729 } 11730 } 11731 11732 return (cache[key] = res) 11733 } 11734 } 11735 11736 /* */ 11737 11738 function createCompilerCreator (baseCompile) { 11739 return function createCompiler (baseOptions) { 11740 function compile ( 11741 template, 11742 options 11743 ) { 11744 var finalOptions = Object.create(baseOptions); 11745 var errors = []; 11746 var tips = []; 11747 11748 var warn = function (msg, range, tip) { 11749 (tip ? tips : errors).push(msg); 11750 }; 11751 11752 if (options) { 11753 if (options.outputSourceRange) { 11754 // $flow-disable-line
11755 var leadingSpaceLength = template.match(/^\s*/)[0].length; 11756 11757 warn = function (msg, range, tip) { 11758 var data = { msg: msg }; 11759 if (range) { 11760 if (range.start != null) { 11761 data.start = range.start + leadingSpaceLength; 11762 } 11763 if (range.end != null) { 11764 data.end = range.end + leadingSpaceLength; 11765 } 11766 } 11767 (tip ? tips : errors).push(data); 11768 }; 11769 } 11770 // merge custom modules 11771 if (options.modules) { 11772 finalOptions.modules = 11773 (baseOptions.modules || []).concat(options.modules); 11774 } 11775 // merge custom directives 11776 if (options.directives) { 11777 finalOptions.directives = extend( 11778 Object.create(baseOptions.directives || null), 11779 options.directives 11780 ); 11781 } 11782 // copy other options 11783 for (var key in options) { 11784 if (key !== 'modules' && key !== 'directives') { 11785 finalOptions[key] = options[key]; 11786 } 11787 } 11788 } 11789 11790 finalOptions.warn = warn; 11791 11792 var compiled = baseCompile(template.trim(), finalOptions); 11793 { 11794 detectErrors(compiled.ast, warn); 11795 } 11796 compiled.errors = errors; 11797 compiled.tips = tips; 11798 return compiled 11799 } 11800 11801 return { 11802 compile: compile, 11803 compileToFunctions: createCompileToFunctionFn(compile) 11804 } 11805 } 11806 } 11807 11808 /* */ 11809 11810 // `createCompilerCreator` allows creating compilers that use alternative 11811 // parser/optimizer/codegen, e.g the SSR optimizing compiler. 11812 // Here we just export a default compiler using the default parts. 11813 var createCompiler = createCompilerCreator(function baseCompile ( 11814 template, 11815 options 11816 ) { 11817 var ast = parse(template.trim(), options); 11818 if (options.optimize !== false) { 11819 optimize(ast, options); 11820 } 11821 var code = generate(ast, options); 11822 return { 11823 ast: ast, 11824 render: code.render, 11825 staticRenderFns: code.staticRenderFns 11826 } 11827 }); 11828 11829 /* */ 11830 11831 var ref$1 = createCompiler(baseOptions); 11832 var compile = ref$1.compile; 11833 var compileToFunctions = ref$1.compileToFunctions; 11834 11835 /* */ 11836 11837 // check whether current browser encodes a char inside attribute values 11838 var div; 11839 function getShouldDecode (href) { 11840 div = div || document.createElement('div'); 11841 div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>"; 11842 return div.innerHTML.indexOf(' ') > 0 11843 } 11844 11845 // #3663: IE encodes newlines inside attribute values while other browsers don't 11846 var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false; 11847 // #6828: chrome encodes content in a[href] 11848 var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false; 11849 11850 /* */ 11851 11852 var idToTemplate = cached(function (id) { 11853 var el = query(id); 11854 return el && el.innerHTML 11855 }); 11856 11857 var mount = Vue.prototype.$mount; 11858 Vue.prototype.$mount = function ( 11859 el, 11860 hydrating 11861 ) { 11862 el = el && query(el); 11863 11864 /* istanbul ignore if */ 11865 if (el === document.body || el === document.documentElement) { 11866 warn( 11867 "Do not mount Vue to <html> or <body> - mount to normal elements instead." 11868 ); 11869 return this 11870 } 11871 11872 var options = this.$options; 11873 // resolve template/el and convert to render function 11874 if (!options.render) { 11875 var template = options.template; 11876 if (template) { 11877 if (typeof template === 'string') { 11878 if (template.charAt(0) === '#') { 11879 template = idToTemplate(template); 11880 /* istanbul ignore if */ 11881 if (!template) { 11882 warn( 11883 ("Template element not found or is empty: " + (options.template)), 11884 this 11885 ); 11886 } 11887 } 11888 } else if (template.nodeType) { 11889 template = template.innerHTML; 11890 } else { 11891 { 11892 warn('invalid template option:' + template, this); 11893 } 11894 return this 11895 } 11896 } else if (el) { 11897 template = getOuterHTML(el); 11898 } 11899 if (template) { 11900 /* istanbul ignore if */ 11901 if (config.performance && mark) { 11902 mark('compile'); 11903 } 11904 11905 var ref = compileToFunctions(template, { 11906 outputSourceRange: "development" !== 'production', 11907 shouldDecodeNewlines: shouldDecodeNewlines, 11908 shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref, 11909 delimiters: options.delimiters, 11910 comments: options.comments 11911 }, this); 11912 var render = ref.render; 11913 var staticRenderFns = ref.staticRenderFns; 11914 options.render = render; 11915 options.staticRenderFns = staticRenderFns; 11916 11917 /* istanbul ignore if */ 11918 if (config.performance && mark) { 11919 mark('compile end'); 11920 measure(("vue " + (this._name) + " compile"), 'compile', 'compile end'); 11921 } 11922 } 11923 } 11924 return mount.call(this, el, hydrating) 11925 }; 11926 11927 /** 11928 * Get outerHTML of elements, taking care 11929 * of SVG elements in IE as well. 11930 */ 11931 function getOuterHTML (el) { 11932 if (el.outerHTML) { 11933 return el.outerHTML 11934 } else { 11935 var container = document.createElement('div'); 11936 container.appendChild(el.cloneNode(true)); 11937 return container.innerHTML 11938 } 11939 } 11940 11941 Vue.compile = compileToFunctions; 11942 11943 return Vue; 11944 11945})); 11946/** 11947 * vuex v3.1.0 11948 * (c) 2019 Evan You 11949 * @license MIT 11950 */ 11951(function (global, factory) { 11952 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 11953 typeof define === 'function' && define.amd ? define(factory) : 11954 (global = global || self, global.Vuex = factory()); 11955}(this, function () { 'use strict'; 11956 11957 function applyMixin (Vue) { 11958 var version = Number(Vue.version.split('.')[0]); 11959 11960 if (version >= 2) { 11961 Vue.mixin({ beforeCreate: vuexInit }); 11962 } else { 11963 // override init and inject vuex init procedure 11964 // for 1.x backwards compatibility. 11965 var _init = Vue.prototype._init; 11966 Vue.prototype._init = function (options) { 11967 if ( options === void 0 ) options = {}; 11968 11969 options.init = options.init 11970 ? [vuexInit].concat(options.init) 11971 : vuexInit; 11972 _init.call(this, options); 11973 }; 11974 } 11975 11976 /** 11977 * Vuex init hook, injected into each instances init hooks list. 11978 */ 11979 11980 function vuexInit () { 11981 var options = this.$options; 11982 // store injection 11983 if (options.store) { 11984 this.$store = typeof options.store === 'function'
vendor: 16,510 bytes, lines 11985-12498
11985 ? options.store() 11986 : options.store; 11987 } else if (options.parent && options.parent.$store) { 11988 this.$store = options.parent.$store; 11989 } 11990 } 11991 } 11992 11993 var devtoolHook = 11994 typeof window !== 'undefined' && 11995 window.__VUE_DEVTOOLS_GLOBAL_HOOK__; 11996 11997 function devtoolPlugin (store) { 11998 if (!devtoolHook) { return } 11999 12000 store._devtoolHook = devtoolHook; 12001 12002 devtoolHook.emit('vuex:init', store); 12003 12004 devtoolHook.on('vuex:travel-to-state', function (targetState) { 12005 store.replaceState(targetState); 12006 }); 12007 12008 store.subscribe(function (mutation, state) { 12009 devtoolHook.emit('vuex:mutation', mutation, state); 12010 }); 12011 } 12012 12013 /** 12014 * Get the first item that pass the test 12015 * by second argument function 12016 * 12017 * @param {Array} list 12018 * @param {Function} f 12019 * @return {*} 12020 */ 12021 12022 /** 12023 * forEach for object 12024 */ 12025 function forEachValue (obj, fn) { 12026 Object.keys(obj).forEach(function (key) { return fn(obj[key], key); }); 12027 } 12028 12029 function isObject (obj) { 12030 return obj !== null && typeof obj === 'object' 12031 } 12032 12033 function isPromise (val) { 12034 return val && typeof val.then === 'function' 12035 } 12036 12037 function assert (condition, msg) { 12038 if (!condition) { throw new Error(("[vuex] " + msg)) } 12039 } 12040 12041 // Base data struct for store's module, package with some attribute and method 12042 var Module = function Module (rawModule, runtime) { 12043 this.runtime = runtime; 12044 // Store some children item 12045 this._children = Object.create(null); 12046 // Store the origin module object which passed by programmer 12047 this._rawModule = rawModule; 12048 var rawState = rawModule.state; 12049 12050 // Store the origin module's state 12051 this.state = (typeof rawState === 'function' ? rawState() : rawState) || {}; 12052 }; 12053 12054 var prototypeAccessors = { namespaced: { configurable: true } }; 12055 12056 prototypeAccessors.namespaced.get = function () { 12057 return !!this._rawModule.namespaced 12058 }; 12059 12060 Module.prototype.addChild = function addChild (key, module) { 12061 this._children[key] = module; 12062 }; 12063 12064 Module.prototype.removeChild = function removeChild (key) { 12065 delete this._children[key]; 12066 }; 12067 12068 Module.prototype.getChild = function getChild (key) { 12069 return this._children[key] 12070 }; 12071 12072 Module.prototype.update = function update (rawModule) { 12073 this._rawModule.namespaced = rawModule.namespaced; 12074 if (rawModule.actions) { 12075 this._rawModule.actions = rawModule.actions; 12076 } 12077 if (rawModule.mutations) { 12078 this._rawModule.mutations = rawModule.mutations; 12079 } 12080 if (rawModule.getters) { 12081 this._rawModule.getters = rawModule.getters; 12082 } 12083 }; 12084 12085 Module.prototype.forEachChild = function forEachChild (fn) { 12086 forEachValue(this._children, fn); 12087 }; 12088 12089 Module.prototype.forEachGetter = function forEachGetter (fn) { 12090 if (this._rawModule.getters) { 12091 forEachValue(this._rawModule.getters, fn); 12092 } 12093 }; 12094 12095 Module.prototype.forEachAction = function forEachAction (fn) { 12096 if (this._rawModule.actions) { 12097 forEachValue(this._rawModule.actions, fn); 12098 } 12099 }; 12100 12101 Module.prototype.forEachMutation = function forEachMutation (fn) { 12102 if (this._rawModule.mutations) { 12103 forEachValue(this._rawModule.mutations, fn); 12104 } 12105 }; 12106 12107 Object.defineProperties( Module.prototype, prototypeAccessors ); 12108 12109 var ModuleCollection = function ModuleCollection (rawRootModule) { 12110 // register root module (Vuex.Store options) 12111 this.register([], rawRootModule, false); 12112 }; 12113 12114 ModuleCollection.prototype.get = function get (path) { 12115 return path.reduce(function (module, key) { 12116 return module.getChild(key) 12117 }, this.root) 12118 }; 12119 12120 ModuleCollection.prototype.getNamespace = function getNamespace (path) { 12121 var module = this.root; 12122 return path.reduce(function (namespace, key) { 12123 module = module.getChild(key); 12124 return namespace + (module.namespaced ? key + '/' : '') 12125 }, '') 12126 }; 12127 12128 ModuleCollection.prototype.update = function update$1 (rawRootModule) { 12129 update([], this.root, rawRootModule); 12130 }; 12131 12132 ModuleCollection.prototype.register = function register (path, rawModule, runtime) { 12133 var this$1 = this; 12134 if ( runtime === void 0 ) runtime = true; 12135 12136 { 12137 assertRawModule(path, rawModule); 12138 } 12139 12140 var newModule = new Module(rawModule, runtime); 12141 if (path.length === 0) { 12142 this.root = newModule; 12143 } else { 12144 var parent = this.get(path.slice(0, -1)); 12145 parent.addChild(path[path.length - 1], newModule); 12146 } 12147 12148 // register nested modules 12149 if (rawModule.modules) { 12150 forEachValue(rawModule.modules, function (rawChildModule, key) { 12151 this$1.register(path.concat(key), rawChildModule, runtime); 12152 }); 12153 } 12154 }; 12155 12156 ModuleCollection.prototype.unregister = function unregister (path) { 12157 var parent = this.get(path.slice(0, -1)); 12158 var key = path[path.length - 1]; 12159 if (!parent.getChild(key).runtime) { return } 12160 12161 parent.removeChild(key); 12162 }; 12163 12164 function update (path, targetModule, newModule) { 12165 { 12166 assertRawModule(path, newModule); 12167 } 12168 12169 // update target module 12170 targetModule.update(newModule); 12171 12172 // update nested modules 12173 if (newModule.modules) { 12174 for (var key in newModule.modules) { 12175 if (!targetModule.getChild(key)) { 12176 { 12177 console.warn( 12178 "[vuex] trying to add a new module '" + key + "' on hot reloading, " + 12179 'manual reload is needed' 12180 ); 12181 } 12182 return 12183 } 12184 update( 12185 path.concat(key), 12186 targetModule.getChild(key), 12187 newModule.modules[key] 12188 ); 12189 } 12190 } 12191 } 12192 12193 var functionAssert = { 12194 assert: function (value) { return typeof value === 'function'; }, 12195 expected: 'function' 12196 }; 12197 12198 var objectAssert = { 12199 assert: function (value) { return typeof value === 'function' || 12200 (typeof value === 'object' && typeof value.handler === 'function'); }, 12201 expected: 'function or object with "handler" function' 12202 }; 12203 12204 var assertTypes = { 12205 getters: functionAssert, 12206 mutations: functionAssert, 12207 actions: objectAssert 12208 }; 12209 12210 function assertRawModule (path, rawModule) { 12211 Object.keys(assertTypes).forEach(function (key) { 12212 if (!rawModule[key]) { return } 12213 12214 var assertOptions = assertTypes[key]; 12215 12216 forEachValue(rawModule[key], function (value, type) { 12217 assert( 12218 assertOptions.assert(value), 12219 makeAssertionMessage(path, key, type, value, assertOptions.expected) 12220 ); 12221 }); 12222 }); 12223 } 12224 12225 function makeAssertionMessage (path, key, type, value, expected) { 12226 var buf = key + " should be " + expected + " but \"" + key + "." + type + "\""; 12227 if (path.length > 0) { 12228 buf += " in module \"" + (path.join('.')) + "\""; 12229 } 12230 buf += " is " + (JSON.stringify(value)) + "."; 12231 return buf 12232 } 12233 12234 var Vue; // bind on install 12235 12236 var Store = function Store (options) { 12237 var this$1 = this; 12238 if ( options === void 0 ) options = {}; 12239 12240 // Auto install if it is not done yet and `window` has `Vue`. 12241 // To allow users to avoid auto-installation in some cases, 12242 // this code should be placed here. See #731 12243 if (!Vue && typeof window !== 'undefined' && window.Vue) { 12244 install(window.Vue); 12245 } 12246 12247 { 12248 assert(Vue, "must call Vue.use(Vuex) before creating a store instance."); 12249 assert(typeof Promise !== 'undefined', "vuex requires a Promise polyfill in this browser."); 12250 assert(this instanceof Store, "store must be called with the new operator."); 12251 } 12252 12253 var plugins = options.plugins; if ( plugins === void 0 ) plugins = []; 12254 var strict = options.strict; if ( strict === void 0 ) strict = false; 12255 12256 // store internal state 12257 this._committing = false; 12258 this._actions = Object.create(null); 12259 this._actionSubscribers = []; 12260 this._mutations = Object.create(null); 12261 this._wrappedGetters = Object.create(null); 12262 this._modules = new ModuleCollection(options); 12263 this._modulesNamespaceMap = Object.create(null); 12264 this._subscribers = []; 12265 this._watcherVM = new Vue(); 12266 12267 // bind commit and dispatch to self 12268 var store = this; 12269 var ref = this; 12270 var dispatch = ref.dispatch; 12271 var commit = ref.commit; 12272 this.dispatch = function boundDispatch (type, payload) { 12273 return dispatch.call(store, type, payload) 12274 }; 12275 this.commit = function boundCommit (type, payload, options) { 12276 return commit.call(store, type, payload, options) 12277 }; 12278 12279 // strict mode 12280 this.strict = strict; 12281 12282 var state = this._modules.root.state; 12283 12284 // init root module. 12285 // this also recursively registers all sub-modules 12286 // and collects all module getters inside this._wrappedGetters 12287 installModule(this, state, [], this._modules.root); 12288 12289 // initialize the store vm, which is responsible for the reactivity 12290 // (also registers _wrappedGetters as computed properties) 12291 resetStoreVM(this, state); 12292 12293 // apply plugins 12294 plugins.forEach(function (plugin) { return plugin(this$1); }); 12295 12296 var useDevtools = options.devtools !== undefined ? options.devtools : Vue.config.devtools; 12297 if (useDevtools) { 12298 devtoolPlugin(this); 12299 } 12300 }; 12301 12302 var prototypeAccessors$1 = { state: { configurable: true } }; 12303 12304 prototypeAccessors$1.state.get = function () { 12305 return this._vm._data.$$state 12306 }; 12307 12308 prototypeAccessors$1.state.set = function (v) { 12309 { 12310 assert(false, "use store.replaceState() to explicit replace store state."); 12311 } 12312 }; 12313 12314 Store.prototype.commit = function commit (_type, _payload, _options) { 12315 var this$1 = this; 12316 12317 // check object-style commit 12318 var ref = unifyObjectStyle(_type, _payload, _options); 12319 var type = ref.type; 12320 var payload = ref.payload; 12321 var options = ref.options; 12322 12323 var mutation = { type: type, payload: payload }; 12324 var entry = this._mutations[type]; 12325 if (!entry) { 12326 { 12327 console.error(("[vuex] unknown mutation type: " + type)); 12328 } 12329 return 12330 } 12331 this._withCommit(function () { 12332 entry.forEach(function commitIterator (handler) { 12333 handler(payload); 12334 }); 12335 }); 12336 this._subscribers.forEach(function (sub) { return sub(mutation, this$1.state); }); 12337 12338 if ( 12339 options && options.silent 12340 ) { 12341 console.warn( 12342 "[vuex] mutation type: " + type + ". Silent option has been removed. " + 12343 'Use the filter functionality in the vue-devtools' 12344 ); 12345 } 12346 }; 12347 12348 Store.prototype.dispatch = function dispatch (_type, _payload) { 12349 var this$1 = this; 12350 12351 // check object-style dispatch 12352 var ref = unifyObjectStyle(_type, _payload); 12353 var type = ref.type; 12354 var payload = ref.payload; 12355 12356 var action = { type: type, payload: payload }; 12357 var entry = this._actions[type]; 12358 if (!entry) { 12359 { 12360 console.error(("[vuex] unknown action type: " + type)); 12361 } 12362 return 12363 } 12364 12365 try { 12366 this._actionSubscribers 12367 .filter(function (sub) { return sub.before; }) 12368 .forEach(function (sub) { return sub.before(action, this$1.state); }); 12369 } catch (e) { 12370 { 12371 console.warn("[vuex] error in before action subscribers: "); 12372 console.error(e); 12373 } 12374 } 12375 12376 var result = entry.length > 1 12377 ? Promise.all(entry.map(function (handler) { return handler(payload); })) 12378 : entry[0](payload); 12379 12380 return result.then(function (res) { 12381 try { 12382 this$1._actionSubscribers 12383 .filter(function (sub) { return sub.after; }) 12384 .forEach(function (sub) { return sub.after(action, this$1.state); }); 12385 } catch (e) { 12386 { 12387 console.warn("[vuex] error in after action subscribers: "); 12388 console.error(e); 12389 } 12390 } 12391 return res 12392 }) 12393 }; 12394 12395 Store.prototype.subscribe = function subscribe (fn) { 12396 return genericSubscribe(fn, this._subscribers) 12397 }; 12398 12399 Store.prototype.subscribeAction = function subscribeAction (fn) { 12400 var subs = typeof fn === 'function' ? { before: fn } : fn; 12401 return genericSubscribe(subs, this._actionSubscribers) 12402 }; 12403 12404 Store.prototype.watch = function watch (getter, cb, options) { 12405 var this$1 = this; 12406 12407 { 12408 assert(typeof getter === 'function', "store.watch only accepts a function."); 12409 } 12410 return this._watcherVM.$watch(function () { return getter(this$1.state, this$1.getters); }, cb, options) 12411 }; 12412 12413 Store.prototype.replaceState = function replaceState (state) { 12414 var this$1 = this; 12415 12416 this._withCommit(function () { 12417 this$1._vm._data.$$state = state; 12418 }); 12419 }; 12420 12421 Store.prototype.registerModule = function registerModule (path, rawModule, options) { 12422 if ( options === void 0 ) options = {}; 12423 12424 if (typeof path === 'string') { path = [path]; } 12425 12426 { 12427 assert(Array.isArray(path), "module path must be a string or an Array."); 12428 assert(path.length > 0, 'cannot register the root module by using registerModule.'); 12429 } 12430 12431 this._modules.register(path, rawModule); 12432 installModule(this, this.state, path, this._modules.get(path), options.preserveState); 12433 // reset store to update getters... 12434 resetStoreVM(this, this.state); 12435 }; 12436 12437 Store.prototype.unregisterModule = function unregisterModule (path) { 12438 var this$1 = this; 12439 12440 if (typeof path === 'string') { path = [path]; } 12441 12442 { 12443 assert(Array.isArray(path), "module path must be a string or an Array."); 12444 } 12445 12446 this._modules.unregister(path); 12447 this._withCommit(function () { 12448 var parentState = getNestedState(this$1.state, path.slice(0, -1)); 12449 Vue.delete(parentState, path[path.length - 1]); 12450 }); 12451 resetStore(this); 12452 }; 12453 12454 Store.prototype.hotUpdate = function hotUpdate (newOptions) { 12455 this._modules.update(newOptions); 12456 resetStore(this, true); 12457 }; 12458 12459 Store.prototype._withCommit = function _withCommit (fn) { 12460 var committing = this._committing; 12461 this._committing = true; 12462 fn(); 12463 this._committing = committing; 12464 }; 12465 12466 Object.defineProperties( Store.prototype, prototypeAccessors$1 ); 12467 12468 function genericSubscribe (fn, subs) { 12469 if (subs.indexOf(fn) < 0) { 12470 subs.push(fn); 12471 } 12472 return function () { 12473 var i = subs.indexOf(fn); 12474 if (i > -1) { 12475 subs.splice(i, 1); 12476 } 12477 } 12478 } 12479 12480 function resetStore (store, hot) { 12481 store._actions = Object.create(null); 12482 store._mutations = Object.create(null); 12483 store._wrappedGetters = Object.create(null); 12484 store._modulesNamespaceMap = Object.create(null); 12485 var state = store.state; 12486 // init all modules 12487 installModule(store, state, [], store._modules.root, true); 12488 // reset vm 12489 resetStoreVM(store, state, hot); 12490 } 12491 12492 function resetStoreVM (store, state, hot) { 12493 var oldVm = store._vm; 12494 12495 // bind store public getters 12496 store.getters = {}; 12497 var wrappedGetters = store._wrappedGetters; 12498 var computed = {};
12499 forEachValue(wrappedGetters, function (fn, key) { 12500 // use computed to leverage its lazy-caching mechanism 12501 computed[key] = function () { return fn(store); }; 12502 Object.defineProperty(store.getters, key, { 12503 get: function () { return store._vm[key]; }, 12504 enumerable: true // for local getters 12505 }); 12506 }); 12507 12508 // use a Vue instance to store the state tree 12509 // suppress warnings just in case the user has added 12510 // some funky global mixins 12511 var silent = Vue.config.silent; 12512 Vue.config.silent = true; 12513 store._vm = new Vue({ 12514 data: { 12515 $$state: state 12516 }, 12517 computed: computed 12518 }); 12519 Vue.config.silent = silent; 12520 12521 // enable strict mode for new vm 12522 if (store.strict) { 12523 enableStrictMode(store); 12524 } 12525 12526 if (oldVm) { 12527 if (hot) { 12528 // dispatch changes in all subscribed watchers 12529 // to force getter re-evaluation for hot reloading. 12530 store._withCommit(function () { 12531 oldVm._data.$$state = null; 12532 }); 12533 } 12534 Vue.nextTick(function () { return oldVm.$destroy(); }); 12535 } 12536 } 12537 12538 function installModule (store, rootState, path, module, hot) { 12539 var isRoot = !path.length; 12540 var namespace = store._modules.getNamespace(path); 12541 12542 // register in namespace map 12543 if (module.namespaced) { 12544 store._modulesNamespaceMap[namespace] = module; 12545 } 12546 12547 // set state 12548 if (!isRoot && !hot) { 12549 var parentState = getNestedState(rootState, path.slice(0, -1)); 12550 var moduleName = path[path.length - 1]; 12551 store._withCommit(function () { 12552 Vue.set(parentState, moduleName, module.state); 12553 }); 12554 } 12555 12556 var local = module.context = makeLocalContext(store, namespace, path); 12557 12558 module.forEachMutation(function (mutation, key) { 12559 var namespacedType = namespace + key; 12560 registerMutation(store, namespacedType, mutation, local); 12561 }); 12562 12563 module.forEachAction(function (action, key) { 12564 var type = action.root ? key : namespace + key; 12565 var handler = action.handler || action; 12566 registerAction(store, type, handler, local); 12567 }); 12568 12569 module.forEachGetter(function (getter, key) { 12570 var namespacedType = namespace + key; 12571 registerGetter(store, namespacedType, getter, local); 12572 }); 12573 12574 module.forEachChild(function (child, key) { 12575 installModule(store, rootState, path.concat(key), child, hot); 12576 }); 12577 } 12578 12579 /** 12580 * make localized dispatch, commit, getters and state 12581 * if there is no namespace, just use root ones 12582 */ 12583 function makeLocalContext (store, namespace, path) { 12584 var noNamespace = namespace === ''; 12585 12586 var local = { 12587 dispatch: noNamespace ? store.dispatch : function (_type, _payload, _options) { 12588 var args = unifyObjectStyle(_type, _payload, _options); 12589 var payload = args.payload; 12590 var options = args.options; 12591 var type = args.type; 12592 12593 if (!options || !options.root) { 12594 type = namespace + type; 12595 if (!store._actions[type]) { 12596 console.error(("[vuex] unknown local action type: " + (args.type) + ", global type: " + type)); 12597 return 12598 } 12599 } 12600 12601 return store.dispatch(type, payload) 12602 }, 12603 12604 commit: noNamespace ? store.commit : function (_type, _payload, _options) { 12605 var args = unifyObjectStyle(_type, _payload, _options); 12606 var payload = args.payload; 12607 var options = args.options; 12608 var type = args.type; 12609 12610 if (!options || !options.root) { 12611 type = namespace + type; 12612 if (!store._mutations[type]) { 12613 console.error(("[vuex] unknown local mutation type: " + (args.type) + ", global type: " + type)); 12614 return 12615 } 12616 } 12617 12618 store.commit(type, payload, options); 12619 } 12620 }; 12621 12622 // getters and state object must be gotten lazily 12623 // because they will be changed by vm update 12624 Object.defineProperties(local, { 12625 getters: { 12626 get: noNamespace 12627 ? function () { return store.getters; } 12628 : function () { return makeLocalGetters(store, namespace); } 12629 }, 12630 state: { 12631 get: function () { return getNestedState(store.state, path); } 12632 } 12633 }); 12634 12635 return local 12636 } 12637 12638 function makeLocalGetters (store, namespace) { 12639 var gettersProxy = {}; 12640 12641 var splitPos = namespace.length;
vendor: 5,427 bytes, lines 12642-12791
12642 Object.keys(store.getters).forEach(function (type) { 12643 // skip if the target getter is not match this namespace 12644 if (type.slice(0, splitPos) !== namespace) { return } 12645 12646 // extract local getter type 12647 var localType = type.slice(splitPos); 12648 12649 // Add a port to the getters proxy. 12650 // Define as getter property because 12651 // we do not want to evaluate the getters in this time. 12652 Object.defineProperty(gettersProxy, localType, { 12653 get: function () { return store.getters[type]; }, 12654 enumerable: true 12655 }); 12656 }); 12657 12658 return gettersProxy 12659 } 12660 12661 function registerMutation (store, type, handler, local) { 12662 var entry = store._mutations[type] || (store._mutations[type] = []); 12663 entry.push(function wrappedMutationHandler (payload) { 12664 handler.call(store, local.state, payload); 12665 }); 12666 } 12667 12668 function registerAction (store, type, handler, local) { 12669 var entry = store._actions[type] || (store._actions[type] = []); 12670 entry.push(function wrappedActionHandler (payload, cb) { 12671 var res = handler.call(store, { 12672 dispatch: local.dispatch, 12673 commit: local.commit, 12674 getters: local.getters, 12675 state: local.state, 12676 rootGetters: store.getters, 12677 rootState: store.state 12678 }, payload, cb); 12679 if (!isPromise(res)) { 12680 res = Promise.resolve(res); 12681 } 12682 if (store._devtoolHook) { 12683 return res.catch(function (err) { 12684 store._devtoolHook.emit('vuex:error', err); 12685 throw err 12686 }) 12687 } else { 12688 return res 12689 } 12690 }); 12691 } 12692 12693 function registerGetter (store, type, rawGetter, local) { 12694 if (store._wrappedGetters[type]) { 12695 { 12696 console.error(("[vuex] duplicate getter key: " + type)); 12697 } 12698 return 12699 } 12700 store._wrappedGetters[type] = function wrappedGetter (store) { 12701 return rawGetter( 12702 local.state, // local state 12703 local.getters, // local getters 12704 store.state, // root state 12705 store.getters // root getters 12706 ) 12707 }; 12708 } 12709 12710 function enableStrictMode (store) { 12711 store._vm.$watch(function () { return this._data.$$state }, function () { 12712 { 12713 assert(store._committing, "do not mutate vuex store state outside mutation handlers."); 12714 } 12715 }, { deep: true, sync: true }); 12716 } 12717 12718 function getNestedState (state, path) { 12719 return path.length 12720 ? path.reduce(function (state, key) { return state[key]; }, state) 12721 : state 12722 } 12723 12724 function unifyObjectStyle (type, payload, options) { 12725 if (isObject(type) && type.type) { 12726 options = payload; 12727 payload = type; 12728 type = type.type; 12729 } 12730 12731 { 12732 assert(typeof type === 'string', ("expects string as the type, but found " + (typeof type) + ".")); 12733 } 12734 12735 return { type: type, payload: payload, options: options } 12736 } 12737 12738 function install (_Vue) { 12739 if (Vue && _Vue === Vue) { 12740 { 12741 console.error( 12742 '[vuex] already installed. Vue.use(Vuex) should be called only once.' 12743 ); 12744 } 12745 return 12746 } 12747 Vue = _Vue; 12748 applyMixin(Vue); 12749 } 12750 12751 /** 12752 * Reduce the code which written in Vue.js for getting the state. 12753 * @param {String} [namespace] - Module's namespace 12754 * @param {Object|Array} states # Object's item can be a function which accept state and getters for param, you can do something for state and getters in it. 12755 * @param {Object} 12756 */ 12757 var mapState = normalizeNamespace(function (namespace, states) { 12758 var res = {}; 12759 normalizeMap(states).forEach(function (ref) { 12760 var key = ref.key; 12761 var val = ref.val; 12762 12763 res[key] = function mappedState () { 12764 var state = this.$store.state; 12765 var getters = this.$store.getters; 12766 if (namespace) { 12767 var module = getModuleByNamespace(this.$store, 'mapState', namespace); 12768 if (!module) { 12769 return 12770 } 12771 state = module.context.state; 12772 getters = module.context.getters; 12773 } 12774 return typeof val === 'function' 12775 ? val.call(this, state, getters) 12776 : state[val] 12777 }; 12778 // mark vuex getter for devtools 12779 res[key].vuex = true; 12780 }); 12781 return res 12782 }); 12783 12784 /** 12785 * Reduce the code which written in Vue.js for committing the mutation 12786 * @param {String} [namespace] - Module's namespace 12787 * @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept anthor params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function. 12788 * @return {Object} 12789 */ 12790 var mapMutations = normalizeNamespace(function (namespace, mutations) { 12791 var res = {};
vendor: 4,468 bytes, lines 12792-12905
12792 normalizeMap(mutations).forEach(function (ref) { 12793 var key = ref.key; 12794 var val = ref.val; 12795 12796 res[key] = function mappedMutation () { 12797 var args = [], len = arguments.length; 12798 while ( len-- ) args[ len ] = arguments[ len ]; 12799 12800 // Get the commit method from store 12801 var commit = this.$store.commit; 12802 if (namespace) { 12803 var module = getModuleByNamespace(this.$store, 'mapMutations', namespace); 12804 if (!module) { 12805 return 12806 } 12807 commit = module.context.commit; 12808 } 12809 return typeof val === 'function' 12810 ? val.apply(this, [commit].concat(args)) 12811 : commit.apply(this.$store, [val].concat(args)) 12812 }; 12813 }); 12814 return res 12815 }); 12816 12817 /** 12818 * Reduce the code which written in Vue.js for getting the getters 12819 * @param {String} [namespace] - Module's namespace 12820 * @param {Object|Array} getters 12821 * @return {Object} 12822 */ 12823 var mapGetters = normalizeNamespace(function (namespace, getters) { 12824 var res = {}; 12825 normalizeMap(getters).forEach(function (ref) { 12826 var key = ref.key; 12827 var val = ref.val; 12828 12829 // The namespace has been mutated by normalizeNamespace 12830 val = namespace + val; 12831 res[key] = function mappedGetter () { 12832 if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) { 12833 return 12834 } 12835 if (!(val in this.$store.getters)) { 12836 console.error(("[vuex] unknown getter: " + val)); 12837 return 12838 } 12839 return this.$store.getters[val] 12840 }; 12841 // mark vuex getter for devtools 12842 res[key].vuex = true; 12843 }); 12844 return res 12845 }); 12846 12847 /** 12848 * Reduce the code which written in Vue.js for dispatch the action 12849 * @param {String} [namespace] - Module's namespace 12850 * @param {Object|Array} actions # Object's item can be a function which accept `dispatch` function as the first param, it can accept anthor params. You can dispatch action and do any other things in this function. specially, You need to pass anthor params from the mapped function. 12851 * @return {Object} 12852 */ 12853 var mapActions = normalizeNamespace(function (namespace, actions) { 12854 var res = {}; 12855 normalizeMap(actions).forEach(function (ref) { 12856 var key = ref.key; 12857 var val = ref.val; 12858 12859 res[key] = function mappedAction () { 12860 var args = [], len = arguments.length; 12861 while ( len-- ) args[ len ] = arguments[ len ]; 12862 12863 // get dispatch function from store 12864 var dispatch = this.$store.dispatch; 12865 if (namespace) { 12866 var module = getModuleByNamespace(this.$store, 'mapActions', namespace); 12867 if (!module) { 12868 return 12869 } 12870 dispatch = module.context.dispatch; 12871 } 12872 return typeof val === 'function' 12873 ? val.apply(this, [dispatch].concat(args)) 12874 : dispatch.apply(this.$store, [val].concat(args)) 12875 }; 12876 }); 12877 return res 12878 }); 12879 12880 /** 12881 * Rebinding namespace param for mapXXX function in special scoped, and return them by simple object 12882 * @param {String} namespace 12883 * @return {Object} 12884 */ 12885 var createNamespacedHelpers = function (namespace) { return ({ 12886 mapState: mapState.bind(null, namespace), 12887 mapGetters: mapGetters.bind(null, namespace), 12888 mapMutations: mapMutations.bind(null, namespace), 12889 mapActions: mapActions.bind(null, namespace) 12890 }); }; 12891 12892 /** 12893 * Normalize the map 12894 * normalizeMap([1, 2, 3]) => [ { key: 1, val: 1 }, { key: 2, val: 2 }, { key: 3, val: 3 } ] 12895 * normalizeMap({a: 1, b: 2, c: 3}) => [ { key: 'a', val: 1 }, { key: 'b', val: 2 }, { key: 'c', val: 3 } ] 12896 * @param {Array|Object} map 12897 * @return {Object} 12898 */ 12899 function normalizeMap (map) { 12900 return Array.isArray(map) 12901 ? map.map(function (key) { return ({ key: key, val: key }); }) 12902 : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); }) 12903 } 12904 12905 /**
vendor: 6,603 bytes, lines 12906-13129
12906 * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map. 12907 * @param {Function} fn 12908 * @return {Function} 12909 */ 12910 function normalizeNamespace (fn) { 12911 return function (namespace, map) { 12912 if (typeof namespace !== 'string') { 12913 map = namespace; 12914 namespace = ''; 12915 } else if (namespace.charAt(namespace.length - 1) !== '/') { 12916 namespace += '/'; 12917 } 12918 return fn(namespace, map) 12919 } 12920 } 12921 12922 /** 12923 * Search a special module from store by namespace. if module not exist, print error message. 12924 * @param {Object} store 12925 * @param {String} helper 12926 * @param {String} namespace 12927 * @return {Object} 12928 */ 12929 function getModuleByNamespace (store, helper, namespace) { 12930 var module = store._modulesNamespaceMap[namespace]; 12931 if (!module) { 12932 console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace)); 12933 } 12934 return module 12935 } 12936 12937 var index = { 12938 Store: Store, 12939 install: install, 12940 version: '3.1.0', 12941 mapState: mapState, 12942 mapMutations: mapMutations, 12943 mapGetters: mapGetters, 12944 mapActions: mapActions, 12945 createNamespacedHelpers: createNamespacedHelpers 12946 }; 12947 12948 return index; 12949 12950})); 12951/*! 12952 * vue-resource v1.3.4 12953 * https://github.com/pagekit/vue-resource 12954 * Released under the MIT License. 12955 */ 12956 12957(function (global, factory) { 12958 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 12959 typeof define === 'function' && define.amd ? define(factory) : 12960 (global.VueResource = factory()); 12961}(this, (function () { 'use strict'; 12962 12963 /** 12964 * Promises/A+ polyfill v1.1.4 (https://github.com/bramstein/promis) 12965 */ 12966 12967 var RESOLVED = 0; 12968 var REJECTED = 1; 12969 var PENDING = 2; 12970 12971 function Promise$1(executor) { 12972 12973 this.state = PENDING; 12974 this.value = undefined; 12975 this.deferred = []; 12976 12977 var promise = this; 12978 12979 try { 12980 executor(function (x) { 12981 promise.resolve(x); 12982 }, function (r) { 12983 promise.reject(r); 12984 }); 12985 } catch (e) { 12986 promise.reject(e); 12987 } 12988 } 12989 12990 Promise$1.reject = function (r) { 12991 return new Promise$1(function (resolve, reject) { 12992 reject(r); 12993 }); 12994 }; 12995 12996 Promise$1.resolve = function (x) { 12997 return new Promise$1(function (resolve, reject) { 12998 resolve(x); 12999 }); 13000 }; 13001 13002 Promise$1.all = function all(iterable) { 13003 return new Promise$1(function (resolve, reject) { 13004 var count = 0, result = []; 13005 13006 if (iterable.length === 0) { 13007 resolve(result); 13008 } 13009 13010 function resolver(i) { 13011 return function (x) { 13012 result[i] = x; 13013 count += 1; 13014 13015 if (count === iterable.length) { 13016 resolve(result); 13017 } 13018 }; 13019 } 13020 13021 for (var i = 0; i < iterable.length; i += 1) { 13022 Promise$1.resolve(iterable[i]).then(resolver(i), reject); 13023 } 13024 }); 13025 }; 13026 13027 Promise$1.race = function race(iterable) { 13028 return new Promise$1(function (resolve, reject) { 13029 for (var i = 0; i < iterable.length; i += 1) { 13030 Promise$1.resolve(iterable[i]).then(resolve, reject); 13031 } 13032 }); 13033 }; 13034 13035 var p$1 = Promise$1.prototype; 13036 13037 p$1.resolve = function resolve(x) { 13038 var promise = this; 13039 13040 if (promise.state === PENDING) { 13041 if (x === promise) { 13042 throw new TypeError('Promise settled with itself.'); 13043 } 13044 13045 var called = false; 13046 13047 try { 13048 var then = x && x['then']; 13049 13050 if (x !== null && typeof x === 'object' && typeof then === 'function') { 13051 then.call(x, function (x) { 13052 if (!called) { 13053 promise.resolve(x); 13054 } 13055 called = true; 13056 13057 }, function (r) { 13058 if (!called) { 13059 promise.reject(r); 13060 } 13061 called = true; 13062 }); 13063 return; 13064 } 13065 } catch (e) { 13066 if (!called) { 13067 promise.reject(e); 13068 } 13069 return; 13070 } 13071 13072 promise.state = RESOLVED; 13073 promise.value = x; 13074 promise.notify(); 13075 } 13076 }; 13077 13078 p$1.reject = function reject(reason) { 13079 var promise = this; 13080 13081 if (promise.state === PENDING) { 13082 if (reason === promise) { 13083 throw new TypeError('Promise settled with itself.'); 13084 } 13085 13086 promise.state = REJECTED; 13087 promise.value = reason; 13088 promise.notify(); 13089 } 13090 }; 13091 13092 p$1.notify = function notify() { 13093 var promise = this; 13094 13095 nextTick(function () { 13096 if (promise.state !== PENDING) { 13097 while (promise.deferred.length) { 13098 var deferred = promise.deferred.shift(), 13099 onResolved = deferred[0], 13100 onRejected = deferred[1], 13101 resolve = deferred[2], 13102 reject = deferred[3]; 13103 13104 try { 13105 if (promise.state === RESOLVED) { 13106 if (typeof onResolved === 'function') { 13107 resolve(onResolved.call(undefined, promise.value)); 13108 } else { 13109 resolve(promise.value); 13110 } 13111 } else if (promise.state === REJECTED) { 13112 if (typeof onRejected === 'function') { 13113 resolve(onRejected.call(undefined, promise.value)); 13114 } else { 13115 reject(promise.value); 13116 } 13117 } 13118 } catch (e) { 13119 reject(e); 13120 } 13121 } 13122 } 13123 }); 13124 }; 13125 13126 p$1.then = function then(onResolved, onRejected) { 13127 var promise = this; 13128 13129 return new Promise$1(function (resolve, reject) {
vendor: 17,267 bytes, lines 13130-13794
13130 promise.deferred.push([onResolved, onRejected, resolve, reject]); 13131 promise.notify(); 13132 }); 13133 }; 13134 13135 p$1.catch = function (onRejected) { 13136 return this.then(undefined, onRejected); 13137 }; 13138 13139 /** 13140 * Promise adapter. 13141 */ 13142 13143 if (typeof Promise === 'undefined') { 13144 window.Promise = Promise$1; 13145 } 13146 13147 function PromiseObj(executor, context) { 13148 13149 if (executor instanceof Promise) { 13150 this.promise = executor; 13151 } else { 13152 this.promise = new Promise(executor.bind(context)); 13153 } 13154 13155 this.context = context; 13156 } 13157 13158 PromiseObj.all = function (iterable, context) { 13159 return new PromiseObj(Promise.all(iterable), context); 13160 }; 13161 13162 PromiseObj.resolve = function (value, context) { 13163 return new PromiseObj(Promise.resolve(value), context); 13164 }; 13165 13166 PromiseObj.reject = function (reason, context) { 13167 return new PromiseObj(Promise.reject(reason), context); 13168 }; 13169 13170 PromiseObj.race = function (iterable, context) { 13171 return new PromiseObj(Promise.race(iterable), context); 13172 }; 13173 13174 var p = PromiseObj.prototype; 13175 13176 p.bind = function (context) { 13177 this.context = context; 13178 return this; 13179 }; 13180 13181 p.then = function (fulfilled, rejected) { 13182 13183 if (fulfilled && fulfilled.bind && this.context) { 13184 fulfilled = fulfilled.bind(this.context); 13185 } 13186 13187 if (rejected && rejected.bind && this.context) { 13188 rejected = rejected.bind(this.context); 13189 } 13190 13191 return new PromiseObj(this.promise.then(fulfilled, rejected), this.context); 13192 }; 13193 13194 p.catch = function (rejected) { 13195 13196 if (rejected && rejected.bind && this.context) { 13197 rejected = rejected.bind(this.context); 13198 } 13199 13200 return new PromiseObj(this.promise.catch(rejected), this.context); 13201 }; 13202 13203 p.finally = function (callback) { 13204 13205 return this.then(function (value) { 13206 callback.call(this); 13207 return value; 13208 }, function (reason) { 13209 callback.call(this); 13210 return Promise.reject(reason); 13211 } 13212 ); 13213 }; 13214 13215 /** 13216 * Utility functions. 13217 */ 13218 13219 var ref = {}; 13220 var hasOwnProperty = ref.hasOwnProperty; 13221 13222 var ref$1 = []; 13223 var slice = ref$1.slice; 13224 var debug = false; 13225 var ntick; 13226 13227 var inBrowser = typeof window !== 'undefined'; 13228 13229 var Util = function (ref) { 13230 var config = ref.config; 13231 var nextTick = ref.nextTick; 13232 13233 ntick = nextTick; 13234 debug = config.debug || !config.silent; 13235 }; 13236 13237 function warn(msg) { 13238 if (typeof console !== 'undefined' && debug) { 13239 console.warn('[VueResource warn]: ' + msg); 13240 } 13241 } 13242 13243 function error(msg) { 13244 if (typeof console !== 'undefined') { 13245 console.error(msg); 13246 } 13247 } 13248 13249 function nextTick(cb, ctx) { 13250 return ntick(cb, ctx); 13251 } 13252 13253 function trim(str) { 13254 return str ? str.replace(/^\s*|\s*$/g, '') : ''; 13255 } 13256 13257 function trimEnd(str, chars) { 13258 13259 if (str && chars === undefined) { 13260 return str.replace(/\s+$/, ''); 13261 } 13262 13263 if (!str || !chars) { 13264 return str; 13265 } 13266 13267 return str.replace(new RegExp(("[" + chars + "]+$")), ''); 13268 } 13269 13270 function toLower(str) { 13271 return str ? str.toLowerCase() : ''; 13272 } 13273 13274 function toUpper(str) { 13275 return str ? str.toUpperCase() : ''; 13276 } 13277 13278 var isArray = Array.isArray; 13279 13280 function isString(val) { 13281 return typeof val === 'string'; 13282 } 13283 13284 13285 13286 function isFunction(val) { 13287 return typeof val === 'function'; 13288 } 13289 13290 function isObject(obj) { 13291 return obj !== null && typeof obj === 'object'; 13292 } 13293 13294 function isPlainObject(obj) { 13295 return isObject(obj) && Object.getPrototypeOf(obj) == Object.prototype; 13296 } 13297 13298 function isBlob(obj) { 13299 return typeof Blob !== 'undefined' && obj instanceof Blob; 13300 } 13301 13302 function isFormData(obj) { 13303 return typeof FormData !== 'undefined' && obj instanceof FormData; 13304 } 13305 13306 function when(value, fulfilled, rejected) { 13307 13308 var promise = PromiseObj.resolve(value); 13309 13310 if (arguments.length < 2) { 13311 return promise; 13312 } 13313 13314 return promise.then(fulfilled, rejected); 13315 } 13316 13317 function options(fn, obj, opts) { 13318 13319 opts = opts || {}; 13320 13321 if (isFunction(opts)) { 13322 opts = opts.call(obj); 13323 } 13324 13325 return merge(fn.bind({$vm: obj, $options: opts}), fn, {$options: opts}); 13326 } 13327 13328 function each(obj, iterator) { 13329 13330 var i, key; 13331 13332 if (isArray(obj)) { 13333 for (i = 0; i < obj.length; i++) { 13334 iterator.call(obj[i], obj[i], i); 13335 } 13336 } else if (isObject(obj)) { 13337 for (key in obj) { 13338 if (hasOwnProperty.call(obj, key)) { 13339 iterator.call(obj[key], obj[key], key); 13340 } 13341 } 13342 } 13343 13344 return obj; 13345 } 13346 13347 var assign = Object.assign || _assign; 13348 13349 function merge(target) { 13350 13351 var args = slice.call(arguments, 1); 13352 13353 args.forEach(function (source) { 13354 _merge(target, source, true); 13355 }); 13356 13357 return target; 13358 } 13359 13360 function defaults(target) { 13361 13362 var args = slice.call(arguments, 1); 13363 13364 args.forEach(function (source) { 13365 13366 for (var key in source) { 13367 if (target[key] === undefined) { 13368 target[key] = source[key]; 13369 } 13370 } 13371 13372 }); 13373 13374 return target; 13375 } 13376 13377 function _assign(target) { 13378 13379 var args = slice.call(arguments, 1); 13380 13381 args.forEach(function (source) { 13382 _merge(target, source); 13383 }); 13384 13385 return target; 13386 } 13387 13388 function _merge(target, source, deep) { 13389 for (var key in source) { 13390 if (deep && (isPlainObject(source[key]) || isArray(source[key]))) { 13391 if (isPlainObject(source[key]) && !isPlainObject(target[key])) { 13392 target[key] = {}; 13393 } 13394 if (isArray(source[key]) && !isArray(target[key])) { 13395 target[key] = []; 13396 } 13397 _merge(target[key], source[key], deep); 13398 } else if (source[key] !== undefined) { 13399 target[key] = source[key]; 13400 } 13401 } 13402 } 13403 13404 /** 13405 * Root Prefix Transform. 13406 */ 13407 13408 var root = function (options$$1, next) { 13409 13410 var url = next(options$$1); 13411 13412 if (isString(options$$1.root) && !/^(https?:)?\//.test(url)) { 13413 url = trimEnd(options$$1.root, '/') + '/' + url; 13414 } 13415 13416 return url; 13417 }; 13418 13419 /** 13420 * Query Parameter Transform. 13421 */ 13422 13423 var query = function (options$$1, next) { 13424 13425 var urlParams = Object.keys(Url.options.params), query = {}, url = next(options$$1); 13426 13427 each(options$$1.params, function (value, key) { 13428 if (urlParams.indexOf(key) === -1) { 13429 query[key] = value; 13430 } 13431 }); 13432 13433 query = Url.params(query); 13434 13435 if (query) { 13436 url += (url.indexOf('?') == -1 ? '?' : '&') + query; 13437 } 13438 13439 return url; 13440 }; 13441 13442 /** 13443 * URL Template v2.0.6 (https://github.com/bramstein/url-template) 13444 */ 13445 13446 function expand(url, params, variables) { 13447 13448 var tmpl = parse(url), expanded = tmpl.expand(params); 13449 13450 if (variables) { 13451 variables.push.apply(variables, tmpl.vars); 13452 } 13453 13454 return expanded; 13455 } 13456 13457 function parse(template) { 13458 13459 var operators = ['+', '#', '.', '/', ';', '?', '&'], variables = []; 13460 13461 return { 13462 vars: variables, 13463 expand: function expand(context) { 13464 return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, function (_, expression, literal) { 13465 if (expression) { 13466 13467 var operator = null, values = []; 13468 13469 if (operators.indexOf(expression.charAt(0)) !== -1) { 13470 operator = expression.charAt(0); 13471 expression = expression.substr(1); 13472 } 13473 13474 expression.split(/,/g).forEach(function (variable) { 13475 var tmp = /([^:\*]*)(?::(\d+)|(\*))?/.exec(variable); 13476 values.push.apply(values, getValues(context, operator, tmp[1], tmp[2] || tmp[3])); 13477 variables.push(tmp[1]); 13478 }); 13479 13480 if (operator && operator !== '+') { 13481 13482 var separator = ','; 13483 13484 if (operator === '?') { 13485 separator = '&'; 13486 } else if (operator !== '#') { 13487 separator = operator; 13488 } 13489 13490 return (values.length !== 0 ? operator : '') + values.join(separator); 13491 } else { 13492 return values.join(','); 13493 } 13494 13495 } else { 13496 return encodeReserved(literal); 13497 } 13498 }); 13499 } 13500 }; 13501 } 13502 13503 function getValues(context, operator, key, modifier) { 13504 13505 var value = context[key], result = []; 13506 13507 if (isDefined(value) && value !== '') { 13508 if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') { 13509 value = value.toString(); 13510 13511 if (modifier && modifier !== '*') { 13512 value = value.substring(0, parseInt(modifier, 10)); 13513 } 13514 13515 result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null)); 13516 } else { 13517 if (modifier === '*') { 13518 if (Array.isArray(value)) { 13519 value.filter(isDefined).forEach(function (value) { 13520 result.push(encodeValue(operator, value, isKeyOperator(operator) ? key : null)); 13521 }); 13522 } else { 13523 Object.keys(value).forEach(function (k) { 13524 if (isDefined(value[k])) { 13525 result.push(encodeValue(operator, value[k], k)); 13526 } 13527 }); 13528 } 13529 } else { 13530 var tmp = []; 13531 13532 if (Array.isArray(value)) { 13533 value.filter(isDefined).forEach(function (value) { 13534 tmp.push(encodeValue(operator, value)); 13535 }); 13536 } else { 13537 Object.keys(value).forEach(function (k) { 13538 if (isDefined(value[k])) { 13539 tmp.push(encodeURIComponent(k)); 13540 tmp.push(encodeValue(operator, value[k].toString())); 13541 } 13542 }); 13543 } 13544 13545 if (isKeyOperator(operator)) { 13546 result.push(encodeURIComponent(key) + '=' + tmp.join(',')); 13547 } else if (tmp.length !== 0) { 13548 result.push(tmp.join(',')); 13549 } 13550 } 13551 } 13552 } else { 13553 if (operator === ';') { 13554 result.push(encodeURIComponent(key)); 13555 } else if (value === '' && (operator === '&' || operator === '?')) { 13556 result.push(encodeURIComponent(key) + '='); 13557 } else if (value === '') { 13558 result.push(''); 13559 } 13560 } 13561 13562 return result; 13563 } 13564 13565 function isDefined(value) { 13566 return value !== undefined && value !== null; 13567 } 13568 13569 function isKeyOperator(operator) { 13570 return operator === ';' || operator === '&' || operator === '?'; 13571 } 13572 13573 function encodeValue(operator, value, key) { 13574 13575 value = (operator === '+' || operator === '#') ? encodeReserved(value) : encodeURIComponent(value); 13576 13577 if (key) { 13578 return encodeURIComponent(key) + '=' + value; 13579 } else { 13580 return value; 13581 } 13582 } 13583 13584 function encodeReserved(str) { 13585 return str.split(/(%[0-9A-Fa-f]{2})/g).map(function (part) { 13586 if (!/%[0-9A-Fa-f]/.test(part)) { 13587 part = encodeURI(part); 13588 } 13589 return part; 13590 }).join(''); 13591 } 13592 13593 /** 13594 * URL Template (RFC 6570) Transform. 13595 */ 13596 13597 var template = function (options) { 13598 13599 var variables = [], url = expand(options.url, options.params, variables); 13600 13601 variables.forEach(function (key) { 13602 delete options.params[key]; 13603 }); 13604 13605 return url; 13606 }; 13607 13608 /** 13609 * Service for URL templating. 13610 */ 13611 13612 function Url(url, params) { 13613 13614 var self = this || {}, options$$1 = url, transform; 13615 13616 if (isString(url)) { 13617 options$$1 = {url: url, params: params}; 13618 } 13619 13620 options$$1 = merge({}, Url.options, self.$options, options$$1); 13621 13622 Url.transforms.forEach(function (handler) { 13623 13624 if (isString(handler)) { 13625 handler = Url.transform[handler]; 13626 } 13627 13628 if (isFunction(handler)) { 13629 transform = factory(handler, transform, self.$vm); 13630 } 13631 13632 }); 13633 13634 return transform(options$$1); 13635 } 13636 13637 /** 13638 * Url options. 13639 */ 13640 13641 Url.options = { 13642 url: '', 13643 root: null, 13644 params: {} 13645 }; 13646 13647 /** 13648 * Url transforms. 13649 */ 13650 13651 Url.transform = {template: template, query: query, root: root}; 13652 Url.transforms = ['template', 'query', 'root']; 13653 13654 /** 13655 * Encodes a Url parameter string. 13656 * 13657 * @param {Object} obj 13658 */ 13659 13660 Url.params = function (obj) { 13661 13662 var params = [], escape = encodeURIComponent; 13663 13664 params.add = function (key, value) { 13665 13666 if (isFunction(value)) { 13667 value = value(); 13668 } 13669 13670 if (value === null) { 13671 value = ''; 13672 } 13673 13674 this.push(escape(key) + '=' + escape(value)); 13675 }; 13676 13677 serialize(params, obj); 13678 13679 return params.join('&').replace(/%20/g, '+'); 13680 }; 13681 13682 /** 13683 * Parse a URL and return its components. 13684 * 13685 * @param {String} url 13686 */ 13687 13688 Url.parse = function (url) { 13689 13690 var el = document.createElement('a'); 13691 13692 if (document.documentMode) { 13693 el.href = url; 13694 url = el.href; 13695 } 13696 13697 el.href = url; 13698 13699 return { 13700 href: el.href, 13701 protocol: el.protocol ? el.protocol.replace(/:$/, '') : '', 13702 port: el.port, 13703 host: el.host, 13704 hostname: el.hostname, 13705 pathname: el.pathname.charAt(0) === '/' ? el.pathname : '/' + el.pathname, 13706 search: el.search ? el.search.replace(/^\?/, '') : '', 13707 hash: el.hash ? el.hash.replace(/^#/, '') : '' 13708 }; 13709 }; 13710 13711 function factory(handler, next, vm) { 13712 return function (options$$1) { 13713 return handler.call(vm, options$$1, next); 13714 }; 13715 } 13716 13717 function serialize(params, obj, scope) { 13718 13719 var array = isArray(obj), plain = isPlainObject(obj), hash; 13720 13721 each(obj, function (value, key) { 13722 13723 hash = isObject(value) || isArray(value); 13724 13725 if (scope) { 13726 key = scope + '[' + (plain || hash ? key : '') + ']'; 13727 } 13728 13729 if (!scope && array) { 13730 params.add(value.name, value.value); 13731 } else if (hash) { 13732 serialize(params, value, key); 13733 } else { 13734 params.add(key, value); 13735 } 13736 }); 13737 } 13738 13739 /** 13740 * XDomain client (Internet Explorer). 13741 */ 13742 13743 var xdrClient = function (request) { 13744 return new PromiseObj(function (resolve) { 13745 13746 var xdr = new XDomainRequest(), handler = function (ref) { 13747 var type = ref.type; 13748 13749 13750 var status = 0; 13751 13752 if (type === 'load') { 13753 status = 200; 13754 } else if (type === 'error') { 13755 status = 500; 13756 } 13757 13758 resolve(request.respondWith(xdr.responseText, {status: status})); 13759 }; 13760 13761 request.abort = function () { return xdr.abort(); }; 13762 13763 xdr.open(request.method, request.getUrl()); 13764 13765 if (request.timeout) { 13766 xdr.timeout = request.timeout; 13767 } 13768 13769 xdr.onload = handler; 13770 xdr.onabort = handler; 13771 xdr.onerror = handler; 13772 xdr.ontimeout = handler; 13773 xdr.onprogress = function () {}; 13774 xdr.send(request.getBody()); 13775 }); 13776 }; 13777 13778 /** 13779 * CORS Interceptor. 13780 */ 13781 13782 var SUPPORTS_CORS = inBrowser && 'withCredentials' in new XMLHttpRequest(); 13783 13784 var cors = function (request, next) { 13785 13786 if (inBrowser) { 13787 13788 var orgUrl = Url.parse(location.href); 13789 var reqUrl = Url.parse(request.getUrl()); 13790 13791 if (reqUrl.protocol !== orgUrl.protocol || reqUrl.host !== orgUrl.host) { 13792 13793 request.crossOrigin = true; 13794 request.emulateHTTP = false;
13795 13796 if (!SUPPORTS_CORS) { 13797 request.client = xdrClient; 13798 } 13799 } 13800 } 13801 13802 next(); 13803 }; 13804 13805 /** 13806 * Form data Interceptor. 13807 */ 13808 13809 var form = function (request, next) { 13810 13811 if (isFormData(request.body)) { 13812 13813 request.headers.delete('Content-Type'); 13814 13815 } else if (isObject(request.body) && request.emulateJSON) { 13816 13817 request.body = Url.params(request.body); 13818 request.headers.set('Content-Type', 'application/x-www-form-urlencoded'); 13819 } 13820 13821 next(); 13822 }; 13823 13824 /** 13825 * JSON Interceptor. 13826 */ 13827 13828 var json = function (request, next) { 13829 13830 var type = request.headers.get('Content-Type') || ''; 13831 13832 if (isObject(request.body) && type.indexOf('application/json') === 0) { 13833 request.body = JSON.stringify(request.body); 13834 } 13835 13836 next(function (response) { 13837 13838 return response.bodyText ? when(response.text(), function (text) { 13839 13840 type = response.headers.get('Content-Type') || ''; 13841 13842 if (type.indexOf('application/json') === 0 || isJson(text)) { 13843 13844 try { 13845 response.body = JSON.parse(text); 13846 } catch (e) { 13847 response.body = null; 13848 } 13849 13850 } else { 13851 response.body = text; 13852 } 13853 13854 return response; 13855 13856 }) : response; 13857 13858 }); 13859 }; 13860 13861 function isJson(str) { 13862 13863 var start = str.match(/^\[|^\{(?!\{)/), end = {'[': /]$/, '{': /}$/}; 13864 13865 return start && end[start[0]].test(str); 13866 } 13867 13868 /** 13869 * JSONP client (Browser). 13870 */ 13871 13872 var jsonpClient = function (request) { 13873 return new PromiseObj(function (resolve) { 13874 13875 var name = request.jsonp || 'callback', callback = request.jsonpCallback || '_jsonp' + Math.random().toString(36).substr(2), body = null, handler, script; 13876 13877 handler = function (ref) { 13878 var type = ref.type; 13879 13880 13881 var status = 0; 13882 13883 if (type === 'load' && body !== null) { 13884 status = 200; 13885 } else if (type === 'error') { 13886 status = 500; 13887 } 13888 13889 if (status && window[callback]) { 13890 delete window[callback]; 13891 document.body.removeChild(script); 13892 } 13893 13894 resolve(request.respondWith(body, {status: status})); 13895 }; 13896 13897 window[callback] = function (result) { 13898 body = JSON.stringify(result); 13899 }; 13900 13901 request.abort = function () { 13902 handler({type: 'abort'}); 13903 }; 13904 13905 request.params[name] = callback; 13906 13907 if (request.timeout) { 13908 setTimeout(request.abort, request.timeout); 13909 } 13910 13911 script = document.createElement('script'); 13912 script.src = request.getUrl(); 13913 script.type = 'text/javascript'; 13914 script.async = true; 13915 script.onload = handler; 13916 script.onerror = handler; 13917 13918 document.body.appendChild(script); 13919 }); 13920 }; 13921 13922 /** 13923 * JSONP Interceptor. 13924 */ 13925 13926 var jsonp = function (request, next) { 13927 13928 if (request.method == 'JSONP') { 13929 request.client = jsonpClient; 13930 } 13931 13932 next(); 13933 }; 13934 13935 /** 13936 * Before Interceptor. 13937 */ 13938 13939 var before = function (request, next) { 13940 13941 if (isFunction(request.before)) { 13942 request.before.call(this, request); 13943 } 13944 13945 next(); 13946 }; 13947 13948 /** 13949 * HTTP method override Interceptor. 13950 */ 13951 13952 var method = function (request, next) { 13953 13954 if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) { 13955 request.headers.set('X-HTTP-Method-Override', request.method); 13956 request.method = 'POST'; 13957 } 13958 13959 next(); 13960 }; 13961 13962 /** 13963 * Header Interceptor. 13964 */ 13965 13966 var header = function (request, next) { 13967 13968 var headers = assign({}, Http.headers.common, 13969 !request.crossOrigin ? Http.headers.custom : {}, 13970 Http.headers[toLower(request.method)] 13971 ); 13972 13973 each(headers, function (value, name) { 13974 if (!request.headers.has(name)) { 13975 request.headers.set(name, value); 13976 } 13977 }); 13978 13979 next(); 13980 }; 13981 13982 /** 13983 * XMLHttp client (Browser). 13984 */ 13985 13986 var xhrClient = function (request) { 13987 return new PromiseObj(function (resolve) { 13988 13989 var xhr = new XMLHttpRequest(), handler = function (event) { 13990 13991 var response = request.respondWith( 13992 'response' in xhr ? xhr.response : xhr.responseText, { 13993 status: xhr.status === 1223 ? 204 : xhr.status, // IE9 status bug 13994 statusText: xhr.status === 1223 ? 'No Content' : trim(xhr.statusText) 13995 } 13996 ); 13997 13998 each(trim(xhr.getAllResponseHeaders()).split('\n'), function (row) { 13999 response.headers.append(row.slice(0, row.indexOf(':')), row.slice(row.indexOf(':') + 1)); 14000 }); 14001 14002 resolve(response); 14003 }; 14004 14005 request.abort = function () { return xhr.abort(); }; 14006 14007 if (request.progress) { 14008 if (request.method === 'GET') { 14009 xhr.addEventListener('progress', request.progress); 14010 } else if (/^(POST|PUT)$/i.test(request.method)) { 14011 xhr.upload.addEventListener('progress', request.progress); 14012 } 14013 } 14014 14015 xhr.open(request.method, request.getUrl(), true); 14016 14017 if (request.timeout) { 14018 xhr.timeout = request.timeout; 14019 } 14020 14021 if (request.responseType && 'responseType' in xhr) { 14022 xhr.responseType = request.responseType; 14023 } 14024 14025 if (request.withCredentials || request.credentials) { 14026 xhr.withCredentials = true; 14027 } 14028 14029 if (!request.crossOrigin) { 14030 request.headers.set('X-Requested-With', 'XMLHttpRequest'); 14031 } 14032
14033 request.headers.forEach(function (value, name) { 14034 xhr.setRequestHeader(name, value); 14035 }); 14036 14037 xhr.onload = handler; 14038 xhr.onabort = handler; 14039 xhr.onerror = handler; 14040 xhr.ontimeout = handler; 14041 xhr.send(request.getBody()); 14042 }); 14043 }; 14044 14045 /** 14046 * Http client (Node). 14047 */ 14048 14049 var nodeClient = function (request) { 14050 14051 var client = require('got'); 14052 14053 return new PromiseObj(function (resolve) { 14054 14055 var url = request.getUrl(); 14056 var body = request.getBody(); 14057 var method = request.method; 14058 var headers = {}, handler; 14059 14060 request.headers.forEach(function (value, name) { 14061 headers[name] = value; 14062 }); 14063 14064 client(url, {body: body, method: method, headers: headers}).then(handler = function (resp) { 14065 14066 var response = request.respondWith(resp.body, { 14067 status: resp.statusCode, 14068 statusText: trim(resp.statusMessage) 14069 } 14070 ); 14071 14072 each(resp.headers, function (value, name) { 14073 response.headers.set(name, value); 14074 }); 14075 14076 resolve(response); 14077 14078 }, function (error$$1) { return handler(error$$1.response); }); 14079 }); 14080 }; 14081 14082 /** 14083 * Base client. 14084 */ 14085 14086 var Client = function (context) { 14087 14088 var reqHandlers = [sendRequest], resHandlers = [], handler; 14089 14090 if (!isObject(context)) { 14091 context = null; 14092 } 14093 14094 function Client(request) { 14095 return new PromiseObj(function (resolve, reject) { 14096 14097 function exec() { 14098 14099 handler = reqHandlers.pop(); 14100 14101 if (isFunction(handler)) { 14102 handler.call(context, request, next); 14103 } else { 14104 warn(("Invalid interceptor of type " + (typeof handler) + ", must be a function")); 14105 next(); 14106 } 14107 } 14108 14109 function next(response) { 14110 14111 if (isFunction(response)) { 14112 14113 resHandlers.unshift(response); 14114 14115 } else if (isObject(response)) { 14116 14117 resHandlers.forEach(function (handler) { 14118 response = when(response, function (response) { 14119 return handler.call(context, response) || response; 14120 }, reject); 14121 }); 14122 14123 when(response, resolve, reject); 14124 14125 return; 14126 } 14127 14128 exec(); 14129 } 14130 14131 exec(); 14132 14133 }, context); 14134 } 14135 14136 Client.use = function (handler) { 14137 reqHandlers.push(handler); 14138 }; 14139 14140 return Client; 14141 }; 14142 14143 function sendRequest(request, resolve) { 14144 14145 var client = request.client || (inBrowser ? xhrClient : nodeClient); 14146 14147 resolve(client(request)); 14148 } 14149 14150 /** 14151 * HTTP Headers. 14152 */ 14153 14154 var Headers = function Headers(headers) { 14155 var this$1 = this; 14156 14157 14158 this.map = {}; 14159 14160 each(headers, function (value, name) { return this$1.append(name, value); }); 14161 }; 14162 14163 Headers.prototype.has = function has (name) { 14164 return getName(this.map, name) !== null; 14165 }; 14166 14167 Headers.prototype.get = function get (name) { 14168 14169 var list = this.map[getName(this.map, name)]; 14170 14171 return list ? list.join() : null; 14172 }; 14173 14174 Headers.prototype.getAll = function getAll (name) { 14175 return this.map[getName(this.map, name)] || []; 14176 }; 14177 14178 Headers.prototype.set = function set (name, value) { 14179 this.map[normalizeName(getName(this.map, name) || name)] = [trim(value)]; 14180 }; 14181 14182 Headers.prototype.append = function append (name, value){ 14183 14184 var list = this.map[getName(this.map, name)]; 14185 14186 if (list) { 14187 list.push(trim(value)); 14188 } else { 14189 this.set(name, value); 14190 } 14191 }; 14192 14193 Headers.prototype.delete = function delete$1 (name){ 14194 delete this.map[getName(this.map, name)]; 14195 }; 14196 14197 Headers.prototype.deleteAll = function deleteAll (){ 14198 this.map = {}; 14199 }; 14200 14201 Headers.prototype.forEach = function forEach (callback, thisArg) { 14202 var this$1 = this; 14203 14204 each(this.map, function (list, name) { 14205 each(list, function (value) { return callback.call(thisArg, value, name, this$1); }); 14206 }); 14207 }; 14208 14209 function getName(map, name) { 14210 return Object.keys(map).reduce(function (prev, curr) { 14211 return toLower(name) === toLower(curr) ? curr : prev; 14212 }, null); 14213 } 14214 14215 function normalizeName(name) { 14216 14217 if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { 14218 throw new TypeError('Invalid character in header field name'); 14219 } 14220 14221 return trim(name); 14222 } 14223 14224 /** 14225 * HTTP Response. 14226 */ 14227 14228 var Response = function Response(body, ref) { 14229 var url = ref.url; 14230 var headers = ref.headers; 14231 var status = ref.status; 14232 var statusText = ref.statusText; 14233 14234 14235 this.url = url; 14236 this.ok = status >= 200 && status < 300; 14237 this.status = status || 0; 14238 this.statusText = statusText || ''; 14239 this.headers = new Headers(headers); 14240 this.body = body; 14241 14242 if (isString(body)) { 14243 14244 this.bodyText = body; 14245 14246 } else if (isBlob(body)) { 14247 14248 this.bodyBlob = body; 14249 14250 if (isBlobText(body)) { 14251 this.bodyText = blobText(body); 14252 } 14253 } 14254 }; 14255 14256 Response.prototype.blob = function blob () { 14257 return when(this.bodyBlob); 14258 }; 14259 14260 Response.prototype.text = function text () { 14261 return when(this.bodyText); 14262 }; 14263 14264 Response.prototype.json = function json () { 14265 return when(this.text(), function (text) { return JSON.parse(text); }); 14266 }; 14267 14268 Object.defineProperty(Response.prototype, 'data', { 14269 14270 get: function get() { 14271 return this.body; 14272 }, 14273 14274 set: function set(body) { 14275 this.body = body; 14276 } 14277 14278 }); 14279 14280 function blobText(body) { 14281 return new PromiseObj(function (resolve) { 14282 14283 var reader = new FileReader(); 14284 14285 reader.readAsText(body); 14286 reader.onload = function () { 14287 resolve(reader.result); 14288 }; 14289 14290 }); 14291 } 14292 14293 function isBlobText(body) { 14294 return body.type.indexOf('text') === 0 || body.type.indexOf('json') !== -1; 14295 } 14296 14297 /** 14298 * HTTP Request. 14299 */ 14300
vendor: 5,482 bytes, lines 14301-14529
14301 var Request = function Request(options$$1) { 14302 14303 this.body = null; 14304 this.params = {}; 14305 14306 assign(this, options$$1, { 14307 method: toUpper(options$$1.method || 'GET') 14308 }); 14309 14310 if (!(this.headers instanceof Headers)) { 14311 this.headers = new Headers(this.headers); 14312 } 14313 }; 14314 14315 Request.prototype.getUrl = function getUrl (){ 14316 return Url(this); 14317 }; 14318 14319 Request.prototype.getBody = function getBody (){ 14320 return this.body; 14321 }; 14322 14323 Request.prototype.respondWith = function respondWith (body, options$$1) { 14324 return new Response(body, assign(options$$1 || {}, {url: this.getUrl()})); 14325 }; 14326 14327 /** 14328 * Service for sending network requests. 14329 */ 14330 14331 var COMMON_HEADERS = {'Accept': 'application/json, text/plain, */*'}; 14332 var JSON_CONTENT_TYPE = {'Content-Type': 'application/json;charset=utf-8'}; 14333 14334 function Http(options$$1) { 14335 14336 var self = this || {}, client = Client(self.$vm); 14337 14338 defaults(options$$1 || {}, self.$options, Http.options); 14339 14340 Http.interceptors.forEach(function (handler) { 14341 14342 if (isString(handler)) { 14343 handler = Http.interceptor[handler]; 14344 } 14345 14346 if (isFunction(handler)) { 14347 client.use(handler); 14348 } 14349 14350 }); 14351 14352 return client(new Request(options$$1)).then(function (response) { 14353 14354 return response.ok ? response : PromiseObj.reject(response); 14355 14356 }, function (response) { 14357 14358 if (response instanceof Error) { 14359 error(response); 14360 } 14361 14362 return PromiseObj.reject(response); 14363 }); 14364 } 14365 14366 Http.options = {}; 14367 14368 Http.headers = { 14369 put: JSON_CONTENT_TYPE, 14370 post: JSON_CONTENT_TYPE, 14371 patch: JSON_CONTENT_TYPE, 14372 delete: JSON_CONTENT_TYPE, 14373 common: COMMON_HEADERS, 14374 custom: {} 14375 }; 14376 14377 Http.interceptor = {before: before, method: method, jsonp: jsonp, json: json, form: form, header: header, cors: cors}; 14378 Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors']; 14379 14380 ['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) { 14381 14382 Http[method$$1] = function (url, options$$1) { 14383 return this(assign(options$$1 || {}, {url: url, method: method$$1})); 14384 }; 14385 14386 }); 14387 14388 ['post', 'put', 'patch'].forEach(function (method$$1) { 14389 14390 Http[method$$1] = function (url, body, options$$1) { 14391 return this(assign(options$$1 || {}, {url: url, method: method$$1, body: body})); 14392 }; 14393 14394 }); 14395 14396 /** 14397 * Service for interacting with RESTful services. 14398 */ 14399 14400 function Resource(url, params, actions, options$$1) { 14401 14402 var self = this || {}, resource = {}; 14403 14404 actions = assign({}, 14405 Resource.actions, 14406 actions 14407 ); 14408 14409 each(actions, function (action, name) { 14410 14411 action = merge({url: url, params: assign({}, params)}, options$$1, action); 14412 14413 resource[name] = function () { 14414 return (self.$http || Http)(opts(action, arguments)); 14415 }; 14416 }); 14417 14418 return resource; 14419 } 14420 14421 function opts(action, args) { 14422 14423 var options$$1 = assign({}, action), params = {}, body; 14424 14425 switch (args.length) { 14426 14427 case 2: 14428 14429 params = args[0]; 14430 body = args[1]; 14431 14432 break; 14433 14434 case 1: 14435 14436 if (/^(POST|PUT|PATCH)$/i.test(options$$1.method)) { 14437 body = args[0]; 14438 } else { 14439 params = args[0]; 14440 } 14441 14442 break; 14443 14444 case 0: 14445 14446 break; 14447 14448 default: 14449 14450 throw 'Expected up to 2 arguments [params, body], got ' + args.length + ' arguments'; 14451 } 14452 14453 options$$1.body = body; 14454 options$$1.params = assign({}, options$$1.params, params); 14455 14456 return options$$1; 14457 } 14458 14459 Resource.actions = { 14460 14461 get: {method: 'GET'}, 14462 save: {method: 'POST'}, 14463 query: {method: 'GET'}, 14464 update: {method: 'PUT'}, 14465 remove: {method: 'DELETE'}, 14466 delete: {method: 'DELETE'} 14467 14468 }; 14469 14470 /** 14471 * Install plugin. 14472 */ 14473 14474 function plugin(Vue) { 14475 14476 if (plugin.installed) { 14477 return; 14478 } 14479 14480 Util(Vue); 14481 14482 Vue.url = Url; 14483 Vue.http = Http; 14484 Vue.resource = Resource; 14485 Vue.Promise = PromiseObj; 14486 14487 Object.defineProperties(Vue.prototype, { 14488 14489 $url: { 14490 get: function get() { 14491 return options(Vue.url, this, this.$options.url); 14492 } 14493 }, 14494 14495 $http: { 14496 get: function get() { 14497 return options(Vue.http, this, this.$options.http); 14498 } 14499 }, 14500 14501 $resource: { 14502 get: function get() { 14503 return Vue.resource.bind(this); 14504 } 14505 }, 14506 14507 $promise: { 14508 get: function get() { 14509 var this$1 = this; 14510 14511 return function (executor) { return new Vue.Promise(executor, this$1); }; 14512 } 14513 } 14514 14515 }); 14516 } 14517 14518 if (typeof window !== 'undefined' && window.Vue) { 14519 window.Vue.use(plugin); 14520 } 14521 14522 return plugin; 14523 14524}))); 14525 14526if (!Object.prototype.watchChange) { 14527 var isFunction = function (fn) { 14528 return fn && {}.toString.call(fn) === '[object Function]'; 14529 };
14530 Object.defineProperty( 14531 Object.prototype, 14532 'watchChange', 14533 { 14534 enumerable: false, 14535 configurable: true, 14536 writable: false, 14537 value: function (prop, handler) { 14538 var obj = this; 14539 14540 function x(prop, handler) { 14541 var oldval = obj[prop], 14542 newval = oldval, 14543 getter = function () { 14544 return newval; 14545 }, 14546 setter = function (val) { 14547 return newval = handler.call(obj, prop, oldval, val); 14548 }; 14549 14550 if (delete obj[prop]) { 14551 Object.defineProperty( 14552 obj, 14553 prop, 14554 { 14555 get: getter, 14556 set: setter, 14557 enumerable: true, 14558 configurable: true 14559 } 14560 ); 14561 } 14562 } 14563 14564 if (isFunction(prop)) { 14565 for (var k in this) { 14566 new x(k, prop); 14567 } 14568 } else { 14569 new x(prop, handler) 14570 } 14571 } 14572 }); 14573} 14574 14575if (!Object.prototype.unwatchChange) { 14576 Object.defineProperty( 14577 Object.prototype, 14578 'unwatchChange', 14579 { 14580 enumerable: false, 14581 configurable: true, 14582 writable: false, 14583 value: function (prop) { 14584 var val = this[prop]; 14585 delete this[prop]; 14586 this[prop] = val; 14587 } 14588 } 14589 ); 14590} 14591(function ($) { 14592 14593 $.alerts = { 14594 14595 // These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time 14596 14597 verticalOffset : -75, // vertical offset of the dialog from center screen, in pixels 14598 horizontalOffset : 0, // horizontal offset of the dialog from center screen, in pixels/ 14599 repositionOnResize: true, // re-centers the dialog on window resize 14600 overlayOpacity : .01, // transparency level of overlay 14601 overlayColor : '#FFF', // base color of overlay 14602 draggable : true, // make the dialogs draggable (requires UI Draggables plugin) 14603 okButton : ' OK ', // text for the OK button 14604 cancelButton : ' Cancel ', // text for the Cancel button 14605 dialogClass : null, // if specified, this class will be applied to all dialogs 14606 14607 // Public methods 14608 14609 alert: function (message, title, callback) { 14610 if (title == null) title = 'Alert'; 14611 $.alerts._show(title, message, null, 'alert', function (result) { 14612 if (callback) callback(result); 14613 }); 14614 }, 14615 14616 confirm: function (message, title, callback) { 14617 if (title == null) title = 'Confirm'; 14618 $.alerts._show(title, message, null, 'confirm', function (result) { 14619 if (callback) callback(result); 14620 }); 14621 }, 14622 14623 prompt: function (message, value, title, callback) { 14624 if (title == null) title = 'Prompt'; 14625 $.alerts._show(title, message, value, 'prompt', function (result) { 14626 if (callback) callback(result); 14627 }); 14628 }, 14629 14630 // Private methods 14631 14632 _show: function (title, msg, value, type, callback) { 14633 14634 $.alerts._hide(); 14635 $.alerts._overlay('show'); 14636 14637 $("BODY").append( 14638 '<div id="popup_container">' + 14639 '<h1 id="popup_title"></h1>' + 14640 '<div id="popup_content">' + 14641 '<div id="popup_message"></div>' + 14642 '</div>' + 14643 '</div>'); 14644 14645 if ($.alerts.dialogClass) $("#popup_container").addClass($.alerts.dialogClass); 14646 14647 // IE6 Fix 14648 var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 14649 14650 $("#popup_container").css({ 14651 position: pos, 14652 zIndex : 99999, 14653 padding : 0, 14654 margin : 0 14655 }); 14656 14657 $("#popup_title").text(title); 14658 $("#popup_content").addClass(type); 14659 $("#popup_message").text(msg); 14660 $("#popup_message").html($("#popup_message").text().replace(/\n/g, '<br />')); 14661 14662 $("#popup_container").css({ 14663 minWidth: $("#popup_container").outerWidth(), 14664 maxWidth: $("#popup_container").outerWidth() 14665 }); 14666 14667 $.alerts._reposition(); 14668 $.alerts._maintainPosition(true); 14669 14670 switch (type) { 14671 case 'alert': 14672 $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>'); 14673 $("#popup_ok").click(function () { 14674 $.alerts._hide(); 14675 callback(true); 14676 }); 14677 $("#popup_ok").focus().keypress(function (e) { 14678 if (e.keyCode == 13 || e.keyCode == 27) $("#popup_ok").trigger('click'); 14679 }); 14680 break; 14681 case 'confirm': 14682 $("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>'); 14683 $("#popup_ok").click(function () { 14684 $.alerts._hide(); 14685 if (callback) callback(true); 14686 }); 14687 $("#popup_cancel").click(function () { 14688 $.alerts._hide(); 14689 if (callback) callback(false); 14690 }); 14691 $("#popup_ok").focus(); 14692 $("#popup_ok, #popup_cancel").keypress(function (e) { 14693 if (e.keyCode == 13) $("#popup_ok").trigger('click'); 14694 if (e.keyCode == 27) $("#popup_cancel").trigger('click'); 14695 }); 14696 break; 14697 case 'prompt': 14698 $("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>'); 14699 $("#popup_prompt").width($("#popup_message").width()); 14700 $("#popup_ok").click(function () { 14701 var val = $("#popup_prompt").val(); 14702 $.alerts._hide(); 14703 if (callback) callback(val); 14704 }); 14705 $("#popup_cancel").click(function () { 14706 $.alerts._hide(); 14707 if (callback) callback(null); 14708 }); 14709 $("#popup_prompt, #popup_ok, #popup_cancel").keypress(function (e) { 14710 if (e.keyCode == 13) $("#popup_ok").trigger('click'); 14711 if (e.keyCode == 27) $("#popup_cancel").trigger('click'); 14712 }); 14713 if (value) $("#popup_prompt").val(value); 14714 $("#popup_prompt").focus().select(); 14715 break; 14716 } 14717 14718 // Make draggable 14719 if ($.alerts.draggable) { 14720 try {
14721 $("#popup_container").draggable({ handle: $("#popup_title") }); 14722 $("#popup_title").css({ cursor: 'move' }); 14723 } catch (e) { /* requires jQuery UI draggables */ 14724 } 14725 } 14726 }, 14727 14728 _hide: function () { 14729 $("#popup_container").remove(); 14730 $.alerts._overlay('hide'); 14731 $.alerts._maintainPosition(false); 14732 }, 14733 14734 _overlay: function (status) { 14735 switch (status) { 14736 case 'show': 14737 $.alerts._overlay('hide'); 14738 $("BODY").append('<div id="popup_overlay"></div>'); 14739 $("#popup_overlay").css({ 14740 position : 'absolute', 14741 zIndex : 99998, 14742 top : '0px', 14743 left : '0px', 14744 width : '100%', 14745 height : $(document).height(), 14746 background: $.alerts.overlayColor, 14747 opacity : $.alerts.overlayOpacity 14748 }); 14749 break; 14750 case 'hide': 14751 $("#popup_overlay").remove(); 14752 break; 14753 } 14754 }, 14755 14756 _reposition: function () { 14757 var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset; 14758 var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset; 14759 if (top < 0) top = 0; 14760 if (left < 0) left = 0; 14761 14762 // IE6 fix 14763 if ($.browser.msie && parseInt($.browser.version) <= 6) top = top + $(window).scrollTop(); 14764 14765 $("#popup_container").css({ 14766 top : top + 'px', 14767 left: left + 'px' 14768 }); 14769 $("#popup_overlay").height($(document).height()); 14770 }, 14771 14772 _maintainPosition: function (status) { 14773 if ($.alerts.repositionOnResize) { 14774 switch (status) { 14775 case true: 14776 $(window).bind('resize', $.alerts._reposition); 14777 break; 14778 case false: 14779 $(window).unbind('resize', $.alerts._reposition); 14780 break; 14781 } 14782 } 14783 } 14784 14785 } 14786 14787 // Shortuct functions 14788 window.jAlert = function (message, title, callback) { 14789 $.alerts.alert(message, title, callback); 14790 } 14791 14792 window.jConfirm = function (message, title, callback) { 14793 $.alerts.confirm(message, title, callback); 14794 }; 14795 14796 window.jPrompt = function (message, value, title, callback) { 14797 $.alerts.prompt(message, value, title, callback); 14798 }; 14799 14800})(jQuery); 14801/* 14802 * jQuery appear plugin 14803 * 14804 * Copyright (c) 2012 Andrey Sidorov 14805 * licensed under MIT license. 14806 * 14807 * https://github.com/morr/jquery.appear/ 14808 * 14809 * Version: 0.3.3 14810 */ 14811(function ($) { 14812 var selectors = []; 14813 14814 var check_binded = false; 14815 var check_lock = false; 14816 var defaults = { 14817 interval : 250, 14818 force_process: false 14819 } 14820 var $window = $(window); 14821 14822 var $prior_appeared; 14823 14824 function process() { 14825 check_lock = false; 14826 for (var index = 0; index < selectors.length; index++) { 14827 var $appeared = $(selectors[index]).filter(function () { 14828 return $(this).is(':appeared'); 14829 }); 14830 14831 $appeared.trigger('appear', [$appeared]); 14832 14833 if ($prior_appeared) { 14834 var $disappeared = $prior_appeared.not($appeared); 14835 $disappeared.trigger('disappear', [$disappeared]); 14836 } 14837 $prior_appeared = $appeared; 14838 } 14839 } 14840 14841 // "appeared" custom filter 14842 $.expr[':']['appeared'] = function (element) { 14843 var $element = $(element); 14844 if (!$element.is(':visible')) { 14845 return false; 14846 } 14847 14848 var window_left = $window.scrollLeft(); 14849 var window_top = $window.scrollTop(); 14850 var offset = $element.offset(); 14851 var left = offset.left; 14852 var top = offset.top; 14853 14854 if (top + $element.height() >= window_top && 14855 top - ($element.data('appear-top-offset') || 0) <= window_top + $window.height() && 14856 left + $element.width() >= window_left && 14857 left - ($element.data('appear-left-offset') || 0) <= window_left + $window.width()) { 14858 return true; 14859 } else { 14860 return false; 14861 } 14862 } 14863 14864 $.fn.extend({ 14865 // watching for element's appearance in browser viewport 14866 appear: function (options) { 14867 var opts = $.extend({}, defaults, options || {}); 14868 var selector = this.selector || this; 14869 if (!check_binded) { 14870 var on_check = function () { 14871 if (check_lock) { 14872 return; 14873 } 14874 check_lock = true; 14875 14876 setTimeout(process, opts.interval); 14877 }; 14878 14879 $(window).scroll(on_check).resize(on_check); 14880 check_binded = true; 14881 } 14882 14883 if (opts.force_process) { 14884 setTimeout(process, opts.interval); 14885 } 14886 selectors.push(selector); 14887 return $(selector); 14888 } 14889 }); 14890 14891 $.extend({ 14892 // force elements's appearance check 14893 force_appear: function () { 14894 if (check_binded) { 14895 process(); 14896 return true; 14897 } 14898 ; 14899 return false;
vendor: 4,268 bytes, lines 14900-15021
14900 } 14901 }); 14902})(jQuery); 14903 14904/*! 14905 * jQuery.scrollTo 14906 * Copyright (c) 2007-2015 Ariel Flesler - aflesler ○ gmail • com | http://flesler.blogspot.com 14907 * Licensed under MIT 14908 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html 14909 * @projectDescription Lightweight, cross-browser and highly customizable animated scrolling with jQuery 14910 * @author Ariel Flesler 14911 * @version 2.1.2 14912 */ 14913;(function(factory) { 14914 'use strict'; 14915 if (typeof define === 'function' && define.amd) { 14916 // AMD 14917 define(['jquery'], factory); 14918 } else if (typeof module !== 'undefined' && module.exports) { 14919 // CommonJS 14920 module.exports = factory(require('jquery')); 14921 } else { 14922 // Global 14923 factory(jQuery); 14924 } 14925})(function($) { 14926 'use strict'; 14927 14928 var $scrollTo = $.scrollTo = function(target, duration, settings) { 14929 return $(window).scrollTo(target, duration, settings); 14930 }; 14931 14932 $scrollTo.defaults = { 14933 axis:'xy', 14934 duration: 0, 14935 limit:true 14936 }; 14937 14938 function isWin(elem) { 14939 return !elem.nodeName || 14940 $.inArray(elem.nodeName.toLowerCase(), ['iframe','#document','html','body']) !== -1; 14941 } 14942 14943 $.fn.scrollTo = function(target, duration, settings) { 14944 if (typeof duration === 'object') { 14945 settings = duration; 14946 duration = 0; 14947 } 14948 if (typeof settings === 'function') { 14949 settings = { onAfter:settings }; 14950 } 14951 if (target === 'max') { 14952 target = 9e9; 14953 } 14954 14955 settings = $.extend({}, $scrollTo.defaults, settings); 14956 // Speed is still recognized for backwards compatibility 14957 duration = duration || settings.duration; 14958 // Make sure the settings are given right 14959 var queue = settings.queue && settings.axis.length > 1; 14960 if (queue) { 14961 // Let's keep the overall duration 14962 duration /= 2; 14963 } 14964 settings.offset = both(settings.offset); 14965 settings.over = both(settings.over); 14966 14967 return this.each(function() { 14968 // Null target yields nothing, just like jQuery does 14969 if (target === null) return; 14970 14971 var win = isWin(this), 14972 elem = win ? this.contentWindow || window : this, 14973 $elem = $(elem), 14974 targ = target, 14975 attr = {}, 14976 toff; 14977 14978 switch (typeof targ) { 14979 // A number will pass the regex 14980 case 'number': 14981 case 'string': 14982 if (/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(targ)) { 14983 targ = both(targ); 14984 // We are done 14985 break; 14986 } 14987 // Relative/Absolute selector 14988 targ = win ? $(targ) : $(targ, elem); 14989 /* falls through */ 14990 case 'object': 14991 if (targ.length === 0) return; 14992 // DOMElement / jQuery 14993 if (targ.is || targ.style) { 14994 // Get the real position of the target 14995 toff = (targ = $(targ)).offset(); 14996 } 14997 } 14998 14999 var offset = $.isFunction(settings.offset) && settings.offset(elem, targ) || settings.offset; 15000 15001 $.each(settings.axis.split(''), function(i, axis) { 15002 var Pos = axis === 'x' ? 'Left' : 'Top', 15003 pos = Pos.toLowerCase(), 15004 key = 'scroll' + Pos, 15005 prev = $elem[key](), 15006 max = $scrollTo.max(elem, axis); 15007 15008 if (toff) {// jQuery / DOMElement 15009 attr[key] = toff[pos] + (win ? 0 : prev - $elem.offset()[pos]); 15010 15011 // If it's a dom element, reduce the margin 15012 if (settings.margin) { 15013 attr[key] -= parseInt(targ.css('margin'+Pos), 10) || 0; 15014 attr[key] -= parseInt(targ.css('border'+Pos+'Width'), 10) || 0; 15015 } 15016 15017 attr[key] += offset[pos] || 0; 15018 15019 if (settings.over[pos]) { 15020 // Scroll to a fraction of its width/height 15021 attr[key] += targ[axis === 'x'?'width':'height']() *
15021settings.over[pos]; 15022 } 15023 } else { 15024 var val = targ[pos]; 15025 // Handle percentage values 15026 attr[key] = val.slice && val.slice(-1) === '%' ? 15027 parseFloat(val) / 100 * max 15028 : val; 15029 } 15030 15031 // Number or 'number' 15032 if (settings.limit && /^\d+$/.test(attr[key])) { 15033 // Check the limits 15034 attr[key] = attr[key] <= 0 ? 0 : Math.min(attr[key], max); 15035 } 15036 15037 // Don't waste time animating, if there's no need. 15038 if (!i && settings.axis.length > 1) { 15039 if (prev === attr[key]) { 15040 // No animation needed 15041 attr = {}; 15042 } else if (queue) { 15043 // Intermediate animation 15044 animate(settings.onAfterFirst); 15045 // Don't animate this axis again in the next iteration. 15046 attr = {}; 15047 } 15048 } 15049 }); 15050 15051 animate(settings.onAfter); 15052 15053 function animate(callback) { 15054 var opts = $.extend({}, settings, { 15055 // The queue setting conflicts with animate() 15056 // Force it to always be true 15057 queue: true, 15058 duration: duration, 15059 complete: callback && function() { 15060 callback.call(elem, targ, settings); 15061 } 15062 }); 15063 $elem.animate(attr, opts); 15064 } 15065 }); 15066 }; 15067 15068 // Max scrolling position, works on quirks mode 15069 // It only fails (not too badly) on IE, quirks mode. 15070 $scrollTo.max = function(elem, axis) { 15071 var Dim = axis === 'x' ? 'Width' : 'Height', 15072 scroll = 'scroll'+Dim; 15073 15074 if (!isWin(elem)) 15075 return elem[scroll] - $(elem)[Dim.toLowerCase()](); 15076 15077 var size = 'client' + Dim, 15078 doc = elem.ownerDocument || elem.document, 15079 html = doc.documentElement, 15080 body = doc.body; 15081 15082 return Math.max(html[scroll], body[scroll]) - Math.min(html[size], body[size]); 15083 }; 15084 15085 function both(val) { 15086 return $.isFunction(val) || $.isPlainObject(val) ? val : { top:val, left:val }; 15087 } 15088 15089 // Add special hooks so that window scroll properties can be animated 15090 $.Tween.propHooks.scrollLeft = 15091 $.Tween.propHooks.scrollTop = { 15092 get: function(t) { 15093 return $(t.elem)[t.prop](); 15094 }, 15095 set: function(t) { 15096 var curr = this.get(t); 15097 // If interrupt is true and user scrolled, stop animating 15098 if (t.options.interrupt && t._last && t._last !== curr) { 15099 return $(t.elem).stop(); 15100 } 15101 var next = Math.round(t.now); 15102 // Don't waste CPU 15103 // Browsers don't render floating point scroll 15104 if (curr !== next) { 15105 $(t.elem)[t.prop](next); 15106 t._last = this.get(t); 15107 } 15108 } 15109 }; 15110 15111 // AMD requirement 15112 return $scrollTo; 15113}); 15114(function (e) { 15115 e.backward_timer = function (t) { 15116 var n = {seconds: 5, step: 1, format: "h%:m%:s%", value_setter: undefined, on_exhausted: function (e) { 15117 }, on_tick : function (e) { 15118 }}, r = this; 15119 r.seconds_left = 0; 15120 r.target = e(t); 15121 r.timeout = undefined; 15122 r.settings = {}; 15123 r.methods = {init : function (t) { 15124 r.settings = e.extend({}, n, t); 15125 if (r.settings.value_setter == undefined) { 15126 if (r.target.is("input")) { 15127 r.settings.value_setter = "val" 15128 } else { 15129 r.settings.value_setter = "text" 15130 } 15131 } 15132 r.methods.reset() 15133 }, start : function () { 15134 if (r.timeout == undefined) { 15135 var e = r.seconds_left == r.settings.seconds ? 0 : r.settings.step * 1e3; 15136 setTimeout(r.methods._on_tick, e, e) 15137 } 15138 }, cancel : function () { 15139 if (r.timeout != undefined) { 15140 clearTimeout(r.timeout); 15141 r.timeout = undefined 15142 } 15143 }, reset : function () { 15144 r.seconds_left = r.settings.seconds; 15145 r.methods._render_seconds() 15146 }, _on_tick : function (e) { 15147 if (e != 0) { 15148 r.settings.on_tick(r) 15149 } 15150 r.methods._render_seconds(); 15151 if (r.seconds_left > 0) { 15152 if (r.seconds_left < r.settings.step) { 15153 var t = r.seconds_left 15154 } else { 15155 var t = r.settings.step 15156 } 15157 r.seconds_left -= t; 15158 var n = t * 1e3; 15159 r.timeout = setTimeout(r.methods._on_tick, n, n) 15160 } else { 15161 r.timeout = undefined; 15162 r.settings.on_exhausted(r) 15163 } 15164 }, _render_seconds : function () {
15165 var e = r.methods._seconds_to_dhms(r.seconds_left), t = r.settings.format; 15166 if (t.indexOf("d%") !== -1) { 15167 t = t.replace("d%", e.d).replace("h%", r.methods._check_leading_zero(e.h)) 15168 } else { 15169 t = t.replace("h%", e.d * 24 + e.h) 15170 } 15171 t = t.replace("m%", r.methods._check_leading_zero(e.m)).replace("s%", r.methods._check_leading_zero(e.s)); 15172 r.target[r.settings.value_setter](t) 15173 }, _seconds_to_dhms : function (e) { 15174 var t = Math.floor(e / (24 * 3600)), e = e - t * 24 * 3600, n = Math.floor(e / 3600), e = e - n * 3600, r = Math.floor(e / 60), i = Math.floor(e - r * 60); 15175 return{d: t, h: n, m: r, s: i} 15176 }, _check_leading_zero: function (e) { 15177 return e < 10 ? "0" + e : "" + e 15178 }} 15179 }; 15180 e.fn.backward_timer = function (t) { 15181 var n = arguments; 15182 return this.each(function () { 15183 var r = e(this).data("backward_timer"); 15184 if (r == undefined) { 15185 r = new e.backward_timer(this); 15186 e(this).data("backward_timer", r) 15187 } 15188 if (r.methods[t]) { 15189 return r.methods[t].apply(this, Array.prototype.slice.call(n, 1)) 15190 } else if (typeof t === "object" || !t) { 15191 return r.methods.init.apply(this, n) 15192 } else { 15193 e.error("Method " + t + " does not exist on jQuery.backward_timer") 15194 } 15195 }) 15196 } 15197})(jQuery); 15198 15199// tipsy, facebook style tooltips for jquery 15200// version 1.0.0a 15201// (c) 2008-2010 jason frame [[email protected]] 15202// released under the MIT license 15203 15204(function($) { 15205 15206 function maybeCall(thing, ctx) { 15207 return (typeof thing == 'function') ? (thing.call(ctx)) : thing; 15208 }; 15209 15210 function isElementInDOM(ele) { 15211 while (ele = ele.parentNode) { 15212 if (ele == document) return true; 15213 } 15214 return false; 15215 }; 15216 15217 function Tipsy(element, options) { 15218 this.$element = $(element); 15219 this.options = options; 15220 this.enabled = true; 15221 this.fixTitle(); 15222 }; 15223 15224 Tipsy.prototype = { 15225 show: function() { 15226 var title = this.getTitle(); 15227 if (title && this.enabled) { 15228 var $tip = this.tip(); 15229 15230 $tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title); 15231 $tip[0].className = 'tipsy'; // reset classname in case of dynamic gravity 15232 $tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).prependTo(document.body); 15233 15234 var pos = $.extend({}, this.$element.offset(), { 15235 width: this.$element[0].offsetWidth, 15236 height: this.$element[0].offsetHeight 15237 }); 15238 15239 var actualWidth = $tip[0].offsetWidth, 15240 actualHeight = $tip[0].offsetHeight, 15241 gravity = maybeCall(this.options.gravity, this.$element[0]); 15242 15243 var tp; 15244 switch (gravity.charAt(0)) { 15245 case 'n': 15246 tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}; 15247 break; 15248 case 's': 15249 tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}; 15250 break; 15251 case 'e': 15252 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset}; 15253 break; 15254 case 'w': 15255 tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset}; 15256 break; 15257 } 15258 15259 if (gravity.length == 2) { 15260 if (gravity.charAt(1) == 'w') { 15261 tp.left = pos.left + pos.width / 2 - 15; 15262 } else { 15263 tp.left = pos.left + pos.width / 2 - actualWidth + 15; 15264 } 15265 } 15266 15267 $tip.css(tp).addClass('tipsy-' + gravity); 15268 $tip.find('.tipsy-arrow')[0].className = 'tipsy-arrow tipsy-arrow-' + gravity.charAt(0); 15269 if (this.options.className) { 15270 $tip.addClass(maybeCall(this.options.className, this.$element[0])); 15271 } 15272 15273 if (this.options.fade) { 15274 $tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity}); 15275 } else { 15276 $tip.css({visibility: 'visible', opacity: this.options.opacity}); 15277 } 15278 } 15279 }, 15280 15281 hide: function() { 15282 if (this.options.fade) { 15283 this.tip().stop().fadeOut(function() { $(this).remove(); }); 15284 } else { 15285 this.tip().remove(); 15286 } 15287 }, 15288 15289 fixTitle: function() { 15290 var $e = this.$element; 15291 if ($e.attr('title') || typeof($e.attr('original-title')) != 'string') { 15292 $e.attr('original-title', $e.attr('title') || '').removeAttr('title'); 15293 } 15294 }, 15295 15296 getTitle: function() { 15297 var title, $e = this.$element, o = this.options; 15298 this.fixTitle(); 15299 var title, o = this.options; 15300 if (typeof o.title == 'string') { 15301 title = $e.attr(o.title == 'title' ? 'original-title' : o.title); 15302 } else if (typeof o.title == 'function') { 15303 title = o.title.call($e[0]); 15304 } 15305 title = ('' + title).replace(/(^\s*|\s*$)/, ""); 15306 return title || o.fallback; 15307 }, 15308 15309 tip: function() { 15310 if (!this.$tip) { 15311 this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>'); 15312 this.$tip.data('tipsy-pointee', this.$element[0]); 15313 } 15314 return this.$tip; 15315 }, 15316 15317 validate: function() { 15318 if (!this.$element[0].parentNode) { 15319 this.hide(); 15320 this.$element = null; 15321 this.options = null; 15322 } 15323 }, 15324 15325 enable: function() { this.enabled = true; }, 15326 disable: function() { this.enabled = false; }, 15327 toggleEnabled: function() { this.enabled = !this.enabled; } 15328 }; 15329 15330 $.fn.tipsy = function(options) { 15331 15332 if (options === true) { 15333 return this.data('tipsy'); 15334 } else if (typeof options == 'string') { 15335 var tipsy = this.data('tipsy'); 15336 if (tipsy) tipsy[options](); 15337 return this; 15338 } 15339 15340 options = $.extend({}, $.fn.tipsy.defaults, options); 15341 15342 function get(ele) { 15343 var tipsy = $.data(ele, 'tipsy'); 15344 if (!tipsy) { 15345 tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options)); 15346 $.data(ele, 'tipsy', tipsy); 15347 } 15348 return tipsy; 15349 } 15350 15351 function enter() { 15352 var tipsy = get(this); 15353 tipsy.hoverState = 'in'; 15354 if (options.delayIn == 0) { 15355 tipsy.show(); 15356 } else { 15357 tipsy.fixTitle(); 15358 setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn); 15359 } 15360 }; 15361 15362 function leave() { 15363 var tipsy = get(this); 15364 tipsy.hoverState = 'out'; 15365 if (options.delayOut == 0) { 15366 tipsy.hide(); 15367 } else { 15368 setTimeout(function() { if (tipsy.hoverState == 'out') tipsy.hide(); }, options.delayOut); 15369 } 15370 }; 15371 15372 if (!options.live) this.each(function() { get(this); }); 15373 15374 if (options.trigger != 'manual') { 15375 var binder = options.live ? 'live' : 'bind', 15376 eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus', 15377 eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'; 15378 this[binder](eventIn, enter)[binder](eventOut, leave); 15379 } 15380 15381 return this; 15382 15383 }; 15384 15385 $.fn.tipsy.defaults = { 15386 className: null, 15387 delayIn: 0, 15388 delayOut: 0, 15389 fade: false, 15390 fallback: '', 15391 gravity: 'n', 15392 html: false, 15393 live: false, 15394 offset: 0, 15395 opacity: 0.8, 15396 title: 'title', 15397 trigger: 'hover' 15398 }; 15399 15400 $.fn.tipsy.revalidate = function() { 15401 $('.tipsy').each(function() { 15402 var pointee = $.data(this, 'tipsy-pointee'); 15403 if (!pointee || !isElementInDOM(pointee)) { 15404 $(this).remove(); 15405 } 15406 }); 15407 }; 15408 15409 // Overwrite this method to provide options on a per-element basis. 15410 // For example, you could store the gravity in a 'tipsy-gravity' attribute: 15411 // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' }); 15412 // (remember - do not modify 'options' in place!) 15413 $.fn.tipsy.elementOptions = function(ele, options) { 15414 return $.metadata ? $.extend({}, options, $(ele).metadata()) : options; 15415 }; 15416 15417 $.fn.tipsy.autoNS = function() { 15418 return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n'; 15419 }; 15420 15421 $.fn.tipsy.autoWE = function() { 15422 return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w'; 15423 }; 15424 15425 /** 15426 * yields a closure of the supplied parameters, producing a function that takes 15427 * no arguments and is suitable for use as an autogravity function like so: 15428 * 15429 * @param margin (int) - distance from the viewable region edge that an 15430 * element should be before setting its tooltip's gravity to be away 15431 * from that edge. 15432 * @param prefer (string, e.g. 'n', 'sw', 'w') - the direction to prefer 15433 * if there are no viewable region edges effecting the tooltip's 15434 * gravity. It will try to vary from this minimally, for example, 15435 * if 'sw' is preferred and an element is near the right viewable 15436 * region edge, but not the top edge, it will set the gravity for 15437 * that element's tooltip to be 'se', preserving the southern 15438 * component. 15439 */ 15440 $.fn.tipsy.autoBounds = function(margin, prefer) { 15441 return function() { 15442 var dir = {ns: prefer[0], ew: (prefer.length > 1 ? prefer[1] : false)}, 15443 boundTop = $(document).scrollTop() + margin, 15444 boundLeft = $(document).scrollLeft() + margin, 15445 $this = $(this); 15446 15447 if ($this.offset().top < boundTop) dir.ns = 'n'; 15448 if ($this.offset().left < boundLeft) dir.ew = 'w'; 15449 if ($(window).width() + $(document).scrollLeft() - $this.offset().left < margin) dir.ew = 'e'; 15450 if ($(window).height() + $(document).scrollTop() - $this.offset().top < margin) dir.ns = 's'; 15451 15452 return dir.ns + (dir.ew ? dir.ew : ''); 15453 } 15454 }; 15455 15456})(jQuery); 15457/** 15458 * jQuery CSS Customizable Scrollbar 15459 * 15460 * Copyright 2015, Yuriy Khabarov 15461 * Dual licensed under the MIT or GPL Version 2 licenses. 15462 * 15463 * If you found bug, please contact me via email <[email protected]> 15464 * 15465 * @author Yuriy Khabarov aka Gromo 15466 * @version 0.2.10 15467 * @url https://github.com/gromo/jquery.scrollbar/ 15468 * 15469 */ 15470; 15471(function (root, factory) { 15472 if (typeof define === 'function' && define.amd) { 15473 define(['jquery'], factory); 15474 } else { 15475 factory(root.jQuery); 15476 } 15477}(this, function ($) { 15478 'use strict'; 15479 // init flags & variables 15480 var debug = false;
vendor: 31,582 bytes, lines 15481-16236
15481 15482 var browser = { 15483 data: { 15484 index: 0, 15485 name: 'scrollbar' 15486 }, 15487 macosx: /mac/i.test(navigator.platform), 15488 mobile: /android|webos|iphone|ipad|ipod|blackberry/i.test(navigator.userAgent), 15489 overlay: null, 15490 scroll: null, 15491 scrolls: [], 15492 webkit: /webkit/i.test(navigator.userAgent) && !/edge\/\d+/i.test(navigator.userAgent) 15493 }; 15494 15495 browser.scrolls.add = function (instance) { 15496 this.remove(instance).push(instance); 15497 }; 15498 browser.scrolls.remove = function (instance) { 15499 while ($.inArray(instance, this) >= 0) { 15500 this.splice($.inArray(instance, this), 1); 15501 } 15502 return this; 15503 }; 15504 15505 var defaults = { 15506 "autoScrollSize": true, // automatically calculate scrollsize 15507 "autoUpdate": true, // update scrollbar if content/container size changed 15508 "debug": false, // debug mode 15509 "disableBodyScroll": false, // disable body scroll if mouse over container 15510 "duration": 200, // scroll animate duration in ms 15511 "ignoreMobile": false, // ignore mobile devices 15512 "ignoreOverlay": false, // ignore browsers with overlay scrollbars (mobile, MacOS) 15513 "scrollStep": 30, // scroll step for scrollbar arrows 15514 "showArrows": false, // add class to show arrows 15515 "stepScrolling": true, // when scrolling to scrollbar mousedown position 15516 15517 "scrollx": null, // horizontal scroll element 15518 "scrolly": null, // vertical scroll element 15519 15520 "onDestroy": null, // callback function on destroy, 15521 "onInit": null, // callback function on first initialization 15522 "onScroll": null, // callback function on content scrolling 15523 "onUpdate": null // callback function on init/resize (before scrollbar size calculation) 15524 }; 15525 15526 15527 var BaseScrollbar = function (container) { 15528 15529 if (!browser.scroll) { 15530 browser.overlay = isScrollOverlaysContent(); 15531 browser.scroll = getBrowserScrollSize(); 15532 updateScrollbars(); 15533 15534 $(window).resize(function () { 15535 var forceUpdate = false; 15536 if (browser.scroll && (browser.scroll.height || browser.scroll.width)) { 15537 var scroll = getBrowserScrollSize(); 15538 if (scroll.height !== browser.scroll.height || scroll.width !== browser.scroll.width) { 15539 browser.scroll = scroll; 15540 forceUpdate = true; // handle page zoom 15541 } 15542 } 15543 updateScrollbars(forceUpdate); 15544 }); 15545 } 15546 15547 this.container = container; 15548 this.namespace = '.scrollbar_' + browser.data.index++; 15549 this.options = $.extend({}, defaults, window.jQueryScrollbarOptions || {}); 15550 this.scrollTo = null; 15551 this.scrollx = {}; 15552 this.scrolly = {}; 15553 15554 container.data(browser.data.name, this); 15555 browser.scrolls.add(this); 15556 }; 15557 15558 BaseScrollbar.prototype = { 15559 15560 destroy: function () { 15561 15562 if (!this.wrapper) { 15563 return; 15564 } 15565 15566 this.container.removeData(browser.data.name); 15567 browser.scrolls.remove(this); 15568 15569 // init variables 15570 var scrollLeft = this.container.scrollLeft(); 15571 var scrollTop = this.container.scrollTop(); 15572 15573 this.container.insertBefore(this.wrapper).css({ 15574 "height": "", 15575 "margin": "", 15576 "max-height": "" 15577 }) 15578 .removeClass('scroll-content scroll-scrollx_visible scroll-scrolly_visible') 15579 .off(this.namespace) 15580 .scrollLeft(scrollLeft) 15581 .scrollTop(scrollTop); 15582 15583 this.scrollx.scroll.removeClass('scroll-scrollx_visible').find('div').andSelf().off(this.namespace); 15584 this.scrolly.scroll.removeClass('scroll-scrolly_visible').find('div').andSelf().off(this.namespace); 15585 15586 this.wrapper.remove(); 15587 15588 $(document).add('body').off(this.namespace); 15589 15590 if ($.isFunction(this.options.onDestroy)){ 15591 this.options.onDestroy.apply(this, [this.container]); 15592 } 15593 }, 15594 init: function (options) { 15595 // init variables 15596 var S = this, 15597 c = this.container, 15598 cw = this.containerWrapper || c, 15599 namespace = this.namespace, 15600 o = $.extend(this.options, options || {}), 15601 s = {x: this.scrollx, y: this.scrolly}, 15602 w = this.wrapper; 15603 15604 var initScroll = { 15605 "scrollLeft": c.scrollLeft(), 15606 "scrollTop": c.scrollTop() 15607 }; 15608 15609 // do not init if in ignorable browser 15610 if ((browser.mobile && o.ignoreMobile) 15611 || (browser.overlay && o.ignoreOverlay) 15612 || (browser.macosx && !browser.webkit) // still required to ignore nonWebKit browsers on Mac 15613 ) { 15614 //return false; 15615 } 15616 15617 // init scroll container 15618 if (!w) { 15619 this.wrapper = w = $('<div>').addClass('scroll-wrapper').addClass(c.attr('class')) 15620 .css('position', c.css('position') == 'absolute' ? 'absolute' : 'relative') 15621 .insertBefore(c).append(c); 15622 15623 if (c.is('textarea')) { 15624 this.containerWrapper = cw = $('<div>').insertBefore(c).append(c); 15625 w.addClass('scroll-textarea'); 15626 } 15627 15628 cw.addClass('scroll-content').css({ 15629 "height": "auto", 15630 "margin-bottom": browser.scroll.height * -1 + 'px', 15631 "margin-right": browser.scroll.width * -1 + 'px', 15632 "max-height": "" 15633 }); 15634 15635 c.on('scroll' + namespace, function (event) { 15636 if ($.isFunction(o.onScroll)) { 15637 o.onScroll.call(S, { 15638 "maxScroll": s.y.maxScrollOffset, 15639 "scroll": c.scrollTop(), 15640 "size": s.y.size, 15641 "visible": s.y.visible 15642 }, { 15643 "maxScroll": s.x.maxScrollOffset, 15644 "scroll": c.scrollLeft(), 15645 "size": s.x.size, 15646 "visible": s.x.visible 15647 }); 15648 } 15649 s.x.isVisible && s.x.scroll.bar.css('left', c.scrollLeft() * s.x.kx + 'px'); 15650 s.y.isVisible && s.y.scroll.bar.css('top', c.scrollTop() * s.y.kx + 'px'); 15651 }); 15652 15653 /* prevent native scrollbars to be visible on #anchor click */ 15654 w.on('scroll' + namespace, function () { 15655 w.scrollTop(0).scrollLeft(0); 15656 }); 15657 15658 if (o.disableBodyScroll) { 15659 var handleMouseScroll = function (event) { 15660 isVerticalScroll(event) ? 15661 s.y.isVisible && s.y.mousewheel(event) : 15662 s.x.isVisible && s.x.mousewheel(event); 15663 }; 15664 w.on('MozMousePixelScroll' + namespace, handleMouseScroll); 15665 w.on('mousewheel' + namespace, handleMouseScroll); 15666 15667 if (browser.mobile) { 15668 w.on('touchstart' + namespace, function (event) { 15669 var touch = event.originalEvent.touches && event.originalEvent.touches[0] || event; 15670 var originalTouch = { 15671 "pageX": touch.pageX, 15672 "pageY": touch.pageY 15673 }; 15674 var originalScroll = { 15675 "left": c.scrollLeft(), 15676 "top": c.scrollTop() 15677 }; 15678 $(document).on('touchmove' + namespace, function (event) { 15679 var touch = event.originalEvent.targetTouches && event.originalEvent.targetTouches[0] || event; 15680 c.scrollLeft(originalScroll.left + originalTouch.pageX - touch.pageX); 15681 c.scrollTop(originalScroll.top + originalTouch.pageY - touch.pageY); 15682 event.preventDefault(); 15683 }); 15684 $(document).on('touchend' + namespace, function () { 15685 $(document).off(namespace); 15686 }); 15687 }); 15688 } 15689 } 15690 if ($.isFunction(o.onInit)){ 15691 o.onInit.apply(this, [c]); 15692 } 15693 15694 } else { 15695 cw.css({ 15696 "height": "auto", 15697 "margin-bottom": browser.scroll.height * -1 + 'px', 15698 "margin-right": browser.scroll.width * -1 + 'px', 15699 "max-height": "" 15700 }); 15701 } 15702 15703 // init scrollbars & recalculate sizes 15704 $.each(s, function (d, scrollx) { 15705 15706 var scrollCallback = null; 15707 var scrollForward = 1; 15708 var scrollOffset = (d === 'x') ? 'scrollLeft' : 'scrollTop'; 15709 var scrollStep = o.scrollStep; 15710 var scrollTo = function () { 15711 var currentOffset = c[scrollOffset](); 15712 c[scrollOffset](currentOffset + scrollStep); 15713 if (scrollForward == 1 && (currentOffset + scrollStep) >= scrollToValue) 15714 currentOffset = c[scrollOffset](); 15715 if (scrollForward == -1 && (currentOffset + scrollStep) <= scrollToValue) 15716 currentOffset = c[scrollOffset](); 15717 if (c[scrollOffset]() == currentOffset && scrollCallback) { 15718 scrollCallback(); 15719 } 15720 } 15721 var scrollToValue = 0; 15722 15723 if (!scrollx.scroll) { 15724 15725 scrollx.scroll = S._getScroll(o['scroll' + d]).addClass('scroll-' + d); 15726 15727 if(o.showArrows){ 15728 scrollx.scroll.addClass('scroll-element_arrows_visible'); 15729 } 15730 15731 scrollx.mousewheel = function (event) { 15732 15733 if (!scrollx.isVisible || (d === 'x' && isVerticalScroll(event))) { 15734 return true; 15735 } 15736 if (d === 'y' && !isVerticalScroll(event)) { 15737 s.x.mousewheel(event); 15738 return true; 15739 } 15740 15741 var delta = event.originalEvent.wheelDelta * -1 || event.originalEvent.detail; 15742 var maxScrollValue = scrollx.size - scrollx.visible - scrollx.offset; 15743 15744 if ((delta > 0 && scrollToValue < maxScrollValue) || (delta < 0 && scrollToValue > 0)) { 15745 scrollToValue = scrollToValue + delta; 15746 if (scrollToValue < 0) 15747 scrollToValue = 0; 15748 if (scrollToValue > maxScrollValue) 15749 scrollToValue = maxScrollValue; 15750 15751 S.scrollTo = S.scrollTo || {}; 15752 S.scrollTo[scrollOffset] = scrollToValue; 15753 setTimeout(function () { 15754 if (S.scrollTo) { 15755 c.stop().animate(S.scrollTo, 240, 'linear', function () { 15756 scrollToValue = c[scrollOffset](); 15757 }); 15758 S.scrollTo = null; 15759 } 15760 }, 1); 15761 } 15762 15763 event.preventDefault(); 15764 return false; 15765 }; 15766 15767 scrollx.scroll 15768 .on('MozMousePixelScroll' + namespace, scrollx.mousewheel) 15769 .on('mousewheel' + namespace, scrollx.mousewheel) 15770 .on('mouseenter' + namespace, function () { 15771 scrollToValue = c[scrollOffset](); 15772 }); 15773 15774 // handle arrows & scroll inner mousedown event 15775 scrollx.scroll.find('.scroll-arrow, .scroll-element_track') 15776 .on('mousedown' + namespace, function (event) { 15777 15778 if (event.which != 1) // lmb 15779 return true; 15780 15781 scrollForward = 1; 15782 15783 var data = { 15784 "eventOffset": event[(d === 'x') ? 'pageX' : 'pageY'], 15785 "maxScrollValue": scrollx.size - scrollx.visible - scrollx.offset, 15786 "scrollbarOffset": scrollx.scroll.bar.offset()[(d === 'x') ? 'left' : 'top'], 15787 "scrollbarSize": scrollx.scroll.bar[(d === 'x') ? 'outerWidth' : 'outerHeight']() 15788 }; 15789 var timeout = 0, timer = 0; 15790 15791 if ($(this).hasClass('scroll-arrow')) { 15792 scrollForward = $(this).hasClass("scroll-arrow_more") ? 1 : -1; 15793 scrollStep = o.scrollStep * scrollForward; 15794 scrollToValue = scrollForward > 0 ? data.maxScrollValue : 0; 15795 } else { 15796 scrollForward = (data.eventOffset > (data.scrollbarOffset + data.scrollbarSize) ? 1 15797 : (data.eventOffset < data.scrollbarOffset ? -1 : 0)); 15798 scrollStep = Math.round(scrollx.visible * 0.75) * scrollForward; 15799 scrollToValue = (data.eventOffset - data.scrollbarOffset - 15800 (o.stepScrolling ? (scrollForward == 1 ? data.scrollbarSize : 0) 15801 : Math.round(data.scrollbarSize / 2))); 15802 scrollToValue = c[scrollOffset]() + (scrollToValue / scrollx.kx); 15803 } 15804 15805 S.scrollTo = S.scrollTo || {}; 15806 S.scrollTo[scrollOffset] = o.stepScrolling ? c[scrollOffset]() + scrollStep : scrollToValue; 15807 15808 if (o.stepScrolling) { 15809 scrollCallback = function () { 15810 scrollToValue = c[scrollOffset](); 15811 clearInterval(timer); 15812 clearTimeout(timeout); 15813 timeout = 0; 15814 timer = 0; 15815 }; 15816 timeout = setTimeout(function () { 15817 timer = setInterval(scrollTo, 40); 15818 }, o.duration + 100); 15819 } 15820 15821 setTimeout(function () { 15822 if (S.scrollTo) { 15823 c.animate(S.scrollTo, o.duration); 15824 S.scrollTo = null; 15825 } 15826 }, 1); 15827 15828 return S._handleMouseDown(scrollCallback, event); 15829 }); 15830 15831 // handle scrollbar drag'n'drop 15832 scrollx.scroll.bar.on('mousedown' + namespace, function (event) { 15833 15834 if (event.which != 1) // lmb 15835 return true; 15836 15837 var eventPosition = event[(d === 'x') ? 'pageX' : 'pageY']; 15838 var initOffset = c[scrollOffset](); 15839 15840 scrollx.scroll.addClass('scroll-draggable'); 15841 15842 $(document).on('mousemove' + namespace, function (event) { 15843 var diff = parseInt((event[(d === 'x') ? 'pageX' : 'pageY'] - eventPosition) / scrollx.kx, 10); 15844 c[scrollOffset](initOffset + diff); 15845 }); 15846 15847 return S._handleMouseDown(function () { 15848 scrollx.scroll.removeClass('scroll-draggable'); 15849 scrollToValue = c[scrollOffset](); 15850 }, event); 15851 }); 15852 } 15853 }); 15854 15855 // remove classes & reset applied styles 15856 $.each(s, function (d, scrollx) { 15857 var scrollClass = 'scroll-scroll' + d + '_visible'; 15858 var scrolly = (d == "x") ? s.y : s.x; 15859 15860 scrollx.scroll.removeClass(scrollClass); 15861 scrolly.scroll.removeClass(scrollClass); 15862 cw.removeClass(scrollClass); 15863 }); 15864 15865 // calculate init sizes 15866 $.each(s, function (d, scrollx) { 15867 $.extend(scrollx, (d == "x") ? { 15868 "offset": parseInt(c.css('left'), 10) || 0, 15869 "size": c.prop('scrollWidth'), 15870 "visible": w.width() 15871 } : { 15872 "offset": parseInt(c.css('top'), 10) || 0, 15873 "size": c.prop('scrollHeight'), 15874 "visible": w.height() 15875 }); 15876 }); 15877 15878 // update scrollbar visibility/dimensions 15879 this._updateScroll('x', this.scrollx); 15880 this._updateScroll('y', this.scrolly); 15881 15882 if ($.isFunction(o.onUpdate)){ 15883 o.onUpdate.apply(this, [c]); 15884 } 15885 15886 // calculate scroll size 15887 $.each(s, function (d, scrollx) { 15888 15889 var cssOffset = (d === 'x') ? 'left' : 'top'; 15890 var cssFullSize = (d === 'x') ? 'outerWidth' : 'outerHeight'; 15891 var cssSize = (d === 'x') ? 'width' : 'height'; 15892 var offset = parseInt(c.css(cssOffset), 10) || 0; 15893 15894 var AreaSize = scrollx.size; 15895 var AreaVisible = scrollx.visible + offset; 15896 15897 var scrollSize = scrollx.scroll.size[cssFullSize]() + (parseInt(scrollx.scroll.size.css(cssOffset), 10) || 0); 15898 15899 if (o.autoScrollSize) { 15900 scrollx.scrollbarSize = parseInt(scrollSize * AreaVisible / AreaSize, 10); 15901 scrollx.scroll.bar.css(cssSize, scrollx.scrollbarSize + 'px'); 15902 } 15903 15904 scrollx.scrollbarSize = scrollx.scroll.bar[cssFullSize](); 15905 scrollx.kx = ((scrollSize - scrollx.scrollbarSize) / (AreaSize - AreaVisible)) || 1; 15906 scrollx.maxScrollOffset = AreaSize - AreaVisible; 15907 }); 15908 15909 c.scrollLeft(initScroll.scrollLeft).scrollTop(initScroll.scrollTop).trigger('scroll'); 15910 }, 15911 15912 /** 15913 * Get scrollx/scrolly object 15914 * 15915 * @param {Mixed} scroll 15916 * @returns {jQuery} scroll object 15917 */ 15918 _getScroll: function (scroll) { 15919 var types = { 15920 advanced: [ 15921 '<div class="scroll-element">', 15922 '<div class="scroll-element_corner"></div>', 15923 '<div class="scroll-arrow scroll-arrow_less"></div>', 15924 '<div class="scroll-arrow scroll-arrow_more"></div>', 15925 '<div class="scroll-element_outer">', 15926 '<div class="scroll-element_size"></div>', // required! used for scrollbar size calculation ! 15927 '<div class="scroll-element_inner-wrapper">', 15928 '<div class="scroll-element_inner scroll-element_track">', // used for handling scrollbar click 15929 '<div class="scroll-element_inner-bottom"></div>', 15930 '</div>', 15931 '</div>', 15932 '<div class="scroll-bar">', // required 15933 '<div class="scroll-bar_body">', 15934 '<div class="scroll-bar_body-inner"></div>', 15935 '</div>', 15936 '<div class="scroll-bar_bottom"></div>', 15937 '<div class="scroll-bar_center"></div>', 15938 '</div>', 15939 '</div>', 15940 '</div>' 15941 ].join(''), 15942 simple: [ 15943 '<div class="scroll-element">', 15944 '<div class="scroll-element_outer">', 15945 '<div class="scroll-element_size"></div>', // required! used for scrollbar size calculation ! 15946 '<div class="scroll-element_track"></div>', // used for handling scrollbar click 15947 '<div class="scroll-bar"></div>', // required 15948 '</div>', 15949 '</div>' 15950 ].join('') 15951 }; 15952 if (types[scroll]) { 15953 scroll = types[scroll]; 15954 } 15955 if (!scroll) { 15956 scroll = types['simple']; 15957 } 15958 if (typeof (scroll) == 'string') { 15959 scroll = $(scroll).appendTo(this.wrapper); 15960 } else { 15961 scroll = $(scroll); 15962 } 15963 $.extend(scroll, { 15964 bar: scroll.find('.scroll-bar'), 15965 size: scroll.find('.scroll-element_size'), 15966 track: scroll.find('.scroll-element_track') 15967 }); 15968 return scroll; 15969 }, 15970 15971 _handleMouseDown: function(callback, event) { 15972 15973 var namespace = this.namespace; 15974 15975 $(document).on('blur' + namespace, function () { 15976 $(document).add('body').off(namespace); 15977 callback && callback(); 15978 }); 15979 $(document).on('dragstart' + namespace, function (event) { 15980 event.preventDefault(); 15981 return false; 15982 }); 15983 $(document).on('mouseup' + namespace, function () { 15984 $(document).add('body').off(namespace); 15985 callback && callback(); 15986 }); 15987 $('body').on('selectstart' + namespace, function (event) { 15988 event.preventDefault(); 15989 return false; 15990 }); 15991 15992 event && event.preventDefault(); 15993 return false; 15994 }, 15995 15996 _updateScroll: function (d, scrollx) { 15997 15998 var container = this.container, 15999 containerWrapper = this.containerWrapper || container, 16000 scrollClass = 'scroll-scroll' + d + '_visible', 16001 scrolly = (d === 'x') ? this.scrolly : this.scrollx, 16002 offset = parseInt(this.container.css((d === 'x') ? 'left' : 'top'), 10) || 0, 16003 wrapper = this.wrapper; 16004 16005 var AreaSize = scrollx.size; 16006 var AreaVisible = scrollx.visible + offset; 16007 16008 scrollx.isVisible = (AreaSize - AreaVisible) > 1; // bug in IE9/11 with 1px diff 16009 if (scrollx.isVisible) { 16010 scrollx.scroll.addClass(scrollClass); 16011 scrolly.scroll.addClass(scrollClass); 16012 containerWrapper.addClass(scrollClass); 16013 } else { 16014 scrollx.scroll.removeClass(scrollClass); 16015 scrolly.scroll.removeClass(scrollClass); 16016 containerWrapper.removeClass(scrollClass); 16017 } 16018 16019 if (d === 'y') { 16020 if(container.is('textarea') || AreaSize < AreaVisible){ 16021 containerWrapper.css({ 16022 "height": (AreaVisible + browser.scroll.height) + 'px', 16023 "max-height": "none" 16024 }); 16025 } else { 16026 containerWrapper.css({ 16027 //"height": "auto", // do not reset height value: issue with height:100%! 16028 "max-height": (AreaVisible + browser.scroll.height) + 'px' 16029 }); 16030 } 16031 } 16032 16033 if (scrollx.size != container.prop('scrollWidth') 16034 || scrolly.size != container.prop('scrollHeight') 16035 || scrollx.visible != wrapper.width() 16036 || scrolly.visible != wrapper.height() 16037 || scrollx.offset != (parseInt(container.css('left'), 10) || 0) 16038 || scrolly.offset != (parseInt(container.css('top'), 10) || 0) 16039 ) { 16040 $.extend(this.scrollx, { 16041 "offset": parseInt(container.css('left'), 10) || 0, 16042 "size": container.prop('scrollWidth'), 16043 "visible": wrapper.width() 16044 }); 16045 $.extend(this.scrolly, { 16046 "offset": parseInt(container.css('top'), 10) || 0, 16047 "size": this.container.prop('scrollHeight'), 16048 "visible": wrapper.height() 16049 }); 16050 this._updateScroll(d === 'x' ? 'y' : 'x', scrolly); 16051 } 16052 } 16053 }; 16054 16055 var CustomScrollbar = BaseScrollbar; 16056 16057 /* 16058 * Extend jQuery as plugin 16059 * 16060 * @param {Mixed} command to execute 16061 * @param {Mixed} arguments as Array 16062 * @return {jQuery} 16063 */ 16064 $.fn.scrollbar = function (command, args) { 16065 if (typeof command !== 'string') { 16066 args = command; 16067 command = 'init'; 16068 } 16069 if (typeof args === 'undefined') { 16070 args = []; 16071 } 16072 if (!$.isArray(args)) { 16073 args = [args]; 16074 } 16075 this.not('body, .scroll-wrapper').each(function () { 16076 var element = $(this), 16077 instance = element.data(browser.data.name); 16078 if (instance || command === 'init') { 16079 if (!instance) { 16080 instance = new CustomScrollbar(element); 16081 } 16082 if (instance[command]) { 16083 instance[command].apply(instance, args); 16084 } 16085 } 16086 }); 16087 return this; 16088 }; 16089 16090 /** 16091 * Connect default options to global object 16092 */ 16093 $.fn.scrollbar.options = defaults; 16094 16095 16096 /** 16097 * Check if scroll content/container size is changed 16098 */ 16099 16100 var updateScrollbars = (function () { 16101 var timer = 0, 16102 timerCounter = 0; 16103 16104 return function (force) { 16105 var i, container, options, scroll, wrapper, scrollx, scrolly; 16106 for (i = 0; i < browser.scrolls.length; i++) { 16107 scroll = browser.scrolls[i]; 16108 container = scroll.container; 16109 options = scroll.options; 16110 wrapper = scroll.wrapper; 16111 scrollx = scroll.scrollx; 16112 scrolly = scroll.scrolly; 16113 if (force || (options.autoUpdate && wrapper && wrapper.is(':visible') && 16114 (container.prop('scrollWidth') != scrollx.size || container.prop('scrollHeight') != scrolly.size || wrapper.width() != scrollx.visible || wrapper.height() != scrolly.visible))) { 16115 scroll.init(); 16116 16117 if (options.debug) { 16118 window.console && console.log({ 16119 scrollHeight: container.prop('scrollHeight') + ':' + scroll.scrolly.size, 16120 scrollWidth: container.prop('scrollWidth') + ':' + scroll.scrollx.size, 16121 visibleHeight: wrapper.height() + ':' + scroll.scrolly.visible, 16122 visibleWidth: wrapper.width() + ':' + scroll.scrollx.visible 16123 }, true); 16124 timerCounter++; 16125 } 16126 } 16127 } 16128 if (debug && timerCounter > 10) { 16129 window.console && console.log('Scroll updates exceed 10'); 16130 updateScrollbars = function () {}; 16131 } else { 16132 clearTimeout(timer); 16133 timer = setTimeout(updateScrollbars, 300); 16134 } 16135 }; 16136 })(); 16137 16138 /* ADDITIONAL FUNCTIONS */ 16139 /** 16140 * Get native browser scrollbar size (height/width) 16141 * 16142 * @param {Boolean} actual size or CSS size, default - CSS size 16143 * @returns {Object} with height, width 16144 */ 16145 function getBrowserScrollSize(actualSize) { 16146 16147 if (browser.webkit && !actualSize) { 16148 return { 16149 "height": 0, 16150 "width": 0 16151 }; 16152 } 16153 16154 if (!browser.data.outer) { 16155 var css = { 16156 "border": "none", 16157 "box-sizing": "content-box", 16158 "height": "200px", 16159 "margin": "0", 16160 "padding": "0", 16161 "width": "200px" 16162 }; 16163 browser.data.inner = $("<div>").css($.extend({}, css)); 16164 browser.data.outer = $("<div>").css($.extend({ 16165 "left": "-1000px", 16166 "overflow": "scroll", 16167 "position": "absolute", 16168 "top": "-1000px" 16169 }, css)).append(browser.data.inner).appendTo("body"); 16170 } 16171 16172 browser.data.outer.scrollLeft(1000).scrollTop(1000); 16173 16174 return { 16175 "height": Math.ceil((browser.data.outer.offset().top - browser.data.inner.offset().top) || 0), 16176 "width": Math.ceil((browser.data.outer.offset().left - browser.data.inner.offset().left) || 0) 16177 }; 16178 } 16179 16180 /** 16181 * Check if native browser scrollbars overlay content 16182 * 16183 * @returns {Boolean} 16184 */ 16185 function isScrollOverlaysContent() { 16186 var scrollSize = getBrowserScrollSize(true); 16187 return !(scrollSize.height || scrollSize.width); 16188 } 16189 16190 function isVerticalScroll(event) { 16191 var e = event.originalEvent; 16192 if (e.axis && e.axis === e.HORIZONTAL_AXIS) 16193 return false; 16194 if (e.wheelDeltaX) 16195 return false; 16196 return true; 16197 } 16198 16199 16200 /** 16201 * Extend AngularJS as UI directive 16202 * and expose a provider for override default config 16203 * 16204 */ 16205 if (window.angular) { 16206 (function (angular) { 16207 angular.module('jQueryScrollbar', []) 16208 .provider('jQueryScrollbar', function () { 16209 var defaultOptions = defaults; 16210 return { 16211 setOptions: function (options) { 16212 angular.extend(defaultOptions, options); 16213 }, 16214 $get: function () { 16215 return { 16216 options: angular.copy(defaultOptions) 16217 }; 16218 } 16219 }; 16220 }) 16221 .directive('jqueryScrollbar', ['jQueryScrollbar', '$parse', function (jQueryScrollbar, $parse) { 16222 return { 16223 "restrict": "AC", 16224 "link": function (scope, element, attrs) { 16225 var model = $parse(attrs.jqueryScrollbar), 16226 options = model(scope); 16227 element.scrollbar(options || jQueryScrollbar.options) 16228 .on('$destroy', function () { 16229 element.scrollbar('destroy'); 16230 }); 16231 } 16232 }; 16233 }]); 16234 })(window.angular); 16235 } 16236}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.