vendor: 10,699 bytes, lines 1-409
1(function(global, factory) { 2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 3 typeof define === 'function' && define.amd ? define(factory) : 4 (global.Vue = factory()); 5}(this, (function() { 6 'use strict'; 7 8 /* */ 9 10 var emptyObject = Object.freeze({}); 11 12 // these helpers produces better vm code in JS engines due to their 13 // explicitness and function inlining 14 function isUndef(v) { 15 return v === undefined || v === null 16 } 17 18 function isDef(v) { 19 return v !== undefined && v !== null 20 } 21 22 function isTrue(v) { 23 return v === true 24 } 25 26 function isFalse(v) { 27 return v === false 28 } 29 30 /** 31 * Check if value is primitive 32 */ 33 function isPrimitive(value) { 34 return ( 35 typeof value === 'string' || 36 typeof value === 'number' || 37 // $flow-disable-line 38 typeof value === 'symbol' || 39 typeof value === 'boolean' 40 ) 41 } 42 43 /** 44 * Quick object check - this is primarily used to tell 45 * Objects from primitive values when we know the value 46 * is a JSON-compliant type. 47 */ 48 function isObject(obj) { 49 return obj !== null && typeof obj === 'object' 50 } 51 52 /** 53 * Get the raw type string of a value e.g. [object Object] 54 */ 55 var _toString = Object.prototype.toString; 56 57 function toRawType(value) { 58 return _toString.call(value).slice(8, -1) 59 } 60 61 /** 62 * Strict object type check. Only returns true 63 * for plain JavaScript objects. 64 */ 65 function isPlainObject(obj) { 66 return _toString.call(obj) === '[object Object]' 67 } 68 69 function isRegExp(v) { 70 return _toString.call(v) === '[object RegExp]' 71 } 72 73 /** 74 * Check if val is a valid array index. 75 */ 76 function isValidArrayIndex(val) { 77 var n = parseFloat(String(val)); 78 return n >= 0 && Math.floor(n) === n && isFinite(val) 79 } 80 81 /** 82 * Convert a value to a string that is actually rendered. 83 */ 84 function toString(val) { 85 return val == null ? 86 '' : 87 typeof val === 'object' ? 88 JSON.stringify(val, null, 2) : 89 String(val) 90 } 91 92 /** 93 * Convert a input value to a number for persistence. 94 * If the conversion fails, return original string. 95 */ 96 function toNumber(val) { 97 var n = parseFloat(val); 98 return isNaN(n) ? val : n 99 } 100 101 /** 102 * Make a map and return a function for checking if a key 103 * is in that map. 104 */ 105 function makeMap( 106 str, 107 expectsLowerCase 108 ) { 109 var map = Object.create(null); 110 var list = str.split(','); 111 for (var i = 0; i < list.length; i++) { 112 map[list[i]] = true; 113 } 114 return expectsLowerCase ? 115 116 function(val) { return map[val.toLowerCase()]; } : 117 function(val) { return map[val]; } 118 } 119 120 /** 121 * Check if a tag is a built-in tag. 122 */ 123 var isBuiltInTag = makeMap('slot,component', true); 124 125 /** 126 * Check if a attribute is a reserved attribute. 127 */ 128 var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); 129 130 /** 131 * Remove an item from an array 132 */ 133 function remove(arr, item) { 134 if (arr.length) { 135 var index = arr.indexOf(item); 136 if (index > -1) { 137 return arr.splice(index, 1) 138 } 139 } 140 } 141 142 /** 143 * Check whether the object has the property. 144 */ 145 var hasOwnProperty = Object.prototype.hasOwnProperty; 146 147 function hasOwn(obj, key) { 148 return hasOwnProperty.call(obj, key) 149 } 150 151 /** 152 * Create a cached version of a pure function. 153 */ 154 function cached(fn) { 155 var cache = Object.create(null); 156 return (function cachedFn(str) { 157 var hit = cache[str]; 158 return hit || (cache[str] = fn(str)) 159 }) 160 } 161 162 /** 163 * Camelize a hyphen-delimited string. 164 */ 165 var camelizeRE = /-(\w)/g; 166 var camelize = cached(function(str) { 167 return str.replace(camelizeRE, function(_, c) { return c ? c.toUpperCase() : ''; }) 168 }); 169 170 /** 171 * Capitalize a string. 172 */ 173 var capitalize = cached(function(str) { 174 return str.charAt(0).toUpperCase() + str.slice(1) 175 }); 176 177 /** 178 * Hyphenate a camelCase string. 179 */ 180 var hyphenateRE = /\B([A-Z])/g; 181 var hyphenate = cached(function(str) { 182 return str.replace(hyphenateRE, '-$1').toLowerCase() 183 }); 184 185 /** 186 * Simple bind polyfill for environments that do not support it... e.g. 187 * PhantomJS 1.x. Technically we don't need this anymore since native bind is 188 * now more performant in most browsers, but removing it would be breaking for 189 * code that was able to run in PhantomJS 1.x, so this must be kept for 190 * backwards compatibility. 191 */ 192 193 /* istanbul ignore next */ 194 function polyfillBind(fn, ctx) { 195 function boundFn(a) { 196 var l = arguments.length; 197 return l ? 198 l > 1 ? 199 fn.apply(ctx, arguments) : 200 fn.call(ctx, a) : 201 fn.call(ctx) 202 } 203 204 boundFn._length = fn.length; 205 return boundFn 206 } 207 208 function nativeBind(fn, ctx) { 209 return fn.bind(ctx) 210 } 211 212 var bind = Function.prototype.bind ? 213 nativeBind : 214 polyfillBind; 215 216 /** 217 * Convert an Array-like object to a real Array. 218 */ 219 function toArray(list, start) { 220 start = start || 0; 221 var i = list.length - start; 222 var ret = new Array(i); 223 while (i--) { 224 ret[i] = list[i + start]; 225 } 226 return ret 227 } 228 229 /** 230 * Mix properties into target object. 231 */ 232 function extend(to, _from) { 233 for (var key in _from) { 234 to[key] = _from[key]; 235 } 236 return to 237 } 238 239 /** 240 * Merge an Array of Objects into a single Object. 241 */ 242 function toObject(arr) { 243 var res = {}; 244 for (var i = 0; i < arr.length; i++) { 245 if (arr[i]) { 246 extend(res, arr[i]); 247 } 248 } 249 return res 250 } 251 252 /** 253 * Perform no operation. 254 * Stubbing args to make Flow happy without leaving useless transpiled code 255 * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) 256 */ 257 function noop(a, b, c) {} 258 259 /** 260 * Always return false. 261 */ 262 var no = function(a, b, c) { return false; }; 263 264 /** 265 * Return same value 266 */ 267 var identity = function(_) { return _; }; 268 269 /** 270 * Generate a static keys string from compiler modules. 271 */ 272 function genStaticKeys(modules) { 273 return modules.reduce(function(keys, m) { 274 return keys.concat(m.staticKeys || []) 275 }, []).join(',') 276 } 277 278 /** 279 * Check if two values are loosely equal - that is, 280 * if they are plain objects, do they have the same shape? 281 */ 282 function looseEqual(a, b) { 283 if (a === b) { return true } 284 var isObjectA = isObject(a); 285 var isObjectB = isObject(b); 286 if (isObjectA && isObjectB) { 287 try { 288 var isArrayA = Array.isArray(a); 289 var isArrayB = Array.isArray(b); 290 if (isArrayA && isArrayB) { 291 return a.length === b.length && a.every(function(e, i) { 292 return looseEqual(e, b[i]) 293 }) 294 } else if (!isArrayA && !isArrayB) { 295 var keysA = Object.keys(a); 296 var keysB = Object.keys(b); 297 return keysA.length === keysB.length && keysA.every(function(key) { 298 return looseEqual(a[key], b[key]) 299 }) 300 } else { 301 /* istanbul ignore next */ 302 return false 303 } 304 } catch (e) { 305 /* istanbul ignore next */ 306 return false 307 } 308 } else if (!isObjectA && !isObjectB) { 309 return String(a) === String(b) 310 } else { 311 return false 312 } 313 } 314 315 function looseIndexOf(arr, val) { 316 for (var i = 0; i < arr.length; i++) { 317 if (looseEqual(arr[i], val)) { return i } 318 } 319 return -1 320 } 321 322 /** 323 * Ensure a function is called only once. 324 */ 325 function once(fn) { 326 var called = false; 327 return function() { 328 if (!called) { 329 called = true; 330 fn.apply(this, arguments); 331 } 332 } 333 } 334 335 var SSR_ATTR = 'data-server-rendered'; 336 337 var ASSET_TYPES = [ 338 'component', 339 'directive', 340 'filter' 341 ]; 342 343 var LIFECYCLE_HOOKS = [ 344 'beforeCreate', 345 'created', 346 'beforeMount', 347 'mounted', 348 'beforeUpdate', 349 'updated', 350 'beforeDestroy', 351 'destroyed', 352 'activated', 353 'deactivated', 354 'errorCaptured' 355 ]; 356 357 /* */ 358 359 var config = ({ 360 /** 361 * Option merge strategies (used in core/util/options) 362 */ 363 // $flow-disable-line 364 optionMergeStrategies: Object.create(null), 365 366 /** 367 * Whether to suppress warnings. 368 */ 369 silent: false, 370 371 /** 372 * Show production mode tip message on boot? 373 */ 374 productionTip: "development" !== 'production', 375 376 /** 377 * Whether to enable devtools 378 */ 379 devtools: "development" !== 'production', 380 381 /** 382 * Whether to record perf 383 */ 384 performance: false, 385 386 /** 387 * Error handler for watcher errors 388 */ 389 errorHandler: null, 390 391 /** 392 * Warn handler for watcher warns 393 */ 394 warnHandler: null, 395 396 /** 397 * Ignore certain custom elements 398 */ 399 ignoredElements: [], 400 401 /** 402 * Custom user key aliases for v-on 403 */ 404 // $flow-disable-line 405 keyCodes: Object.create(null), 406 407 /** 408 * Check if a tag is reserved so that it cannot be registered as a 409 * component. This is platform-dependent and may be over
vendor: 10,769 bytes, lines 409-757
409written. 410 */ 411 isReservedTag: no, 412 413 /** 414 * Check if an attribute is reserved so that it cannot be used as a component 415 * prop. This is platform-dependent and may be overwritten. 416 */ 417 isReservedAttr: no, 418 419 /** 420 * Check if a tag is an unknown element. 421 * Platform-dependent. 422 */ 423 isUnknownElement: no, 424 425 /** 426 * Get the namespace of an element 427 */ 428 getTagNamespace: noop, 429 430 /** 431 * Parse the real tag name for the specific platform. 432 */ 433 parsePlatformTagName: identity, 434 435 /** 436 * Check if an attribute must be bound using property, e.g. value 437 * Platform-dependent. 438 */ 439 mustUseProp: no, 440 441 /** 442 * Exposed for legacy reasons 443 */ 444 _lifecycleHooks: LIFECYCLE_HOOKS 445 }) 446 447 /* */ 448 449 /** 450 * Check if a string starts with $ or _ 451 */ 452 function isReserved(str) { 453 var c = (str + '').charCodeAt(0); 454 return c === 0x24 || c === 0x5F 455 } 456 457 /** 458 * Define a property. 459 */ 460 function def(obj, key, val, enumerable) { 461 Object.defineProperty(obj, key, { 462 value: val, 463 enumerable: !!enumerable, 464 writable: true, 465 configurable: true 466 }); 467 } 468 469 /** 470 * Parse simple path. 471 */ 472 var bailRE = /[^\w.$]/; 473 474 function parsePath(path) { 475 if (bailRE.test(path)) { 476 return 477 } 478 var segments = path.split('.'); 479 return function(obj) { 480 for (var i = 0; i < segments.length; i++) { 481 if (!obj) { return } 482 obj = obj[segments[i]]; 483 } 484 return obj 485 } 486 } 487 488 /* */ 489 490 // can we use __proto__? 491 var hasProto = '__proto__' in {}; 492 493 // Browser environment sniffing 494 var inBrowser = typeof window !== 'undefined'; 495 var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; 496 var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase(); 497 var UA = inBrowser && window.navigator.userAgent.toLowerCase(); 498 var isIE = UA && /msie|trident/.test(UA); 499 var isIE9 = UA && UA.indexOf('msie 9.0') > 0; 500 var isEdge = UA && UA.indexOf('edge/') > 0; 501 var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android'); 502 var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios'); 503 var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; 504 505 // Firefox has a "watch" function on Object.prototype... 506 var nativeWatch = ({}).watch; 507 508 var supportsPassive = false; 509 if (inBrowser) { 510 try { 511 var opts = {}; 512 Object.defineProperty(opts, 'passive', ({ 513 get: function get() { 514 /* istanbul ignore next */ 515 supportsPassive = true; 516 } 517 })); // https://github.com/facebook/flow/issues/285 518 window.addEventListener('test-passive', null, opts); 519 } catch (e) {} 520 } 521 522 // this needs to be lazy-evaled because vue may be required before 523 // vue-server-renderer can set VUE_ENV 524 var _isServer; 525 var isServerRendering = function() { 526 if (_isServer === undefined) { 527 /* istanbul ignore if */ 528 if (!inBrowser && !inWeex && typeof global !== 'undefined') { 529 // detect presence of vue-server-renderer and avoid 530 // Webpack shimming the process 531 _isServer = global['process'].env.VUE_ENV === 'server'; 532 } else { 533 _isServer = false; 534 } 535 } 536 return _isServer 537 }; 538 539 // detect devtools 540 var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; 541 542 /* istanbul ignore next */ 543 function isNative(Ctor) { 544 return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) 545 } 546 547 var hasSymbol = 548 typeof Symbol !== 'undefined' && isNative(Symbol) && 549 typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); 550 551 var _Set; 552 /* istanbul ignore if */ // $flow-disable-line 553 if (typeof Set !== 'undefined' && isNative(Set)) { 554 // use native Set when available. 555 _Set = Set; 556 } else { 557 // a non-standard Set polyfill that only works with primitive keys. 558 _Set = (function() { 559 function Set() { 560 this.set = Object.create(null); 561 } 562 Set.prototype.has = function has(key) { 563 return this.set[key] === true 564 }; 565 Set.prototype.add = function add(key) { 566 this.set[key] = true; 567 }; 568 Set.prototype.clear = function clear() { 569 this.set = Object.create(null); 570 }; 571 572 return Set; 573 }()); 574 } 575 576 /* */ 577 578 var warn = noop; 579 var tip = noop; 580 var generateComponentTrace = (noop); // work around flow check 581 var formatComponentName = (noop); 582 583 { 584 var hasConsole = typeof console !== 'undefined'; 585 var classifyRE = /(?:^|[-_])(\w)/g; 586 var classify = function(str) { 587 return str 588 .replace(classifyRE, function(c) { return c.toUpperCase(); }) 589 .replace(/[-_]/g, ''); 590 }; 591 592 warn = function(msg, vm) { 593 var trace = vm ? generateComponentTrace(vm) : ''; 594 595 if (config.warnHandler) { 596 config.warnHandler.call(null, msg, vm, trace); 597 } else if (hasConsole && (!config.silent)) { 598 console.error(("[Vue warn]: " + msg + trace)); 599 } 600 }; 601 602 tip = function(msg, vm) { 603 if (hasConsole && (!config.silent)) { 604 console.warn("[Vue tip]: " + msg + ( 605 vm ? generateComponentTrace(vm) : '' 606 )); 607 } 608 }; 609 610 formatComponentName = function(vm, includeFile) { 611 if (vm.$root === vm) { 612 return '<Root>' 613 } 614 var options = typeof vm === 'function' && vm.cid != null ? 615 vm.options : 616 vm._isVue ? 617 vm.$options || vm.constructor.options : 618 vm || {}; 619 var name = options.name || options._componentTag; 620 var file = options.__file; 621 if (!name && file) { 622 var match = file.match(/([^/\\]+)\.vue$/); 623 name = match && match[1]; 624 } 625 626 return ( 627 (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") + 628 (file && includeFile !== false ? (" at " + file) : '') 629 ) 630 }; 631 632 var repeat = function(str, n) { 633 var res = ''; 634 while (n) { 635 if (n % 2 === 1) { res += str; } 636 if (n > 1) { str += str; } 637 n >>= 1; 638 } 639 return res 640 }; 641 642 generateComponentTrace = function(vm) { 643 if (vm._isVue && vm.$parent) { 644 var tree = []; 645 var currentRecursiveSequence = 0; 646 while (vm) { 647 if (tree.length > 0) { 648 var last = tree[tree.length - 1]; 649 if (last.constructor === vm.constructor) { 650 currentRecursiveSequence++; 651 vm = vm.$parent; 652 continue 653 } else if (currentRecursiveSequence > 0) { 654 tree[tree.length - 1] = [last, currentRecursiveSequence]; 655 currentRecursiveSequence = 0; 656 } 657 } 658 tree.push(vm); 659 vm = vm.$parent; 660 } 661 return '\n\nfound in\n\n' + tree 662 .map(function(vm, i) { 663 return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm) ? 664 ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)") : 665 formatComponentName(vm))); 666 }) 667 .join('\n') 668 } else { 669 return ("\n\n(found in " + (formatComponentName(vm)) + ")") 670 } 671 }; 672 } 673 674 /* */ 675 676 677 var uid = 0; 678 679 /** 680 * A dep is an observable that can have multiple 681 * directives subscribing to it. 682 */ 683 var Dep = function Dep() { 684 this.id = uid++; 685 this.subs = []; 686 }; 687 688 Dep.prototype.addSub = function addSub(sub) { 689 this.subs.push(sub); 690 }; 691 692 Dep.prototype.removeSub = function removeSub(sub) { 693 remove(this.subs, sub); 694 }; 695 696 Dep.prototype.depend = function depend() { 697 if (Dep.target) { 698 Dep.target.addDep(this); 699 } 700 }; 701 702 Dep.prototype.notify = function notify() { 703 // stabilize the subscriber list first 704 var subs = this.subs.slice(); 705 for (var i = 0, l = subs.length; i < l; i++) { 706 subs[i].update(); 707 } 708 }; 709 710 // the current target watcher being evaluated. 711 // this is globally unique because there could be only one 712 // watcher being evaluated at any time. 713 Dep.target = null; 714 var targetStack = []; 715 716 function pushTarget(_target) { 717 if (Dep.target) { targetStack.push(Dep.target); } 718 Dep.target = _target; 719 } 720 721 function popTarget() { 722 Dep.target = targetStack.pop(); 723 } 724 725 /* */ 726 727 var VNode = function VNode( 728 tag, 729 data, 730 children, 731 text, 732 elm, 733 context, 734 componentOptions, 735 asyncFactory 736 ) { 737 this.tag = tag; 738 this.data = data; 739 this.children = children; 740 this.text = text; 741 this.elm = elm; 742 this.ns = undefined; 743 this.context = context; 744 this.fnContext = undefined; 745 this.fnOptions = undefined; 746 this.fnScopeId = undefined; 747 this.key = data && data.key; 748 this.componentOptions = componentOptions; 749 this.componentInstance = undefined; 750 this.parent = undefined; 751 this.raw = false; 752 this.isStatic = false; 753 this.isRootInsert = true; 754 this.isComment = false; 755 this.isCloned = false; 756 this.isOnce = false; 757 this.asyncFactory = asyncFactory;
vendor: 25,521 bytes, lines 758-1588
758 this.asyncMeta = undefined; 759 this.isAsyncPlaceholder = false; 760 }; 761 762 var prototypeAccessors = { child: { configurable: true } }; 763 764 // DEPRECATED: alias for componentInstance for backwards compat. 765 /* istanbul ignore next */ 766 prototypeAccessors.child.get = function() { 767 return this.componentInstance 768 }; 769 770 Object.defineProperties(VNode.prototype, prototypeAccessors); 771 772 var createEmptyVNode = function(text) { 773 if (text === void 0) text = ''; 774 775 var node = new VNode(); 776 node.text = text; 777 node.isComment = true; 778 return node 779 }; 780 781 function createTextVNode(val) { 782 return new VNode(undefined, undefined, undefined, String(val)) 783 } 784 785 // optimized shallow clone 786 // used for static nodes and slot nodes because they may be reused across 787 // multiple renders, cloning them avoids errors when DOM manipulations rely 788 // on their elm reference. 789 function cloneVNode(vnode) { 790 var cloned = new VNode( 791 vnode.tag, 792 vnode.data, 793 vnode.children, 794 vnode.text, 795 vnode.elm, 796 vnode.context, 797 vnode.componentOptions, 798 vnode.asyncFactory 799 ); 800 cloned.ns = vnode.ns; 801 cloned.isStatic = vnode.isStatic; 802 cloned.key = vnode.key; 803 cloned.isComment = vnode.isComment; 804 cloned.fnContext = vnode.fnContext; 805 cloned.fnOptions = vnode.fnOptions; 806 cloned.fnScopeId = vnode.fnScopeId; 807 cloned.isCloned = true; 808 return cloned 809 } 810 811 /* 812 * not type checking this file because flow doesn't play well with 813 * dynamically accessing methods on Array prototype 814 */ 815 816 var arrayProto = Array.prototype; 817 var arrayMethods = Object.create(arrayProto); 818 819 var methodsToPatch = [ 820 'push', 821 'pop', 822 'shift', 823 'unshift', 824 'splice', 825 'sort', 826 'reverse' 827 ]; 828 829 /** 830 * Intercept mutating methods and emit events 831 */ 832 methodsToPatch.forEach(function(method) { 833 // cache original method 834 var original = arrayProto[method]; 835 def(arrayMethods, method, function mutator() { 836 var args = [], 837 len = arguments.length; 838 while (len--) args[len] = arguments[len]; 839 840 var result = original.apply(this, args); 841 var ob = this.__ob__; 842 var inserted; 843 switch (method) { 844 case 'push': 845 case 'unshift': 846 inserted = args; 847 break 848 case 'splice': 849 inserted = args.slice(2); 850 break 851 } 852 if (inserted) { ob.observeArray(inserted); } 853 // notify change 854 ob.dep.notify(); 855 return result 856 }); 857 }); 858 859 /* */ 860 861 var arrayKeys = Object.getOwnPropertyNames(arrayMethods); 862 863 /** 864 * In some cases we may want to disable observation inside a component's 865 * update computation. 866 */ 867 var shouldObserve = true; 868 869 function toggleObserving(value) { 870 shouldObserve = value; 871 } 872 873 /** 874 * Observer class that is attached to each observed 875 * object. Once attached, the observer converts the target 876 * object's property keys into getter/setters that 877 * collect dependencies and dispatch updates. 878 */ 879 var Observer = function Observer(value) { 880 this.value = value; 881 this.dep = new Dep(); 882 this.vmCount = 0; 883 def(value, '__ob__', this); 884 if (Array.isArray(value)) { 885 var augment = hasProto ? 886 protoAugment : 887 copyAugment; 888 augment(value, arrayMethods, arrayKeys); 889 this.observeArray(value); 890 } else { 891 this.walk(value); 892 } 893 }; 894 895 /** 896 * Walk through each property and convert them into 897 * getter/setters. This method should only be called when 898 * value type is Object. 899 */ 900 Observer.prototype.walk = function walk(obj) { 901 var keys = Object.keys(obj); 902 for (var i = 0; i < keys.length; i++) { 903 defineReactive(obj, keys[i]); 904 } 905 }; 906 907 /** 908 * Observe a list of Array items. 909 */ 910 Observer.prototype.observeArray = function observeArray(items) { 911 for (var i = 0, l = items.length; i < l; i++) { 912 observe(items[i]); 913 } 914 }; 915 916 // helpers 917 918 /** 919 * Augment an target Object or Array by intercepting 920 * the prototype chain using __proto__ 921 */ 922 function protoAugment(target, src, keys) { 923 /* eslint-disable no-proto */ 924 target.__proto__ = src; 925 /* eslint-enable no-proto */ 926 } 927 928 /** 929 * Augment an target Object or Array by defining 930 * hidden properties. 931 */ 932 /* istanbul ignore next */ 933 function copyAugment(target, src, keys) { 934 for (var i = 0, l = keys.length; i < l; i++) { 935 var key = keys[i]; 936 def(target, key, src[key]); 937 } 938 } 939 940 /** 941 * Attempt to create an observer instance for a value, 942 * returns the new observer if successfully observed, 943 * or the existing observer if the value already has one. 944 */ 945 function observe(value, asRootData) { 946 if (!isObject(value) || value instanceof VNode) { 947 return 948 } 949 var ob; 950 if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { 951 ob = value.__ob__; 952 } else if ( 953 shouldObserve && 954 !isServerRendering() && 955 (Array.isArray(value) || isPlainObject(value)) && 956 Object.isExtensible(value) && 957 !value._isVue 958 ) { 959 ob = new Observer(value); 960 } 961 if (asRootData && ob) { 962 ob.vmCount++; 963 } 964 return ob 965 } 966 967 /** 968 * Define a reactive property on an Object. 969 */ 970 function defineReactive( 971 obj, 972 key, 973 val, 974 customSetter, 975 shallow 976 ) { 977 var dep = new Dep(); 978 979 var property = Object.getOwnPropertyDescriptor(obj, key); 980 if (property && property.configurable === false) { 981 return 982 } 983 984 // cater for pre-defined getter/setters 985 var getter = property && property.get; 986 if (!getter && arguments.length === 2) { 987 val = obj[key]; 988 } 989 var setter = property && property.set; 990 991 var childOb = !shallow && observe(val); 992 Object.defineProperty(obj, key, { 993 enumerable: true, 994 configurable: true, 995 get: function reactiveGetter() { 996 var value = getter ? getter.call(obj) : val; 997 if (Dep.target) { 998 dep.depend(); 999 if (childOb) { 1000 childOb.dep.depend(); 1001 if (Array.isArray(value)) { 1002 dependArray(value); 1003 } 1004 } 1005 } 1006 return value 1007 }, 1008 set: function reactiveSetter(newVal) { 1009 var value = getter ? getter.call(obj) : val; 1010 /* eslint-disable no-self-compare */ 1011 if (newVal === value || (newVal !== newVal && value !== value)) { 1012 return 1013 } 1014 /* eslint-enable no-self-compare */ 1015 if ("development" !== 'production' && customSetter) { 1016 customSetter(); 1017 } 1018 if (setter) { 1019 setter.call(obj, newVal); 1020 } else { 1021 val = newVal; 1022 } 1023 childOb = !shallow && observe(newVal); 1024 dep.notify(); 1025 } 1026 }); 1027 } 1028 1029 /** 1030 * Set a property on an object. Adds the new property and 1031 * triggers change notification if the property doesn't 1032 * already exist. 1033 */ 1034 function set(target, key, val) { 1035 if ("development" !== 'production' && 1036 (isUndef(target) || isPrimitive(target)) 1037 ) { 1038 warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target)))); 1039 } 1040 if (Array.isArray(target) && isValidArrayIndex(key)) { 1041 target.length = Math.max(target.length, key); 1042 target.splice(key, 1, val); 1043 return val 1044 } 1045 if (key in target && !(key in Object.prototype)) { 1046 target[key] = val; 1047 return val 1048 } 1049 var ob = (target).__ob__; 1050 if (target._isVue || (ob && ob.vmCount)) { 1051 "development" !== 'production' && warn( 1052 'Avoid adding reactive properties to a Vue instance or its root $data ' + 1053 'at runtime - declare it upfront in the data option.' 1054 ); 1055 return val 1056 } 1057 if (!ob) { 1058 target[key] = val; 1059 return val 1060 } 1061 defineReactive(ob.value, key, val); 1062 ob.dep.notify(); 1063 return val 1064 } 1065 1066 /** 1067 * Delete a property and trigger change if necessary. 1068 */ 1069 function del(target, key) { 1070 if ("development" !== 'production' && 1071 (isUndef(target) || isPrimitive(target)) 1072 ) { 1073 warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target)))); 1074 } 1075 if (Array.isArray(target) && isValidArrayIndex(key)) { 1076 target.splice(key, 1); 1077 return 1078 } 1079 var ob = (target).__ob__; 1080 if (target._isVue || (ob && ob.vmCount)) { 1081 "development" !== 'production' && warn( 1082 'Avoid deleting properties on a Vue instance or its root $data ' + 1083 '- just set it to null.' 1084 ); 1085 return 1086 } 1087 if (!hasOwn(target, key)) { 1088 return 1089 } 1090 delete target[key]; 1091 if (!ob) { 1092 return 1093 } 1094 ob.dep.notify(); 1095 } 1096 1097 /** 1098 * Collect dependencies on array elements when the array is touched, since 1099 * we cannot intercept array element access like property getters. 1100 */ 1101 function dependArray(value) { 1102 for (var e = (void 0), i = 0, l = value.length; i < l; i++) { 1103 e = value[i]; 1104 e && e.__ob__ && e.__ob__.dep.depend(); 1105 if (Array.isArray(e)) { 1106 dependArray(e); 1107 } 1108 } 1109 } 1110 1111 /* */ 1112 1113 /** 1114 * Option overwriting strategies are functions that handle 1115 * how to merge a parent option value and a child option 1116 * value into the final value. 1117 */ 1118 var strats = config.optionMergeStrategies; 1119 1120 /** 1121 * Options with restrictions 1122 */ 1123 { 1124 strats.el = strats.propsData = function(parent, child, vm, key) { 1125 if (!vm) { 1126 warn( 1127 "option \"" + key + "\" can only be used during instance " + 1128 'creation with the `new` keyword.' 1129 ); 1130 } 1131 return defaultStrat(parent, child) 1132 }; 1133 } 1134 1135 /** 1136 * Helper that recursively merges two data objects together. 1137 */ 1138 function mergeData(to, from) { 1139 if (!from) { return to } 1140 var key, toVal, fromVal; 1141 var keys = Object.keys(from); 1142 for (var i = 0; i < keys.length; i++) { 1143 key = keys[i]; 1144 toVal = to[key]; 1145 fromVal = from[key]; 1146 if (!hasOwn(to, key)) { 1147 set(to, key, fromVal); 1148 } else if (isPlainObject(toVal) && isPlainObject(fromVal)) { 1149 mergeData(toVal, fromVal); 1150 } 1151 } 1152 return to 1153 } 1154 1155 /** 1156 * Data 1157 */ 1158 function mergeDataOrFn( 1159 parentVal, 1160 childVal, 1161 vm 1162 ) { 1163 if (!vm) { 1164 // in a Vue.extend merge, both should be functions 1165 if (!childVal) { 1166 return parentVal 1167 } 1168 if (!parentVal) { 1169 return childVal 1170 } 1171 // when parentVal & childVal are both present, 1172 // we need to return a function that returns the 1173 // merged result of both functions... no need to 1174 // check if parentVal is a function here because 1175 // it has to be a function to pass previous merges. 1176 return function mergedDataFn() { 1177 return mergeData( 1178 typeof childVal === 'function' ? childVal.call(this, this) : childVal, 1179 typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal 1180 ) 1181 } 1182 } else { 1183 return function mergedInstanceDataFn() { 1184 // instance merge 1185 var instanceData = typeof childVal === 'function' ? 1186 childVal.call(vm, vm) : 1187 childVal; 1188 var defaultData = typeof parentVal === 'function' ? 1189 parentVal.call(vm, vm) : 1190 parentVal; 1191 if (instanceData) { 1192 return mergeData(instanceData, defaultData) 1193 } else { 1194 return defaultData 1195 } 1196 } 1197 } 1198 } 1199 1200 strats.data = function( 1201 parentVal, 1202 childVal, 1203 vm 1204 ) { 1205 if (!vm) { 1206 if (childVal && typeof childVal !== 'function') { 1207 "development" !== 'production' && warn( 1208 'The "data" option should be a function ' + 1209 'that returns a per-instance value in component ' + 1210 'definitions.', 1211 vm 1212 ); 1213 1214 return parentVal 1215 } 1216 return mergeDataOrFn(parentVal, childVal) 1217 } 1218 1219 return mergeDataOrFn(parentVal, childVal, vm) 1220 }; 1221 1222 /** 1223 * Hooks and props are merged as arrays. 1224 */ 1225 function mergeHook( 1226 parentVal, 1227 childVal 1228 ) { 1229 return childVal ? 1230 parentVal ? 1231 parentVal.concat(childVal) : 1232 Array.isArray(childVal) ? 1233 childVal : 1234 [childVal] : 1235 parentVal 1236 } 1237 1238 LIFECYCLE_HOOKS.forEach(function(hook) { 1239 strats[hook] = mergeHook; 1240 }); 1241 1242 /** 1243 * Assets 1244 * 1245 * When a vm is present (instance creation), we need to do 1246 * a three-way merge between constructor options, instance 1247 * options and parent options. 1248 */ 1249 function mergeAssets( 1250 parentVal, 1251 childVal, 1252 vm, 1253 key 1254 ) { 1255 var res = Object.create(parentVal || null); 1256 if (childVal) { 1257 "development" !== 'production' && assertObjectType(key, childVal, vm); 1258 return extend(res, childVal) 1259 } else { 1260 return res 1261 } 1262 } 1263 1264 ASSET_TYPES.forEach(function(type) { 1265 strats[type + 's'] = mergeAssets; 1266 }); 1267 1268 /** 1269 * Watchers. 1270 * 1271 * Watchers hashes should not overwrite one 1272 * another, so we merge them as arrays. 1273 */ 1274 strats.watch = function( 1275 parentVal, 1276 childVal, 1277 vm, 1278 key 1279 ) { 1280 // work around Firefox's Object.prototype.watch... 1281 if (parentVal === nativeWatch) { parentVal = undefined; } 1282 if (childVal === nativeWatch) { childVal = undefined; } 1283 /* istanbul ignore if */ 1284 if (!childVal) { return Object.create(parentVal || null) } { 1285 assertObjectType(key, childVal, vm); 1286 } 1287 if (!parentVal) { return childVal } 1288 var ret = {}; 1289 extend(ret, parentVal); 1290 for (var key$1 in childVal) { 1291 var parent = ret[key$1]; 1292 var child = childVal[key$1]; 1293 if (parent && !Array.isArray(parent)) { 1294 parent = [parent]; 1295 } 1296 ret[key$1] = parent ? 1297 parent.concat(child) : 1298 Array.isArray(child) ? child : [child]; 1299 } 1300 return ret 1301 }; 1302 1303 /** 1304 * Other object hashes. 1305 */ 1306 strats.props = 1307 strats.methods = 1308 strats.inject = 1309 strats.computed = function( 1310 parentVal, 1311 childVal, 1312 vm, 1313 key 1314 ) { 1315 if (childVal && "development" !== 'production') { 1316 assertObjectType(key, childVal, vm); 1317 } 1318 if (!parentVal) { return childVal } 1319 var ret = Object.create(null); 1320 extend(ret, parentVal); 1321 if (childVal) { extend(ret, childVal); } 1322 return ret 1323 }; 1324 strats.provide = mergeDataOrFn; 1325 1326 /** 1327 * Default strategy. 1328 */ 1329 var defaultStrat = function(parentVal, childVal) { 1330 return childVal === undefined ? 1331 parentVal : 1332 childVal 1333 }; 1334 1335 /** 1336 * Validate component names 1337 */ 1338 function checkComponents(options) { 1339 for (var key in options.components) { 1340 validateComponentName(key); 1341 } 1342 } 1343 1344 function validateComponentName(name) { 1345 if (!/^[a-zA-Z][\w-]*$/.test(name)) { 1346 warn( 1347 'Invalid component name: "' + name + '". Component names ' + 1348 'can only contain alphanumeric characters and the hyphen, ' + 1349 'and must start with a letter.' 1350 ); 1351 } 1352 if (isBuiltInTag(name) || config.isReservedTag(name)) { 1353 warn( 1354 'Do not use built-in or reserved HTML elements as component ' + 1355 'id: ' + name 1356 ); 1357 } 1358 } 1359 1360 /** 1361 * Ensure all props option syntax are normalized into the 1362 * Object-based format. 1363 */ 1364 function normalizeProps(options, vm) { 1365 var props = options.props; 1366 if (!props) { return } 1367 var res = {}; 1368 var i, val, name; 1369 if (Array.isArray(props)) { 1370 i = props.length; 1371 while (i--) { 1372 val = props[i]; 1373 if (typeof val === 'string') { 1374 name = camelize(val); 1375 res[name] = { type: null }; 1376 } else { 1377 warn('props must be strings when using array syntax.'); 1378 } 1379 } 1380 } else if (isPlainObject(props)) { 1381 for (var key in props) { 1382 val = props[key]; 1383 name = camelize(key); 1384 res[name] = isPlainObject(val) ? 1385 val : 1386 { type: val }; 1387 } 1388 } else { 1389 warn( 1390 "Invalid value for option \"props\": expected an Array or an Object, " + 1391 "but got " + (toRawType(props)) + ".", 1392 vm 1393 ); 1394 } 1395 options.props = res; 1396 } 1397 1398 /** 1399 * Normalize all injections into Object-based format 1400 */ 1401 function normalizeInject(options, vm) { 1402 var inject = options.inject; 1403 if (!inject) { return } 1404 var normalized = options.inject = {}; 1405 if (Array.isArray(inject)) { 1406 for (var i = 0; i < inject.length; i++) { 1407 normalized[inject[i]] = { from: inject[i] }; 1408 } 1409 } else if (isPlainObject(inject)) { 1410 for (var key in inject) { 1411 var val = inject[key]; 1412 normalized[key] = isPlainObject(val) ? 1413 extend({ from: key }, val) : 1414 { from: val }; 1415 } 1416 } else { 1417 warn( 1418 "Invalid value for option \"inject\": expected an Array or an Object, " + 1419 "but got " + (toRawType(inject)) + ".", 1420 vm 1421 ); 1422 } 1423 } 1424 1425 /** 1426 * Normalize raw function directives into object format. 1427 */ 1428 function normalizeDirectives(options) { 1429 var dirs = options.directives; 1430 if (dirs) { 1431 for (var key in dirs) { 1432 var def = dirs[key]; 1433 if (typeof def === 'function') { 1434 dirs[key] = { bind: def, update: def }; 1435 } 1436 } 1437 } 1438 } 1439 1440 function assertObjectType(name, value, vm) { 1441 if (!isPlainObject(value)) { 1442 warn( 1443 "Invalid value for option \"" + name + "\": expected an Object, " + 1444 "but got " + (toRawType(value)) + ".", 1445 vm 1446 ); 1447 } 1448 } 1449 1450 /** 1451 * Merge two option objects into a new one. 1452 * Core utility used in both instantiation and inheritance. 1453 */ 1454 function mergeOptions( 1455 parent, 1456 child, 1457 vm 1458 ) { 1459 { 1460 checkComponents(child); 1461 } 1462 1463 if (typeof child === 'function') { 1464 child = child.options; 1465 } 1466 1467 normalizeProps(child, vm); 1468 normalizeInject(child, vm); 1469 normalizeDirectives(child); 1470 var extendsFrom = child.extends; 1471 if (extendsFrom) { 1472 parent = mergeOptions(parent, extendsFrom, vm); 1473 } 1474 if (child.mixins) { 1475 for (var i = 0, l = child.mixins.length; i < l; i++) { 1476 parent = mergeOptions(parent, child.mixins[i], vm); 1477 } 1478 } 1479 var options = {}; 1480 var key; 1481 for (key in parent) { 1482 mergeField(key); 1483 } 1484 for (key in child) { 1485 if (!hasOwn(parent, key)) { 1486 mergeField(key); 1487 } 1488 } 1489 1490 function mergeField(key) { 1491 var strat = strats[key] || defaultStrat; 1492 options[key] = strat(parent[key], child[key], vm, key); 1493 } 1494 return options 1495 } 1496 1497 /** 1498 * Resolve an asset. 1499 * This function is used because child instances need access 1500 * to assets defined in its ancestor chain. 1501 */ 1502 function resolveAsset( 1503 options, 1504 type, 1505 id, 1506 warnMissing 1507 ) { 1508 /* istanbul ignore if */ 1509 if (typeof id !== 'string') { 1510 return 1511 } 1512 var assets = options[type]; 1513 // check local registration variations first 1514 if (hasOwn(assets, id)) { return assets[id] } 1515 var camelizedId = camelize(id); 1516 if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } 1517 var PascalCaseId = capitalize(camelizedId); 1518 if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } 1519 // fallback to prototype chain 1520 var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; 1521 if ("development" !== 'production' && warnMissing && !res) { 1522 warn( 1523 'Failed to resolve ' + type.slice(0, -1) + ': ' + id, 1524 options 1525 ); 1526 } 1527 return res 1528 } 1529 1530 /* */ 1531 1532 function validateProp( 1533 key, 1534 propOptions, 1535 propsData, 1536 vm 1537 ) { 1538 var prop = propOptions[key]; 1539 var absent = !hasOwn(propsData, key); 1540 var value = propsData[key]; 1541 // boolean casting 1542 var booleanIndex = getTypeIndex(Boolean, prop.type); 1543 if (booleanIndex > -1) { 1544 if (absent && !hasOwn(prop, 'default')) { 1545 value = false; 1546 } else if (value === '' || value === hyphenate(key)) { 1547 // only cast empty string / same name to boolean if 1548 // boolean has higher priority 1549 var stringIndex = getTypeIndex(String, prop.type); 1550 if (stringIndex < 0 || booleanIndex < stringIndex) { 1551 value = true; 1552 } 1553 } 1554 } 1555 // check default value 1556 if (value === undefined) { 1557 value = getPropDefaultValue(vm, prop, key); 1558 // since the default value is a fresh copy, 1559 // make sure to observe it. 1560 var prevShouldObserve = shouldObserve; 1561 toggleObserving(true); 1562 observe(value); 1563 toggleObserving(prevShouldObserve); 1564 } { 1565 assertProp(prop, key, value, vm, absent); 1566 } 1567 return value 1568 } 1569 1570 /** 1571 * Get the default value of a prop. 1572 */ 1573 function getPropDefaultValue(vm, prop, key) { 1574 // no default, return undefined 1575 if (!hasOwn(prop, 'default')) { 1576 return undefined 1577 } 1578 var def = prop.default; 1579 // warn against non-factory defaults for Object & Array 1580 if ("development" !== 'production' && isObject(def)) { 1581 warn( 1582 'Invalid default value for prop "' + key + '": ' + 1583 'Props with type Object/Array must use a factory function ' + 1584 'to return the default value.', 1585 vm 1586 ); 1587 } 1588 // the raw prop value was also undefined from previous render,
vendor: 6,579 bytes, lines 1589-1784
1589 // return previous default value to avoid unnecessary watcher trigger 1590 if (vm && vm.$options.propsData && 1591 vm.$options.propsData[key] === undefined && 1592 vm._props[key] !== undefined 1593 ) { 1594 return vm._props[key] 1595 } 1596 // call factory function for non-Function types 1597 // a value is Function if its prototype is function even across different execution context 1598 return typeof def === 'function' && getType(prop.type) !== 'Function' ? 1599 def.call(vm) : 1600 def 1601 } 1602 1603 /** 1604 * Assert whether a prop is valid. 1605 */ 1606 function assertProp( 1607 prop, 1608 name, 1609 value, 1610 vm, 1611 absent 1612 ) { 1613 if (prop.required && absent) { 1614 warn( 1615 'Missing required prop: "' + name + '"', 1616 vm 1617 ); 1618 return 1619 } 1620 if (value == null && !prop.required) { 1621 return 1622 } 1623 var type = prop.type; 1624 var valid = !type || type === true; 1625 var expectedTypes = []; 1626 if (type) { 1627 if (!Array.isArray(type)) { 1628 type = [type]; 1629 } 1630 for (var i = 0; i < type.length && !valid; i++) { 1631 var assertedType = assertType(value, type[i]); 1632 expectedTypes.push(assertedType.expectedType || ''); 1633 valid = assertedType.valid; 1634 } 1635 } 1636 if (!valid) { 1637 warn( 1638 "Invalid prop: type check failed for prop \"" + name + "\"." + 1639 " Expected " + (expectedTypes.map(capitalize).join(', ')) + 1640 ", got " + (toRawType(value)) + ".", 1641 vm 1642 ); 1643 return 1644 } 1645 var validator = prop.validator; 1646 if (validator) { 1647 if (!validator(value)) { 1648 warn( 1649 'Invalid prop: custom validator check failed for prop "' + name + '".', 1650 vm 1651 ); 1652 } 1653 } 1654 } 1655 1656 var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/; 1657 1658 function assertType(value, type) { 1659 var valid; 1660 var expectedType = getType(type); 1661 if (simpleCheckRE.test(expectedType)) { 1662 var t = typeof value; 1663 valid = t === expectedType.toLowerCase(); 1664 // for primitive wrapper objects 1665 if (!valid && t === 'object') { 1666 valid = value instanceof type; 1667 } 1668 } else if (expectedType === 'Object') { 1669 valid = isPlainObject(value); 1670 } else if (expectedType === 'Array') { 1671 valid = Array.isArray(value); 1672 } else { 1673 valid = value instanceof type; 1674 } 1675 return { 1676 valid: valid, 1677 expectedType: expectedType 1678 } 1679 } 1680 1681 /** 1682 * Use function string name to check built-in types, 1683 * because a simple equality check will fail when running 1684 * across different vms / iframes. 1685 */ 1686 function getType(fn) { 1687 var match = fn && fn.toString().match(/^\s*function (\w+)/); 1688 return match ? match[1] : '' 1689 } 1690 1691 function isSameType(a, b) { 1692 return getType(a) === getType(b) 1693 } 1694 1695 function getTypeIndex(type, expectedTypes) { 1696 if (!Array.isArray(expectedTypes)) { 1697 return isSameType(expectedTypes, type) ? 0 : -1 1698 } 1699 for (var i = 0, len = expectedTypes.length; i < len; i++) { 1700 if (isSameType(expectedTypes[i], type)) { 1701 return i 1702 } 1703 } 1704 return -1 1705 } 1706 1707 /* */ 1708 1709 function handleError(err, vm, info) { 1710 if (vm) { 1711 var cur = vm; 1712 while ((cur = cur.$parent)) { 1713 var hooks = cur.$options.errorCaptured; 1714 if (hooks) { 1715 for (var i = 0; i < hooks.length; i++) { 1716 try { 1717 var capture = hooks[i].call(cur, err, vm, info) === false; 1718 if (capture) { return } 1719 } catch (e) { 1720 globalHandleError(e, cur, 'errorCaptured hook'); 1721 } 1722 } 1723 } 1724 } 1725 } 1726 globalHandleError(err, vm, info); 1727 } 1728 1729 function globalHandleError(err, vm, info) { 1730 if (config.errorHandler) { 1731 try { 1732 return config.errorHandler.call(null, err, vm, info) 1733 } catch (e) { 1734 logError(e, null, 'config.errorHandler'); 1735 } 1736 } 1737 logError(err, vm, info); 1738 } 1739 1740 function logError(err, vm, info) { 1741 { 1742 warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm); 1743 } 1744 /* istanbul ignore else */ 1745 if ((inBrowser || inWeex) && typeof console !== 'undefined') { 1746 console.error(err); 1747 } else { 1748 throw err 1749 } 1750 } 1751 1752 /* */ 1753 /* globals MessageChannel */ 1754 1755 var callbacks = []; 1756 var pending = false; 1757 1758 function flushCallbacks() { 1759 pending = false; 1760 var copies = callbacks.slice(0); 1761 callbacks.length = 0; 1762 for (var i = 0; i < copies.length; i++) { 1763 copies[i](); 1764 } 1765 } 1766 1767 // Here we have async deferring wrappers using both microtasks and (macro) tasks. 1768 // In < 2.4 we used microtasks everywhere, but there are some scenarios where 1769 // microtasks have too high a priority and fire in between supposedly 1770 // sequential events (e.g. #4521, #6690) or even between bubbling of the same 1771 // event (#6566). However, using (macro) tasks everywhere also has subtle problems 1772 // when state is changed right before repaint (e.g. #6813, out-in transitions). 1773 // Here we use microtask by default, but expose a way to force (macro) task when 1774 // needed (e.g. in event handlers attached by v-on). 1775 var microTimerFunc; 1776 var macroTimerFunc; 1777 var useMacroTask = false; 1778 1779 // Determine (macro) task defer implementation. 1780 // Technically setImmediate should be the ideal choice, but it's only available 1781 // in IE. The only polyfill that consistently queues the callback after all DOM 1782 // events triggered in the same loop is by using MessageChannel. 1783 /* istanbul ignore if */ 1784 if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
1785 macroTimerFunc = function() { 1786 setImmediate(flushCallbacks); 1787 }; 1788 } else if (typeof MessageChannel !== 'undefined' && ( 1789 isNative(MessageChannel) || 1790 // PhantomJS 1791 MessageChannel.toString() === '[object MessageChannelConstructor]' 1792 )) { 1793 var channel = new MessageChannel(); 1794 var port = channel.port2; 1795 channel.port1.onmessage = flushCallbacks; 1796 macroTimerFunc = function() { 1797 port.postMessage(1); 1798 }; 1799 } else { 1800 /* istanbul ignore next */ 1801 macroTimerFunc = function() { 1802 setTimeout(flushCallbacks, 0); 1803 }; 1804 } 1805 1806 // Determine microtask defer implementation. 1807 /* istanbul ignore next, $flow-disable-line */ 1808 if (typeof Promise !== 'undefined' && isNative(Promise)) { 1809 var p = Promise.resolve(); 1810 microTimerFunc = function() { 1811 p.then(flushCallbacks); 1812 // in problematic UIWebViews, Promise.then doesn't completely break, but 1813 // it can get stuck in a weird state where callbacks are pushed into the 1814 // microtask queue but the queue isn't being flushed, until the browser 1815 // needs to do some other work, e.g. handle a timer. Therefore we can 1816 // "force" the microtask queue to be flushed by adding an empty timer. 1817 if (isIOS) { setTimeout(noop); } 1818 }; 1819 } else { 1820 // fallback to macro 1821 microTimerFunc = macroTimerFunc; 1822 } 1823 1824 /** 1825 * Wrap a function so that if any code inside triggers state change, 1826 * the changes are queued using a (macro) task instead of a microtask. 1827 */ 1828 function withMacroTask(fn) { 1829 return fn._withTask || (fn._withTask = function() { 1830 useMacroTask = true; 1831 var res = fn.apply(null, arguments); 1832 useMacroTask = false; 1833 return res 1834 }) 1835 } 1836 1837 function nextTick(cb, ctx) { 1838 var _resolve; 1839 callbacks.push(function() { 1840 if (cb) { 1841 try { 1842 cb.call(ctx); 1843 } catch (e) { 1844 handleError(e, ctx, 'nextTick'); 1845 } 1846 } else if (_resolve) { 1847 _resolve(ctx); 1848 } 1849 }); 1850 if (!pending) { 1851 pending = true; 1852 if (useMacroTask) { 1853 macroTimerFunc(); 1854 } else { 1855 microTimerFunc(); 1856 } 1857 } 1858 // $flow-disable-line 1859 if (!cb && typeof Promise !== 'undefined') { 1860 return new Promise(function(resolve) { 1861 _resolve = resolve; 1862 }) 1863 } 1864 } 1865 1866 /* */ 1867 1868 var mark; 1869 var measure; 1870 1871 { 1872 var perf = inBrowser && window.performance; 1873 /* istanbul ignore if */ 1874 if ( 1875 perf && 1876 perf.mark && 1877 perf.measure && 1878 perf.clearMarks && 1879 perf.clearMeasures 1880 ) { 1881 mark = function(tag) { return perf.mark(tag); }; 1882 measure = function(name, startTag, endTag) { 1883 perf.measure(name, startTag, endTag); 1884 perf.clearMarks(startTag); 1885 perf.clearMarks(endTag); 1886 perf.clearMeasures(name); 1887 }; 1888 } 1889 } 1890 1891 /* not type checking this file because flow doesn't play well with Proxy */ 1892 1893 var initProxy; 1894 1895 { 1896 var allowedGlobals = makeMap( 1897 'Infinity,undefined,NaN,isFinite,isNaN,' + 1898 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + 1899 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + 1900 'require' // for Webpack/Browserify 1901 ); 1902 1903 var warnNonPresent = function(target, key) { 1904 warn( 1905 "Property or method \"" + key + "\" is not defined on the instance but " + 1906 'referenced during render. Make sure that this property is reactive, ' + 1907 'either in the data option, or for class-based components, by ' + 1908 'initializing the property. ' + 1909 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
vendor: 8,056 bytes, lines 1910-2158
1910 target 1911 ); 1912 }; 1913 1914 var hasProxy = 1915 typeof Proxy !== 'undefined' && isNative(Proxy); 1916 1917 if (hasProxy) { 1918 var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact'); 1919 config.keyCodes = new Proxy(config.keyCodes, { 1920 set: function set(target, key, value) { 1921 if (isBuiltInModifier(key)) { 1922 warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key)); 1923 return false 1924 } else { 1925 target[key] = value; 1926 return true 1927 } 1928 } 1929 }); 1930 } 1931 1932 var hasHandler = { 1933 has: function has(target, key) { 1934 var has = key in target; 1935 var isAllowed = allowedGlobals(key) || key.charAt(0) === '_'; 1936 if (!has && !isAllowed) { 1937 warnNonPresent(target, key); 1938 } 1939 return has || !isAllowed 1940 } 1941 }; 1942 1943 var getHandler = { 1944 get: function get(target, key) { 1945 if (typeof key === 'string' && !(key in target)) { 1946 warnNonPresent(target, key); 1947 } 1948 return target[key] 1949 } 1950 }; 1951 1952 initProxy = function initProxy(vm) { 1953 if (hasProxy) { 1954 // determine which proxy handler to use 1955 var options = vm.$options; 1956 var handlers = options.render && options.render._withStripped ? 1957 getHandler : 1958 hasHandler; 1959 vm._renderProxy = new Proxy(vm, handlers); 1960 } else { 1961 vm._renderProxy = vm; 1962 } 1963 }; 1964 } 1965 1966 /* */ 1967 1968 var seenObjects = new _Set(); 1969 1970 /** 1971 * Recursively traverse an object to evoke all converted 1972 * getters, so that every nested property inside the object 1973 * is collected as a "deep" dependency. 1974 */ 1975 function traverse(val) { 1976 _traverse(val, seenObjects); 1977 seenObjects.clear(); 1978 } 1979 1980 function _traverse(val, seen) { 1981 var i, keys; 1982 var isA = Array.isArray(val); 1983 if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) { 1984 return 1985 } 1986 if (val.__ob__) { 1987 var depId = val.__ob__.dep.id; 1988 if (seen.has(depId)) { 1989 return 1990 } 1991 seen.add(depId); 1992 } 1993 if (isA) { 1994 i = val.length; 1995 while (i--) { _traverse(val[i], seen); } 1996 } else { 1997 keys = Object.keys(val); 1998 i = keys.length; 1999 while (i--) { _traverse(val[keys[i]], seen); } 2000 } 2001 } 2002 2003 /* */ 2004 2005 var normalizeEvent = cached(function(name) { 2006 var passive = name.charAt(0) === '&'; 2007 name = passive ? name.slice(1) : name; 2008 var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first 2009 name = once$$1 ? name.slice(1) : name; 2010 var capture = name.charAt(0) === '!'; 2011 name = capture ? name.slice(1) : name; 2012 return { 2013 name: name, 2014 once: once$$1, 2015 capture: capture, 2016 passive: passive 2017 } 2018 }); 2019 2020 function createFnInvoker(fns) { 2021 function invoker() { 2022 var arguments$1 = arguments; 2023 2024 var fns = invoker.fns; 2025 if (Array.isArray(fns)) { 2026 var cloned = fns.slice(); 2027 for (var i = 0; i < cloned.length; i++) { 2028 cloned[i].apply(null, arguments$1); 2029 } 2030 } else { 2031 // return handler return value for single handlers 2032 return fns.apply(null, arguments) 2033 } 2034 } 2035 invoker.fns = fns; 2036 return invoker 2037 } 2038 2039 function updateListeners( 2040 on, 2041 oldOn, 2042 add, 2043 remove$$1, 2044 vm 2045 ) { 2046 var name, def, cur, old, event; 2047 for (name in on) { 2048 def = cur = on[name]; 2049 old = oldOn[name]; 2050 event = normalizeEvent(name); 2051 /* istanbul ignore if */ 2052 if (isUndef(cur)) { 2053 "development" !== 'production' && warn( 2054 "Invalid handler for event \"" + (event.name) + "\": got " + String(cur), 2055 vm 2056 ); 2057 } else if (isUndef(old)) { 2058 if (isUndef(cur.fns)) { 2059 cur = on[name] = createFnInvoker(cur); 2060 } 2061 add(event.name, cur, event.once, event.capture, event.passive, event.params); 2062 } else if (cur !== old) { 2063 old.fns = cur; 2064 on[name] = old; 2065 } 2066 } 2067 for (name in oldOn) { 2068 if (isUndef(on[name])) { 2069 event = normalizeEvent(name); 2070 remove$$1(event.name, oldOn[name], event.capture); 2071 } 2072 } 2073 } 2074 2075 /* */ 2076 2077 function mergeVNodeHook(def, hookKey, hook) { 2078 if (def instanceof VNode) { 2079 def = def.data.hook || (def.data.hook = {}); 2080 } 2081 var invoker; 2082 var oldHook = def[hookKey]; 2083 2084 function wrappedHook() { 2085 hook.apply(this, arguments); 2086 // important: remove merged hook to ensure it's called only once 2087 // and prevent memory leak 2088 remove(invoker.fns, wrappedHook); 2089 } 2090 2091 if (isUndef(oldHook)) { 2092 // no existing hook 2093 invoker = createFnInvoker([wrappedHook]); 2094 } else { 2095 /* istanbul ignore if */ 2096 if (isDef(oldHook.fns) && isTrue(oldHook.merged)) { 2097 // already a merged invoker 2098 invoker = oldHook; 2099 invoker.fns.push(wrappedHook); 2100 } else { 2101 // existing plain hook 2102 invoker = createFnInvoker([oldHook, wrappedHook]); 2103 } 2104 } 2105 2106 invoker.merged = true; 2107 def[hookKey] = invoker; 2108 } 2109 2110 /* */ 2111 2112 function extractPropsFromVNodeData( 2113 data, 2114 Ctor, 2115 tag 2116 ) { 2117 // we are only extracting raw values here. 2118 // validation and default values are handled in the child 2119 // component itself. 2120 var propOptions = Ctor.options.props; 2121 if (isUndef(propOptions)) { 2122 return 2123 } 2124 var res = {}; 2125 var attrs = data.attrs; 2126 var props = data.props; 2127 if (isDef(attrs) || isDef(props)) { 2128 for (var key in propOptions) { 2129 var altKey = hyphenate(key); { 2130 var keyInLowerCase = key.toLowerCase(); 2131 if ( 2132 key !== keyInLowerCase && 2133 attrs && hasOwn(attrs, keyInLowerCase) 2134 ) { 2135 tip( 2136 "Prop \"" + keyInLowerCase + "\" is passed to component " + 2137 (formatComponentName(tag || Ctor)) + ", but the declared prop name is" + 2138 " \"" + key + "\". " + 2139 "Note that HTML attributes are case-insensitive and camelCased " + 2140 "props need to use their kebab-case equivalents when using in-DOM " + 2141 "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"." 2142 ); 2143 } 2144 } 2145 checkProp(res, props, key, altKey, true) || 2146 checkProp(res, attrs, key, altKey, false); 2147 } 2148 } 2149 return res 2150 } 2151 2152 function checkProp( 2153 res, 2154 hash, 2155 key, 2156 altKey, 2157 preserve 2158 ) {
vendor: 6,716 bytes, lines 2159-2343
2159 if (isDef(hash)) { 2160 if (hasOwn(hash, key)) { 2161 res[key] = hash[key]; 2162 if (!preserve) { 2163 delete hash[key]; 2164 } 2165 return true 2166 } else if (hasOwn(hash, altKey)) { 2167 res[key] = hash[altKey]; 2168 if (!preserve) { 2169 delete hash[altKey]; 2170 } 2171 return true 2172 } 2173 } 2174 return false 2175 } 2176 2177 /* */ 2178 2179 // The template compiler attempts to minimize the need for normalization by 2180 // statically analyzing the template at compile time. 2181 // 2182 // For plain HTML markup, normalization can be completely skipped because the 2183 // generated render function is guaranteed to return Array<VNode>. There are 2184 // two cases where extra normalization is needed: 2185 2186 // 1. When the children contains components - because a functional component 2187 // may return an Array instead of a single root. In this case, just a simple 2188 // normalization is needed - if any child is an Array, we flatten the whole 2189 // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep 2190 // because functional components already normalize their own children. 2191 function simpleNormalizeChildren(children) { 2192 for (var i = 0; i < children.length; i++) { 2193 if (Array.isArray(children[i])) { 2194 return Array.prototype.concat.apply([], children) 2195 } 2196 } 2197 return children 2198 } 2199 2200 // 2. When the children contains constructs that always generated nested Arrays, 2201 // e.g. <template>, <slot>, v-for, or when the children is provided by user 2202 // with hand-written render functions / JSX. In such cases a full normalization 2203 // is needed to cater to all possible types of children values. 2204 function normalizeChildren(children) { 2205 return isPrimitive(children) ? 2206 [createTextVNode(children)] : 2207 Array.isArray(children) ? 2208 normalizeArrayChildren(children) : 2209 undefined 2210 } 2211 2212 function isTextNode(node) { 2213 return isDef(node) && isDef(node.text) && isFalse(node.isComment) 2214 } 2215 2216 function normalizeArrayChildren(children, nestedIndex) { 2217 var res = []; 2218 var i, c, lastIndex, last; 2219 for (i = 0; i < children.length; i++) { 2220 c = children[i]; 2221 if (isUndef(c) || typeof c === 'boolean') { continue } 2222 lastIndex = res.length - 1; 2223 last = res[lastIndex]; 2224 // nested 2225 if (Array.isArray(c)) { 2226 if (c.length > 0) { 2227 c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)); 2228 // merge adjacent text nodes 2229 if (isTextNode(c[0]) && isTextNode(last)) { 2230 res[lastIndex] = createTextVNode(last.text + (c[0]).text); 2231 c.shift(); 2232 } 2233 res.push.apply(res, c); 2234 } 2235 } else if (isPrimitive(c)) { 2236 if (isTextNode(last)) { 2237 // merge adjacent text nodes 2238 // this is necessary for SSR hydration because text nodes are 2239 // essentially merged when rendered to HTML strings 2240 res[lastIndex] = createTextVNode(last.text + c); 2241 } else if (c !== '') { 2242 // convert primitive to vnode 2243 res.push(createTextVNode(c)); 2244 } 2245 } else { 2246 if (isTextNode(c) && isTextNode(last)) { 2247 // merge adjacent text nodes 2248 res[lastIndex] = createTextVNode(last.text + c.text); 2249 } else { 2250 // default key for nested array children (likely generated by v-for) 2251 if (isTrue(children._isVList) && 2252 isDef(c.tag) && 2253 isUndef(c.key) && 2254 isDef(nestedIndex)) { 2255 c.key = "__vlist" + nestedIndex + "_" + i + "__"; 2256 } 2257 res.push(c); 2258 } 2259 } 2260 } 2261 return res 2262 } 2263 2264 /* */ 2265 2266 function ensureCtor(comp, base) { 2267 if ( 2268 comp.__esModule || 2269 (hasSymbol && comp[Symbol.toStringTag] === 'Module') 2270 ) { 2271 comp = comp.default; 2272 } 2273 return isObject(comp) ? 2274 base.extend(comp) : 2275 comp 2276 } 2277 2278 function createAsyncPlaceholder( 2279 factory, 2280 data, 2281 context, 2282 children, 2283 tag 2284 ) { 2285 var node = createEmptyVNode(); 2286 node.asyncFactory = factory; 2287 node.asyncMeta = { data: data, context: context, children: children, tag: tag }; 2288 return node 2289 } 2290 2291 function resolveAsyncComponent( 2292 factory, 2293 baseCtor, 2294 context 2295 ) { 2296 if (isTrue(factory.error) && isDef(factory.errorComp)) { 2297 return factory.errorComp 2298 } 2299 2300 if (isDef(factory.resolved)) { 2301 return factory.resolved 2302 } 2303 2304 if (isTrue(factory.loading) && isDef(factory.loadingComp)) { 2305 return factory.loadingComp 2306 } 2307 2308 if (isDef(factory.contexts)) { 2309 // already pending 2310 factory.contexts.push(context); 2311 } else { 2312 var contexts = factory.contexts = [context]; 2313 var sync = true; 2314 2315 var forceRender = function() { 2316 for (var i = 0, l = contexts.length; i < l; i++) { 2317 contexts[i].$forceUpdate(); 2318 } 2319 }; 2320 2321 var resolve = once(function(res) { 2322 // cache resolved 2323 factory.resolved = ensureCtor(res, baseCtor); 2324 // invoke callbacks only if this is not a synchronous resolve 2325 // (async resolves are shimmed as synchronous during SSR) 2326 if (!sync) { 2327 forceRender(); 2328 } 2329 }); 2330 2331 var reject = once(function(reason) { 2332 "development" !== 'production' && warn( 2333 "Failed to resolve async component: " + (String(factory)) + 2334 (reason ? ("\nReason: " + reason) : '') 2335 ); 2336 if (isDef(factory.errorComp)) { 2337 factory.error = true; 2338 forceRender(); 2339 } 2340 }); 2341 2342 var res = factory(resolve, reject); 2343
vendor: 28,034 bytes, lines 2344-3199
2344 if (isObject(res)) { 2345 if (typeof res.then === 'function') { 2346 // () => Promise 2347 if (isUndef(factory.resolved)) { 2348 res.then(resolve, reject); 2349 } 2350 } else if (isDef(res.component) && typeof res.component.then === 'function') { 2351 res.component.then(resolve, reject); 2352 2353 if (isDef(res.error)) { 2354 factory.errorComp = ensureCtor(res.error, baseCtor); 2355 } 2356 2357 if (isDef(res.loading)) { 2358 factory.loadingComp = ensureCtor(res.loading, baseCtor); 2359 if (res.delay === 0) { 2360 factory.loading = true; 2361 } else { 2362 setTimeout(function() { 2363 if (isUndef(factory.resolved) && isUndef(factory.error)) { 2364 factory.loading = true; 2365 forceRender(); 2366 } 2367 }, res.delay || 200); 2368 } 2369 } 2370 2371 if (isDef(res.timeout)) { 2372 setTimeout(function() { 2373 if (isUndef(factory.resolved)) { 2374 reject( 2375 "timeout (" + (res.timeout) + "ms)" 2376 ); 2377 } 2378 }, res.timeout); 2379 } 2380 } 2381 } 2382 2383 sync = false; 2384 // return in case resolved synchronously 2385 return factory.loading ? 2386 factory.loadingComp : 2387 factory.resolved 2388 } 2389 } 2390 2391 /* */ 2392 2393 function isAsyncPlaceholder(node) { 2394 return node.isComment && node.asyncFactory 2395 } 2396 2397 /* */ 2398 2399 function getFirstComponentChild(children) { 2400 if (Array.isArray(children)) { 2401 for (var i = 0; i < children.length; i++) { 2402 var c = children[i]; 2403 if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) { 2404 return c 2405 } 2406 } 2407 } 2408 } 2409 2410 /* */ 2411 2412 /* */ 2413 2414 function initEvents(vm) { 2415 vm._events = Object.create(null); 2416 vm._hasHookEvent = false; 2417 // init parent attached events 2418 var listeners = vm.$options._parentListeners; 2419 if (listeners) { 2420 updateComponentListeners(vm, listeners); 2421 } 2422 } 2423 2424 var target; 2425 2426 function add(event, fn, once) { 2427 if (once) { 2428 target.$once(event, fn); 2429 } else { 2430 target.$on(event, fn); 2431 } 2432 } 2433 2434 function remove$1(event, fn) { 2435 target.$off(event, fn); 2436 } 2437 2438 function updateComponentListeners( 2439 vm, 2440 listeners, 2441 oldListeners 2442 ) { 2443 target = vm; 2444 updateListeners(listeners, oldListeners || {}, add, remove$1, vm); 2445 target = undefined; 2446 } 2447 2448 function eventsMixin(Vue) { 2449 var hookRE = /^hook:/; 2450 Vue.prototype.$on = function(event, fn) { 2451 var this$1 = this; 2452 2453 var vm = this; 2454 if (Array.isArray(event)) { 2455 for (var i = 0, l = event.length; i < l; i++) { 2456 this$1.$on(event[i], fn); 2457 } 2458 } else { 2459 (vm._events[event] || (vm._events[event] = [])).push(fn); 2460 // optimize hook:event cost by using a boolean flag marked at registration 2461 // instead of a hash lookup 2462 if (hookRE.test(event)) { 2463 vm._hasHookEvent = true; 2464 } 2465 } 2466 return vm 2467 }; 2468 2469 Vue.prototype.$once = function(event, fn) { 2470 var vm = this; 2471 2472 function on() { 2473 vm.$off(event, on); 2474 fn.apply(vm, arguments); 2475 } 2476 on.fn = fn; 2477 vm.$on(event, on); 2478 return vm 2479 }; 2480 2481 Vue.prototype.$off = function(event, fn) { 2482 var this$1 = this; 2483 2484 var vm = this; 2485 // all 2486 if (!arguments.length) { 2487 vm._events = Object.create(null); 2488 return vm 2489 } 2490 // array of events 2491 if (Array.isArray(event)) { 2492 for (var i = 0, l = event.length; i < l; i++) { 2493 this$1.$off(event[i], fn); 2494 } 2495 return vm 2496 } 2497 // specific event 2498 var cbs = vm._events[event]; 2499 if (!cbs) { 2500 return vm 2501 } 2502 if (!fn) { 2503 vm._events[event] = null; 2504 return vm 2505 } 2506 if (fn) { 2507 // specific handler 2508 var cb; 2509 var i$1 = cbs.length; 2510 while (i$1--) { 2511 cb = cbs[i$1]; 2512 if (cb === fn || cb.fn === fn) { 2513 cbs.splice(i$1, 1); 2514 break 2515 } 2516 } 2517 } 2518 return vm 2519 }; 2520 2521 Vue.prototype.$emit = function(event) { 2522 var vm = this; { 2523 var lowerCaseEvent = event.toLowerCase(); 2524 if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) { 2525 tip( 2526 "Event \"" + lowerCaseEvent + "\" is emitted in component " + 2527 (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " + 2528 "Note that HTML attributes are case-insensitive and you cannot use " + 2529 "v-on to listen to camelCase events when using in-DOM templates. " + 2530 "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"." 2531 ); 2532 } 2533 } 2534 var cbs = vm._events[event]; 2535 if (cbs) { 2536 cbs = cbs.length > 1 ? toArray(cbs) : cbs; 2537 var args = toArray(arguments, 1); 2538 for (var i = 0, l = cbs.length; i < l; i++) { 2539 try { 2540 cbs[i].apply(vm, args); 2541 } catch (e) { 2542 handleError(e, vm, ("event handler for \"" + event + "\"")); 2543 } 2544 } 2545 } 2546 return vm 2547 }; 2548 } 2549 2550 /* */ 2551 2552 2553 2554 /** 2555 * Runtime helper for resolving raw children VNodes into a slot object. 2556 */ 2557 function resolveSlots( 2558 children, 2559 context 2560 ) { 2561 var slots = {}; 2562 if (!children) { 2563 return slots 2564 } 2565 for (var i = 0, l = children.length; i < l; i++) { 2566 var child = children[i]; 2567 var data = child.data; 2568 // remove slot attribute if the node is resolved as a Vue slot node 2569 if (data && data.attrs && data.attrs.slot) { 2570 delete data.attrs.slot; 2571 } 2572 // named slots should only be respected if the vnode was rendered in the 2573 // same context. 2574 if ((child.context === context || child.fnContext === context) && 2575 data && data.slot != null 2576 ) { 2577 var name = data.slot; 2578 var slot = (slots[name] || (slots[name] = [])); 2579 if (child.tag === 'template') { 2580 slot.push.apply(slot, child.children || []); 2581 } else { 2582 slot.push(child); 2583 } 2584 } else { 2585 (slots.default || (slots.default = [])).push(child); 2586 } 2587 } 2588 // ignore slots that contains only whitespace 2589 for (var name$1 in slots) { 2590 if (slots[name$1].every(isWhitespace)) { 2591 delete slots[name$1]; 2592 } 2593 } 2594 return slots 2595 } 2596 2597 function isWhitespace(node) { 2598 return (node.isComment && !node.asyncFactory) || node.text === ' ' 2599 } 2600 2601 function resolveScopedSlots( 2602 fns, // see flow/vnode 2603 res 2604 ) { 2605 res = res || {}; 2606 for (var i = 0; i < fns.length; i++) { 2607 if (Array.isArray(fns[i])) { 2608 resolveScopedSlots(fns[i], res); 2609 } else { 2610 res[fns[i].key] = fns[i].fn; 2611 } 2612 } 2613 return res 2614 } 2615 2616 /* */ 2617 2618 var activeInstance = null; 2619 var isUpdatingChildComponent = false; 2620 2621 function initLifecycle(vm) { 2622 var options = vm.$options; 2623 2624 // locate first non-abstract parent 2625 var parent = options.parent; 2626 if (parent && !options.abstract) { 2627 while (parent.$options.abstract && parent.$parent) { 2628 parent = parent.$parent; 2629 } 2630 parent.$children.push(vm); 2631 } 2632 2633 vm.$parent = parent; 2634 vm.$root = parent ? parent.$root : vm; 2635 2636 vm.$children = []; 2637 vm.$refs = {}; 2638 2639 vm._watcher = null; 2640 vm._inactive = null; 2641 vm._directInactive = false; 2642 vm._isMounted = false; 2643 vm._isDestroyed = false; 2644 vm._isBeingDestroyed = false; 2645 } 2646 2647 function lifecycleMixin(Vue) { 2648 Vue.prototype._update = function(vnode, hydrating) { 2649 var vm = this; 2650 if (vm._isMounted) { 2651 callHook(vm, 'beforeUpdate'); 2652 } 2653 var prevEl = vm.$el; 2654 var prevVnode = vm._vnode; 2655 var prevActiveInstance = activeInstance; 2656 activeInstance = vm; 2657 vm._vnode = vnode; 2658 // Vue.prototype.__patch__ is injected in entry points 2659 // based on the rendering backend used. 2660 if (!prevVnode) { 2661 // initial render 2662 vm.$el = vm.__patch__( 2663 vm.$el, vnode, hydrating, false /* removeOnly */ , 2664 vm.$options._parentElm, 2665 vm.$options._refElm 2666 ); 2667 // no need for the ref nodes after initial patch 2668 // this prevents keeping a detached DOM tree in memory (#5851) 2669 vm.$options._parentElm = vm.$options._refElm = null; 2670 } else { 2671 // updates 2672 vm.$el = vm.__patch__(prevVnode, vnode); 2673 } 2674 activeInstance = prevActiveInstance; 2675 // update __vue__ reference 2676 if (prevEl) { 2677 prevEl.__vue__ = null; 2678 } 2679 if (vm.$el) { 2680 vm.$el.__vue__ = vm; 2681 } 2682 // if parent is an HOC, update its $el as well 2683 if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) { 2684 vm.$parent.$el = vm.$el; 2685 } 2686 // updated hook is called by the scheduler to ensure that children are 2687 // updated in a parent's updated hook. 2688 }; 2689 2690 Vue.prototype.$forceUpdate = function() { 2691 var vm = this; 2692 if (vm._watcher) { 2693 vm._watcher.update(); 2694 } 2695 }; 2696 2697 Vue.prototype.$destroy = function() { 2698 var vm = this; 2699 if (vm._isBeingDestroyed) { 2700 return 2701 } 2702 callHook(vm, 'beforeDestroy'); 2703 vm._isBeingDestroyed = true; 2704 // remove self from parent 2705 var parent = vm.$parent; 2706 if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) { 2707 remove(parent.$children, vm); 2708 } 2709 // teardown watchers 2710 if (vm._watcher) { 2711 vm._watcher.teardown(); 2712 } 2713 var i = vm._watchers.length; 2714 while (i--) { 2715 vm._watchers[i].teardown(); 2716 } 2717 // remove reference from data ob 2718 // frozen object may not have observer. 2719 if (vm._data.__ob__) { 2720 vm._data.__ob__.vmCount--; 2721 } 2722 // call the last hook... 2723 vm._isDestroyed = true; 2724 // invoke destroy hooks on current rendered tree 2725 vm.__patch__(vm._vnode, null); 2726 // fire destroyed hook 2727 callHook(vm, 'destroyed'); 2728 // turn off all instance listeners. 2729 vm.$off(); 2730 // remove __vue__ reference 2731 if (vm.$el) { 2732 vm.$el.__vue__ = null; 2733 } 2734 // release circular reference (#6759) 2735 if (vm.$vnode) { 2736 vm.$vnode.parent = null; 2737 } 2738 }; 2739 } 2740 2741 function mountComponent( 2742 vm, 2743 el, 2744 hydrating 2745 ) { 2746 vm.$el = el; 2747 if (!vm.$options.render) { 2748 vm.$options.render = createEmptyVNode; { 2749 /* istanbul ignore if */ 2750 if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') || 2751 vm.$options.el || el) { 2752 warn( 2753 'You are using the runtime-only build of Vue where the template ' + 2754 'compiler is not available. Either pre-compile the templates into ' + 2755 'render functions, or use the compiler-included build.', 2756 vm 2757 ); 2758 } else { 2759 warn( 2760 'Failed to mount component: template or render function not defined.', 2761 vm 2762 ); 2763 } 2764 } 2765 } 2766 callHook(vm, 'beforeMount'); 2767 2768 var updateComponent; 2769 /* istanbul ignore if */ 2770 if ("development" !== 'production' && config.performance && mark) { 2771 updateComponent = function() { 2772 var name = vm._name; 2773 var id = vm._uid; 2774 var startTag = "vue-perf-start:" + id; 2775 var endTag = "vue-perf-end:" + id; 2776 2777 mark(startTag); 2778 var vnode = vm._render(); 2779 mark(endTag); 2780 measure(("vue " + name + " render"), startTag, endTag); 2781 2782 mark(startTag); 2783 vm._update(vnode, hydrating); 2784 mark(endTag); 2785 measure(("vue " + name + " patch"), startTag, endTag); 2786 }; 2787 } else { 2788 updateComponent = function() { 2789 vm._update(vm._render(), hydrating); 2790 }; 2791 } 2792 2793 // we set this to vm._watcher inside the watcher's constructor 2794 // since the watcher's initial patch may call $forceUpdate (e.g. inside child 2795 // component's mounted hook), which relies on vm._watcher being already defined 2796 new Watcher(vm, updateComponent, noop, null, true /* isRenderWatcher */ ); 2797 hydrating = false; 2798 2799 // manually mounted instance, call mounted on self 2800 // mounted is called for render-created child components in its inserted hook 2801 if (vm.$vnode == null) { 2802 vm._isMounted = true; 2803 callHook(vm, 'mounted'); 2804 } 2805 return vm 2806 } 2807 2808 function updateChildComponent( 2809 vm, 2810 propsData, 2811 listeners, 2812 parentVnode, 2813 renderChildren 2814 ) { 2815 { 2816 isUpdatingChildComponent = true; 2817 } 2818 2819 // determine whether component has slot children 2820 // we need to do this before overwriting $options._renderChildren 2821 var hasChildren = !!( 2822 renderChildren || // has new static slots 2823 vm.$options._renderChildren || // has old static slots 2824 parentVnode.data.scopedSlots || // has new scoped slots 2825 vm.$scopedSlots !== emptyObject // has old scoped slots 2826 ); 2827 2828 vm.$options._parentVnode = parentVnode; 2829 vm.$vnode = parentVnode; // update vm's placeholder node without re-render 2830 2831 if (vm._vnode) { // update child tree's parent 2832 vm._vnode.parent = parentVnode; 2833 } 2834 vm.$options._renderChildren = renderChildren; 2835 2836 // update $attrs and $listeners hash 2837 // these are also reactive so they may trigger child update if the child 2838 // used them during render 2839 vm.$attrs = parentVnode.data.attrs || emptyObject; 2840 vm.$listeners = listeners || emptyObject; 2841 2842 // update props 2843 if (propsData && vm.$options.props) { 2844 toggleObserving(false); 2845 var props = vm._props; 2846 var propKeys = vm.$options._propKeys || []; 2847 for (var i = 0; i < propKeys.length; i++) { 2848 var key = propKeys[i]; 2849 var propOptions = vm.$options.props; // wtf flow? 2850 props[key] = validateProp(key, propOptions, propsData, vm); 2851 } 2852 toggleObserving(true); 2853 // keep a copy of raw propsData 2854 vm.$options.propsData = propsData; 2855 } 2856 2857 // update listeners 2858 listeners = listeners || emptyObject; 2859 var oldListeners = vm.$options._parentListeners; 2860 vm.$options._parentListeners = listeners; 2861 updateComponentListeners(vm, listeners, oldListeners); 2862 2863 // resolve slots + force update if has children 2864 if (hasChildren) { 2865 vm.$slots = resolveSlots(renderChildren, parentVnode.context); 2866 vm.$forceUpdate(); 2867 } 2868 2869 { 2870 isUpdatingChildComponent = false; 2871 } 2872 } 2873 2874 function isInInactiveTree(vm) { 2875 while (vm && (vm = vm.$parent)) { 2876 if (vm._inactive) { return true } 2877 } 2878 return false 2879 } 2880 2881 function activateChildComponent(vm, direct) { 2882 if (direct) { 2883 vm._directInactive = false; 2884 if (isInInactiveTree(vm)) { 2885 return 2886 } 2887 } else if (vm._directInactive) { 2888 return 2889 } 2890 if (vm._inactive || vm._inactive === null) { 2891 vm._inactive = false; 2892 for (var i = 0; i < vm.$children.length; i++) { 2893 activateChildComponent(vm.$children[i]); 2894 } 2895 callHook(vm, 'activated'); 2896 } 2897 } 2898 2899 function deactivateChildComponent(vm, direct) { 2900 if (direct) { 2901 vm._directInactive = true; 2902 if (isInInactiveTree(vm)) { 2903 return 2904 } 2905 } 2906 if (!vm._inactive) { 2907 vm._inactive = true; 2908 for (var i = 0; i < vm.$children.length; i++) { 2909 deactivateChildComponent(vm.$children[i]); 2910 } 2911 callHook(vm, 'deactivated'); 2912 } 2913 } 2914 2915 function callHook(vm, hook) { 2916 // #7573 disable dep collection when invoking lifecycle hooks 2917 pushTarget(); 2918 var handlers = vm.$options[hook]; 2919 if (handlers) { 2920 for (var i = 0, j = handlers.length; i < j; i++) { 2921 try { 2922 handlers[i].call(vm); 2923 } catch (e) { 2924 handleError(e, vm, (hook + " hook")); 2925 } 2926 } 2927 } 2928 if (vm._hasHookEvent) { 2929 vm.$emit('hook:' + hook); 2930 } 2931 popTarget(); 2932 } 2933 2934 /* */ 2935 2936 2937 var MAX_UPDATE_COUNT = 100; 2938 2939 var queue = []; 2940 var activatedChildren = []; 2941 var has = {}; 2942 var circular = {}; 2943 var waiting = false; 2944 var flushing = false; 2945 var index = 0; 2946 2947 /** 2948 * Reset the scheduler's state. 2949 */ 2950 function resetSchedulerState() { 2951 index = queue.length = activatedChildren.length = 0; 2952 has = {}; { 2953 circular = {}; 2954 } 2955 waiting = flushing = false; 2956 } 2957 2958 /** 2959 * Flush both queues and run the watchers. 2960 */ 2961 function flushSchedulerQueue() { 2962 flushing = true; 2963 var watcher, id; 2964 2965 // Sort queue before flush. 2966 // This ensures that: 2967 // 1. Components are updated from parent to child. (because parent is always 2968 // created before the child) 2969 // 2. A component's user watchers are run before its render watcher (because 2970 // user watchers are created before the render watcher) 2971 // 3. If a component is destroyed during a parent component's watcher run, 2972 // its watchers can be skipped. 2973 queue.sort(function(a, b) { return a.id - b.id; }); 2974 2975 // do not cache length because more watchers might be pushed 2976 // as we run existing watchers 2977 for (index = 0; index < queue.length; index++) { 2978 watcher = queue[index]; 2979 id = watcher.id; 2980 has[id] = null; 2981 watcher.run(); 2982 // in dev build, check and stop circular updates. 2983 if ("development" !== 'production' && has[id] != null) { 2984 circular[id] = (circular[id] || 0) + 1; 2985 if (circular[id] > MAX_UPDATE_COUNT) { 2986 warn( 2987 'You may have an infinite update loop ' + ( 2988 watcher.user ? 2989 ("in watcher with expression \"" + (watcher.expression) + "\"") : 2990 "in a component render function." 2991 ), 2992 watcher.vm 2993 ); 2994 break 2995 } 2996 } 2997 } 2998 2999 // keep copies of post queues before resetting state 3000 var activatedQueue = activatedChildren.slice(); 3001 var updatedQueue = queue.slice(); 3002 3003 resetSchedulerState(); 3004 3005 // call component updated and activated hooks 3006 callActivatedHooks(activatedQueue); 3007 callUpdatedHooks(updatedQueue); 3008 3009 // devtool hook 3010 /* istanbul ignore if */ 3011 if (devtools && config.devtools) { 3012 devtools.emit('flush'); 3013 } 3014 } 3015 3016 function callUpdatedHooks(queue) { 3017 var i = queue.length; 3018 while (i--) { 3019 var watcher = queue[i]; 3020 var vm = watcher.vm; 3021 if (vm._watcher === watcher && vm._isMounted) { 3022 callHook(vm, 'updated'); 3023 } 3024 } 3025 } 3026 3027 /** 3028 * Queue a kept-alive component that was activated during patch. 3029 * The queue will be processed after the entire tree has been patched. 3030 */ 3031 function queueActivatedComponent(vm) { 3032 // setting _inactive to false here so that a render function can 3033 // rely on checking whether it's in an inactive tree (e.g. router-view) 3034 vm._inactive = false; 3035 activatedChildren.push(vm); 3036 } 3037 3038 function callActivatedHooks(queue) { 3039 for (var i = 0; i < queue.length; i++) { 3040 queue[i]._inactive = true; 3041 activateChildComponent(queue[i], true /* true */ ); 3042 } 3043 } 3044 3045 /** 3046 * Push a watcher into the watcher queue. 3047 * Jobs with duplicate IDs will be skipped unless it's 3048 * pushed when the queue is being flushed. 3049 */ 3050 function queueWatcher(watcher) { 3051 var id = watcher.id; 3052 if (has[id] == null) { 3053 has[id] = true; 3054 if (!flushing) { 3055 queue.push(watcher); 3056 } else { 3057 // if already flushing, splice the watcher based on its id 3058 // if already past its id, it will be run next immediately. 3059 var i = queue.length - 1; 3060 while (i > index && queue[i].id > watcher.id) { 3061 i--; 3062 } 3063 queue.splice(i + 1, 0, watcher); 3064 } 3065 // queue the flush 3066 if (!waiting) { 3067 waiting = true; 3068 nextTick(flushSchedulerQueue); 3069 } 3070 } 3071 } 3072 3073 /* */ 3074 3075 var uid$1 = 0; 3076 3077 /** 3078 * A watcher parses an expression, collects dependencies, 3079 * and fires callback when the expression value changes. 3080 * This is used for both the $watch() api and directives. 3081 */ 3082 var Watcher = function Watcher( 3083 vm, 3084 expOrFn, 3085 cb, 3086 options, 3087 isRenderWatcher 3088 ) { 3089 this.vm = vm; 3090 if (isRenderWatcher) { 3091 vm._watcher = this; 3092 } 3093 vm._watchers.push(this); 3094 // options 3095 if (options) { 3096 this.deep = !!options.deep; 3097 this.user = !!options.user; 3098 this.lazy = !!options.lazy; 3099 this.sync = !!options.sync; 3100 } else { 3101 this.deep = this.user = this.lazy = this.sync = false; 3102 } 3103 this.cb = cb; 3104 this.id = ++uid$1; // uid for batching 3105 this.active = true; 3106 this.dirty = this.lazy; // for lazy watchers 3107 this.deps = []; 3108 this.newDeps = []; 3109 this.depIds = new _Set(); 3110 this.newDepIds = new _Set(); 3111 this.expression = expOrFn.toString(); 3112 // parse expression for getter 3113 if (typeof expOrFn === 'function') { 3114 this.getter = expOrFn; 3115 } else { 3116 this.getter = parsePath(expOrFn); 3117 if (!this.getter) { 3118 this.getter = function() {}; 3119 "development" !== 'production' && warn( 3120 "Failed watching path: \"" + expOrFn + "\" " + 3121 'Watcher only accepts simple dot-delimited paths. ' + 3122 'For full control, use a function instead.', 3123 vm 3124 ); 3125 } 3126 } 3127 this.value = this.lazy ? 3128 undefined : 3129 this.get(); 3130 }; 3131 3132 /** 3133 * Evaluate the getter, and re-collect dependencies. 3134 */ 3135 Watcher.prototype.get = function get() { 3136 pushTarget(this); 3137 var value; 3138 var vm = this.vm; 3139 try { 3140 value = this.getter.call(vm, vm); 3141 } catch (e) { 3142 if (this.user) { 3143 handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\"")); 3144 } else { 3145 throw e 3146 } 3147 } finally { 3148 // "touch" every property so they are all tracked as 3149 // dependencies for deep watching 3150 if (this.deep) { 3151 traverse(value); 3152 } 3153 popTarget(); 3154 this.cleanupDeps(); 3155 } 3156 return value 3157 }; 3158 3159 /** 3160 * Add a dependency to this directive. 3161 */ 3162 Watcher.prototype.addDep = function addDep(dep) { 3163 var id = dep.id; 3164 if (!this.newDepIds.has(id)) { 3165 this.newDepIds.add(id); 3166 this.newDeps.push(dep); 3167 if (!this.depIds.has(id)) { 3168 dep.addSub(this); 3169 } 3170 } 3171 }; 3172 3173 /** 3174 * Clean up for dependency collection. 3175 */ 3176 Watcher.prototype.cleanupDeps = function cleanupDeps() { 3177 var this$1 = this; 3178 3179 var i = this.deps.length; 3180 while (i--) { 3181 var dep = this$1.deps[i]; 3182 if (!this$1.newDepIds.has(dep.id)) { 3183 dep.removeSub(this$1); 3184 } 3185 } 3186 var tmp = this.depIds; 3187 this.depIds = this.newDepIds; 3188 this.newDepIds = tmp; 3189 this.newDepIds.clear(); 3190 tmp = this.deps; 3191 this.deps = this.newDeps; 3192 this.newDeps = tmp; 3193 this.newDeps.length = 0; 3194 }; 3195 3196 /** 3197 * Subscriber interface. 3198 * Will be called when a dependency changes. 3199 */
vendor: 1,661 bytes, lines 3200-3253
3200 Watcher.prototype.update = function update() { 3201 /* istanbul ignore else */ 3202 if (this.lazy) { 3203 this.dirty = true; 3204 } else if (this.sync) { 3205 this.run(); 3206 } else { 3207 queueWatcher(this); 3208 } 3209 }; 3210 3211 /** 3212 * Scheduler job interface. 3213 * Will be called by the scheduler. 3214 */ 3215 Watcher.prototype.run = function run() { 3216 if (this.active) { 3217 var value = this.get(); 3218 if ( 3219 value !== this.value || 3220 // Deep watchers and watchers on Object/Arrays should fire even 3221 // when the value is the same, because the value may 3222 // have mutated. 3223 isObject(value) || 3224 this.deep 3225 ) { 3226 // set new value 3227 var oldValue = this.value; 3228 this.value = value; 3229 if (this.user) { 3230 try { 3231 this.cb.call(this.vm, value, oldValue); 3232 } catch (e) { 3233 handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\"")); 3234 } 3235 } else { 3236 this.cb.call(this.vm, value, oldValue); 3237 } 3238 } 3239 } 3240 }; 3241 3242 /** 3243 * Evaluate the value of the watcher. 3244 * This only gets called for lazy watchers. 3245 */ 3246 Watcher.prototype.evaluate = function evaluate() { 3247 this.value = this.get(); 3248 this.dirty = false; 3249 }; 3250 3251 /** 3252 * Depend on all deps collected by this watcher. 3253 */
vendor: 8,992 bytes, lines 3254-3504
3254 Watcher.prototype.depend = function depend() { 3255 var this$1 = this; 3256 3257 var i = this.deps.length; 3258 while (i--) { 3259 this$1.deps[i].depend(); 3260 } 3261 }; 3262 3263 /** 3264 * Remove self from all dependencies' subscriber list. 3265 */ 3266 Watcher.prototype.teardown = function teardown() { 3267 var this$1 = this; 3268 3269 if (this.active) { 3270 // remove self from vm's watcher list 3271 // this is a somewhat expensive operation so we skip it 3272 // if the vm is being destroyed. 3273 if (!this.vm._isBeingDestroyed) { 3274 remove(this.vm._watchers, this); 3275 } 3276 var i = this.deps.length; 3277 while (i--) { 3278 this$1.deps[i].removeSub(this$1); 3279 } 3280 this.active = false; 3281 } 3282 }; 3283 3284 /* */ 3285 3286 var sharedPropertyDefinition = { 3287 enumerable: true, 3288 configurable: true, 3289 get: noop, 3290 set: noop 3291 }; 3292 3293 function proxy(target, sourceKey, key) { 3294 sharedPropertyDefinition.get = function proxyGetter() { 3295 return this[sourceKey][key] 3296 }; 3297 sharedPropertyDefinition.set = function proxySetter(val) { 3298 this[sourceKey][key] = val; 3299 }; 3300 Object.defineProperty(target, key, sharedPropertyDefinition); 3301 } 3302 3303 function initState(vm) { 3304 vm._watchers = []; 3305 var opts = vm.$options; 3306 if (opts.props) { initProps(vm, opts.props); } 3307 if (opts.methods) { initMethods(vm, opts.methods); } 3308 if (opts.data) { 3309 initData(vm); 3310 } else { 3311 observe(vm._data = {}, true /* asRootData */ ); 3312 } 3313 if (opts.computed) { initComputed(vm, opts.computed); } 3314 if (opts.watch && opts.watch !== nativeWatch) { 3315 initWatch(vm, opts.watch); 3316 } 3317 } 3318 3319 function initProps(vm, propsOptions) { 3320 var propsData = vm.$options.propsData || {}; 3321 var props = vm._props = {}; 3322 // cache prop keys so that future props updates can iterate using Array 3323 // instead of dynamic object key enumeration. 3324 var keys = vm.$options._propKeys = []; 3325 var isRoot = !vm.$parent; 3326 // root instance props should be converted 3327 if (!isRoot) { 3328 toggleObserving(false); 3329 } 3330 var loop = function(key) { 3331 keys.push(key); 3332 var value = validateProp(key, propsOptions, propsData, vm); 3333 /* istanbul ignore else */ 3334 { 3335 var hyphenatedKey = hyphenate(key); 3336 if (isReservedAttribute(hyphenatedKey) || 3337 config.isReservedAttr(hyphenatedKey)) { 3338 warn( 3339 ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."), 3340 vm 3341 ); 3342 } 3343 defineReactive(props, key, value, function() { 3344 if (vm.$parent && !isUpdatingChildComponent) { 3345 warn( 3346 "Avoid mutating a prop directly since the value will be " + 3347 "overwritten whenever the parent component re-renders. " + 3348 "Instead, use a data or computed property based on the prop's " + 3349 "value. Prop being mutated: \"" + key + "\"", 3350 vm 3351 ); 3352 } 3353 }); 3354 } 3355 // static props are already proxied on the component's prototype 3356 // during Vue.extend(). We only need to proxy props defined at 3357 // instantiation here. 3358 if (!(key in vm)) { 3359 proxy(vm, "_props", key); 3360 } 3361 }; 3362 3363 for (var key in propsOptions) loop(key); 3364 toggleObserving(true); 3365 } 3366 3367 function initData(vm) { 3368 var data = vm.$options.data; 3369 data = vm._data = typeof data === 'function' ? 3370 getData(data, vm) : 3371 data || {}; 3372 if (!isPlainObject(data)) { 3373 data = {}; 3374 "development" !== 'production' && warn( 3375 'data functions should return an object:\n' + 3376 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', 3377 vm 3378 ); 3379 } 3380 // proxy data on instance 3381 var keys = Object.keys(data); 3382 var props = vm.$options.props; 3383 var methods = vm.$options.methods; 3384 var i = keys.length; 3385 while (i--) { 3386 var key = keys[i]; { 3387 if (methods && hasOwn(methods, key)) { 3388 warn( 3389 ("Method \"" + key + "\" has already been defined as a data property."), 3390 vm 3391 ); 3392 } 3393 } 3394 if (props && hasOwn(props, key)) { 3395 "development" !== 'production' && warn( 3396 "The data property \"" + key + "\" is already declared as a prop. " + 3397 "Use prop default value instead.", 3398 vm 3399 ); 3400 } else if (!isReserved(key)) { 3401 proxy(vm, "_data", key); 3402 } 3403 } 3404 // observe data 3405 observe(data, true /* asRootData */ ); 3406 } 3407 3408 function getData(data, vm) { 3409 // #7573 disable dep collection when invoking data getters 3410 pushTarget(); 3411 try { 3412 return data.call(vm, vm) 3413 } catch (e) { 3414 handleError(e, vm, "data()"); 3415 return {} 3416 } finally { 3417 popTarget(); 3418 } 3419 } 3420 3421 var computedWatcherOptions = { lazy: true }; 3422 3423 function initComputed(vm, computed) { 3424 // $flow-disable-line 3425 var watchers = vm._computedWatchers = Object.create(null); 3426 // computed properties are just getters during SSR 3427 var isSSR = isServerRendering(); 3428 3429 for (var key in computed) { 3430 var userDef = computed[key]; 3431 var getter = typeof userDef === 'function' ? userDef : userDef.get; 3432 if ("development" !== 'production' && getter == null) { 3433 warn( 3434 ("Getter is missing for computed property \"" + key + "\"."), 3435 vm 3436 ); 3437 } 3438 3439 if (!isSSR) { 3440 // create internal watcher for the computed property. 3441 watchers[key] = new Watcher( 3442 vm, 3443 getter || noop, 3444 noop, 3445 computedWatcherOptions 3446 ); 3447 } 3448 3449 // component-defined computed properties are already defined on the 3450 // component prototype. We only need to define computed properties defined 3451 // at instantiation here. 3452 if (!(key in vm)) { 3453 defineComputed(vm, key, userDef); 3454 } else { 3455 if (key in vm.$data) { 3456 warn(("The computed property \"" + key + "\" is already defined in data."), vm); 3457 } else if (vm.$options.props && key in vm.$options.props) { 3458 warn(("The computed property \"" + key + "\" is already defined as a prop."), vm); 3459 } 3460 } 3461 } 3462 } 3463 3464 function defineComputed( 3465 target, 3466 key, 3467 userDef 3468 ) { 3469 var shouldCache = !isServerRendering(); 3470 if (typeof userDef === 'function') { 3471 sharedPropertyDefinition.get = shouldCache ? 3472 createComputedGetter(key) : 3473 userDef; 3474 sharedPropertyDefinition.set = noop; 3475 } else { 3476 sharedPropertyDefinition.get = userDef.get ? 3477 shouldCache && userDef.cache !== false ? 3478 createComputedGetter(key) : 3479 userDef.get : 3480 noop; 3481 sharedPropertyDefinition.set = userDef.set ? 3482 userDef.set : 3483 noop; 3484 } 3485 if ("development" !== 'production' && 3486 sharedPropertyDefinition.set === noop) { 3487 sharedPropertyDefinition.set = function() { 3488 warn( 3489 ("Computed property \"" + key + "\" was assigned to but it has no setter."), 3490 this 3491 ); 3492 }; 3493 } 3494 Object.defineProperty(target, key, sharedPropertyDefinition); 3495 } 3496 3497 function createComputedGetter(key) { 3498 return function computedGetter() { 3499 var watcher = this._computedWatchers && this._computedWatchers[key]; 3500 if (watcher) { 3501 if (watcher.dirty) { 3502 watcher.evaluate(); 3503 } 3504 if (Dep.target) {
3505 watcher.depend(); 3506 } 3507 return watcher.value 3508 } 3509 } 3510 } 3511 3512 function initMethods(vm, methods) { 3513 var props = vm.$options.props; 3514 for (var key in methods) { 3515 { 3516 if (methods[key] == null) { 3517 warn( 3518 "Method \"" + key + "\" has an undefined value in the component definition. " + 3519 "Did you reference the function correctly?", 3520 vm 3521 ); 3522 } 3523 if (props && hasOwn(props, key)) { 3524 warn( 3525 ("Method \"" + key + "\" has already been defined as a prop."), 3526 vm 3527 ); 3528 } 3529 if ((key in vm) && isReserved(key)) { 3530 warn( 3531 "Method \"" + key + "\" conflicts with an existing Vue instance method. " + 3532 "Avoid defining component methods that start with _ or $." 3533 ); 3534 } 3535 } 3536 vm[key] = methods[key] == null ? noop : bind(methods[key], vm); 3537 } 3538 } 3539 3540 function initWatch(vm, watch) { 3541 for (var key in watch) { 3542 var handler = watch[key]; 3543 if (Array.isArray(handler)) { 3544 for (var i = 0; i < handler.length; i++) { 3545 createWatcher(vm, key, handler[i]); 3546 } 3547 } else { 3548 createWatcher(vm, key, handler); 3549 } 3550 } 3551 } 3552 3553 function createWatcher( 3554 vm, 3555 expOrFn, 3556 handler, 3557 options 3558 ) { 3559 if (isPlainObject(handler)) { 3560 options = handler; 3561 handler = handler.handler; 3562 } 3563 if (typeof handler === 'string') { 3564 handler = vm[handler]; 3565 } 3566 return vm.$watch(expOrFn, handler, options) 3567 } 3568 3569 function stateMixin(Vue) { 3570 // flow somehow has problems with directly declared definition object 3571 // when using Object.defineProperty, so we have to procedurally build up 3572 // the object here. 3573 var dataDef = {}; 3574 dataDef.get = function() { return this._data }; 3575 var propsDef = {}; 3576 propsDef.get = function() { return this._props }; { 3577 dataDef.set = function(newData) { 3578 warn( 3579 'Avoid replacing instance root $data. ' + 3580 'Use nested data properties instead.', 3581 this 3582 ); 3583 }; 3584 propsDef.set = function() { 3585 warn("$props is readonly.", this); 3586 }; 3587 } 3588 Object.defineProperty(Vue.prototype, '$data', dataDef); 3589 Object.defineProperty(Vue.prototype, '$props', propsDef); 3590 3591 Vue.prototype.$set = set; 3592 Vue.prototype.$delete = del; 3593 3594 Vue.prototype.$watch = function( 3595 expOrFn, 3596 cb, 3597 options 3598 ) { 3599 var vm = this; 3600 if (isPlainObject(cb)) { 3601 return createWatcher(vm, expOrFn, cb, options) 3602 } 3603 options = options || {}; 3604 options.user = true; 3605 var watcher = new Watcher(vm, expOrFn, cb, options); 3606 if (options.immediate) { 3607 cb.call(vm, watcher.value); 3608 } 3609 return function unwatchFn() { 3610 watcher.teardown(); 3611 } 3612 }; 3613 } 3614 3615 /* */ 3616 3617 function initProvide(vm) { 3618 var provide = vm.$options.provide; 3619 if (provide) { 3620 vm._provided = typeof provide === 'function' ? 3621 provide.call(vm) : 3622 provide; 3623 } 3624 } 3625 3626 function initInjections(vm) { 3627 var result = resolveInject(vm.$options.inject, vm); 3628 if (result) { 3629 toggleObserving(false); 3630 Object.keys(result).forEach(function(key) { 3631 /* istanbul ignore else */ 3632 { 3633 defineReactive(vm, key, result[key], function() { 3634 warn( 3635 "Avoid mutating an injected value directly since the changes will be " + 3636 "overwritten whenever the provided component re-renders. " + 3637 "injection being mutated: \"" + key + "\"", 3638 vm 3639 ); 3640 }); 3641 } 3642 }); 3643 toggleObserving(true); 3644 } 3645 } 3646 3647 function resolveInject(inject, vm) { 3648 if (inject) { 3649 // inject is :any because flow is not smart enough to figure out cached 3650 var result = Object.create(null); 3651 var keys = hasSymbol ? 3652 Reflect.ownKeys(inject).filter(function(key) { 3653 /* istanbul ignore next */ 3654 return Object.getOwnPropertyDescriptor(inject, key).enumerable 3655 }) : 3656 Object.keys(inject); 3657 3658 for (var i = 0; i < keys.length; i++) { 3659 var key = keys[i]; 3660 var provideKey = inject[key].from; 3661 var source = vm; 3662 while (source) { 3663 if (source._provided && hasOwn(source._provided, provideKey)) { 3664 result[key] = source._provided[provideKey]; 3665 break 3666 } 3667 source = source.$parent; 3668 } 3669 if (!source) { 3670 if ('default' in inject[key]) { 3671 var provideDefault = inject[key].default; 3672 result[key] = typeof provideDefault === 'function' ? 3673 provideDefault.call(vm) : 3674 provideDefault; 3675 } else { 3676 warn(("Injection \"" + key + "\" not found"), vm); 3677 } 3678 } 3679 } 3680 return result 3681 } 3682 } 3683 3684 /* */ 3685 3686 /** 3687 * Runtime helper for rendering v-for lists. 3688 */ 3689 function renderList( 3690 val, 3691 render 3692 ) { 3693 var ret, i, l, keys, key; 3694 if (Array.isArray(val) || typeof val === 'string') { 3695 ret = new Array(val.length); 3696 for (i = 0, l = val.length; i < l; i++) { 3697 ret[i] = render(val[i], i); 3698 } 3699 } else if (typeof val === 'number') { 3700 ret = new Array(val); 3701 for (i = 0; i < val; i++) { 3702 ret[i] = render(i + 1, i); 3703 } 3704 } else if (isObject(val)) { 3705 keys = Object.keys(val); 3706 ret = new Array(keys.length);
3707 for (i = 0, l = keys.length; i < l; i++) { 3708 key = keys[i]; 3709 ret[i] = render(val[key], key, i); 3710 } 3711 } 3712 if (isDef(ret)) { 3713 (ret)._isVList = true; 3714 } 3715 return ret 3716 } 3717 3718 /* */ 3719 3720 /** 3721 * Runtime helper for rendering <slot> 3722 */ 3723 function renderSlot( 3724 name, 3725 fallback, 3726 props, 3727 bindObject 3728 ) { 3729 var scopedSlotFn = this.$scopedSlots[name]; 3730 var nodes; 3731 if (scopedSlotFn) { // scoped slot 3732 props = props || {}; 3733 if (bindObject) { 3734 if ("development" !== 'production' && !isObject(bindObject)) { 3735 warn( 3736 'slot v-bind without argument expects an Object', 3737 this 3738 ); 3739 } 3740 props = extend(extend({}, bindObject), props); 3741 } 3742 nodes = scopedSlotFn(props) || fallback; 3743 } else { 3744 var slotNodes = this.$slots[name]; 3745 // warn duplicate slot usage 3746 if (slotNodes) { 3747 if ("development" !== 'production' && slotNodes._rendered) { 3748 warn( 3749 "Duplicate presence of slot \"" + name + "\" found in the same render tree " + 3750 "- this will likely cause render errors.", 3751 this 3752 ); 3753 } 3754 slotNodes._rendered = true; 3755 } 3756 nodes = slotNodes || fallback; 3757 } 3758 3759 var target = props && props.slot; 3760 if (target) { 3761 return this.$createElement('template', { slot: target }, nodes) 3762 } else { 3763 return nodes 3764 } 3765 } 3766 3767 /* */ 3768 3769 /** 3770 * Runtime helper for resolving filters 3771 */ 3772 function resolveFilter(id) { 3773 return resolveAsset(this.$options, 'filters', id, true) || identity 3774 } 3775 3776 /* */ 3777 3778 function isKeyNotMatch(expect, actual) { 3779 if (Array.isArray(expect)) { 3780 return expect.indexOf(actual) === -1 3781 } else { 3782 return expect !== actual 3783 } 3784 } 3785 3786 /** 3787 * Runtime helper for checking keyCodes from config. 3788 * exposed as Vue.prototype._k 3789 * passing in eventKeyName as last argument separately for backwards compat 3790 */ 3791 function checkKeyCodes( 3792 eventKeyCode, 3793 key, 3794 builtInKeyCode, 3795 eventKeyName, 3796 builtInKeyName 3797 ) { 3798 var mappedKeyCode = config.keyCodes[key] || builtInKeyCode; 3799 if (builtInKeyName && eventKeyName && !config.keyCodes[key]) { 3800 return isKeyNotMatch(builtInKeyName, eventKeyName) 3801 } else if (mappedKeyCode) { 3802 return isKeyNotMatch(mappedKeyCode, eventKeyCode) 3803 } else if (eventKeyName) { 3804 return hyphenate(eventKeyName) !== key 3805 } 3806 } 3807 3808 /* */ 3809 3810 /** 3811 * Runtime helper for merging v-bind="object" into a VNode's data. 3812 */ 3813 function bindObjectProps( 3814 data, 3815 tag, 3816 value, 3817 asProp, 3818 isSync 3819 ) { 3820 if (value) { 3821 if (!isObject(value)) { 3822 "development" !== 'production' && warn( 3823 'v-bind without argument expects an Object or Array value', 3824 this 3825 ); 3826 } else { 3827 if (Array.isArray(value)) { 3828 value = toObject(value); 3829 } 3830 var hash; 3831 var loop = function(key) { 3832 if ( 3833 key === 'class' || 3834 key === 'style' || 3835 isReservedAttribute(key) 3836 ) { 3837 hash = data; 3838 } else { 3839 var type = data.attrs && data.attrs.type; 3840 hash = asProp || config.mustUseProp(tag, type, key) ? 3841 data.domProps || (data.domProps = {}) : 3842 data.attrs || (data.attrs = {}); 3843 } 3844 if (!(key in hash)) { 3845 hash[key] = value[key]; 3846 3847 if (isSync) { 3848 var on = data.on || (data.on = {}); 3849 on[("update:" + key)] = function($event) { 3850 value[key] = $event; 3851 }; 3852 } 3853 } 3854 }; 3855 3856 for (var key in value) loop(key); 3857 } 3858 } 3859 return data 3860 } 3861 3862 /* */ 3863 3864 /** 3865 * Runtime helper for rendering static trees. 3866 */
vendor: 7,583 bytes, lines 3867-4106
3867 function renderStatic( 3868 index, 3869 isInFor 3870 ) { 3871 var cached = this._staticTrees || (this._staticTrees = []); 3872 var tree = cached[index]; 3873 // if has already-rendered static tree and not inside v-for, 3874 // we can reuse the same tree. 3875 if (tree && !isInFor) { 3876 return tree 3877 } 3878 // otherwise, render a fresh tree. 3879 tree = cached[index] = this.$options.staticRenderFns[index].call( 3880 this._renderProxy, 3881 null, 3882 this // for render fns generated for functional component templates 3883 ); 3884 markStatic(tree, ("__static__" + index), false); 3885 return tree 3886 } 3887 3888 /** 3889 * Runtime helper for v-once. 3890 * Effectively it means marking the node as static with a unique key. 3891 */ 3892 function markOnce( 3893 tree, 3894 index, 3895 key 3896 ) { 3897 markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true); 3898 return tree 3899 } 3900 3901 function markStatic( 3902 tree, 3903 key, 3904 isOnce 3905 ) { 3906 if (Array.isArray(tree)) { 3907 for (var i = 0; i < tree.length; i++) { 3908 if (tree[i] && typeof tree[i] !== 'string') { 3909 markStaticNode(tree[i], (key + "_" + i), isOnce); 3910 } 3911 } 3912 } else { 3913 markStaticNode(tree, key, isOnce); 3914 } 3915 } 3916 3917 function markStaticNode(node, key, isOnce) { 3918 node.isStatic = true; 3919 node.key = key; 3920 node.isOnce = isOnce; 3921 } 3922 3923 /* */ 3924 3925 function bindObjectListeners(data, value) { 3926 if (value) { 3927 if (!isPlainObject(value)) { 3928 "development" !== 'production' && warn( 3929 'v-on without argument expects an Object value', 3930 this 3931 ); 3932 } else { 3933 var on = data.on = data.on ? extend({}, data.on) : {}; 3934 for (var key in value) { 3935 var existing = on[key]; 3936 var ours = value[key]; 3937 on[key] = existing ? [].concat(existing, ours) : ours; 3938 } 3939 } 3940 } 3941 return data 3942 } 3943 3944 /* */ 3945 3946 function installRenderHelpers(target) { 3947 target._o = markOnce; 3948 target._n = toNumber; 3949 target._s = toString; 3950 target._l = renderList; 3951 target._t = renderSlot; 3952 target._q = looseEqual; 3953 target._i = looseIndexOf; 3954 target._m = renderStatic; 3955 target._f = resolveFilter; 3956 target._k = checkKeyCodes; 3957 target._b = bindObjectProps; 3958 target._v = createTextVNode; 3959 target._e = createEmptyVNode; 3960 target._u = resolveScopedSlots; 3961 target._g = bindObjectListeners; 3962 } 3963 3964 /* */ 3965 3966 function FunctionalRenderContext( 3967 data, 3968 props, 3969 children, 3970 parent, 3971 Ctor 3972 ) { 3973 var options = Ctor.options; 3974 // ensure the createElement function in functional components 3975 // gets a unique context - this is necessary for correct named slot check 3976 var contextVm; 3977 if (hasOwn(parent, '_uid')) { 3978 contextVm = Object.create(parent); 3979 // $flow-disable-line 3980 contextVm._original = parent; 3981 } else { 3982 // the context vm passed in is a functional context as well. 3983 // in this case we want to make sure we are able to get a hold to the 3984 // real context instance. 3985 contextVm = parent; 3986 // $flow-disable-line 3987 parent = parent._original; 3988 } 3989 var isCompiled = isTrue(options._compiled); 3990 var needNormalization = !isCompiled; 3991 3992 this.data = data; 3993 this.props = props; 3994 this.children = children; 3995 this.parent = parent; 3996 this.listeners = data.on || emptyObject; 3997 this.injections = resolveInject(options.inject, parent); 3998 this.slots = function() { return resolveSlots(children, parent); }; 3999 4000 // support for compiled functional template 4001 if (isCompiled) { 4002 // exposing $options for renderStatic() 4003 this.$options = options; 4004 // pre-resolve slots for renderSlot() 4005 this.$slots = this.slots(); 4006 this.$scopedSlots = data.scopedSlots || emptyObject; 4007 } 4008 4009 if (options._scopeId) { 4010 this._c = function(a, b, c, d) { 4011 var vnode = createElement(contextVm, a, b, c, d, needNormalization); 4012 if (vnode && !Array.isArray(vnode)) { 4013 vnode.fnScopeId = options._scopeId; 4014 vnode.fnContext = parent; 4015 } 4016 return vnode 4017 }; 4018 } else { 4019 this._c = function(a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); }; 4020 } 4021 } 4022 4023 installRenderHelpers(FunctionalRenderContext.prototype); 4024 4025 function createFunctionalComponent( 4026 Ctor, 4027 propsData, 4028 data, 4029 contextVm, 4030 children 4031 ) { 4032 var options = Ctor.options; 4033 var props = {}; 4034 var propOptions = options.props; 4035 if (isDef(propOptions)) { 4036 for (var key in propOptions) { 4037 props[key] = validateProp(key, propOptions, propsData || emptyObject); 4038 } 4039 } else { 4040 if (isDef(data.attrs)) { mergeProps(props, data.attrs); } 4041 if (isDef(data.props)) { mergeProps(props, data.props); } 4042 } 4043 4044 var renderContext = new FunctionalRenderContext( 4045 data, 4046 props, 4047 children, 4048 contextVm, 4049 Ctor 4050 ); 4051 4052 var vnode = options.render.call(null, renderContext._c, renderContext); 4053 4054 if (vnode instanceof VNode) { 4055 return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options) 4056 } else if (Array.isArray(vnode)) { 4057 var vnodes = normalizeChildren(vnode) || []; 4058 var res = new Array(vnodes.length); 4059 for (var i = 0; i < vnodes.length; i++) { 4060 res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options); 4061 } 4062 return res 4063 } 4064 } 4065 4066 function cloneAndMarkFunctionalResult(vnode, data, contextVm, options) { 4067 // #7817 clone node before setting fnContext, otherwise if the node is reused 4068 // (e.g. it was from a cached normal slot) the fnContext causes named slots 4069 // that should not be matched to match. 4070 var clone = cloneVNode(vnode); 4071 clone.fnContext = contextVm; 4072 clone.fnOptions = options; 4073 if (data.slot) { 4074 (clone.data || (clone.data = {})).slot = data.slot; 4075 } 4076 return clone 4077 } 4078 4079 function mergeProps(to, from) { 4080 for (var key in from) { 4081 to[camelize(key)] = from[key]; 4082 } 4083 } 4084 4085 /* */ 4086 4087 4088 4089 4090 // Register the component hook to weex native render engine. 4091 // The hook will be triggered by native, not javascript. 4092 4093 4094 // Updates the state of the component to weex native render engine. 4095 4096 /* */ 4097 4098 // https://github.com/Hanks10100/weex-native-directive/tree/master/component 4099 4100 // listening on native callback 4101 4102 /* */ 4103 4104 /* */ 4105 4106 // inline hooks to be invoked on component VNodes during patch
vendor: 11,654 bytes, lines 4107-4428
4107 var componentVNodeHooks = { 4108 init: function init( 4109 vnode, 4110 hydrating, 4111 parentElm, 4112 refElm 4113 ) { 4114 if ( 4115 vnode.componentInstance && 4116 !vnode.componentInstance._isDestroyed && 4117 vnode.data.keepAlive 4118 ) { 4119 // kept-alive components, treat as a patch 4120 var mountedNode = vnode; // work around flow 4121 componentVNodeHooks.prepatch(mountedNode, mountedNode); 4122 } else { 4123 var child = vnode.componentInstance = createComponentInstanceForVnode( 4124 vnode, 4125 activeInstance, 4126 parentElm, 4127 refElm 4128 ); 4129 child.$mount(hydrating ? vnode.elm : undefined, hydrating); 4130 } 4131 }, 4132 4133 prepatch: function prepatch(oldVnode, vnode) { 4134 var options = vnode.componentOptions; 4135 var child = vnode.componentInstance = oldVnode.componentInstance; 4136 updateChildComponent( 4137 child, 4138 options.propsData, // updated props 4139 options.listeners, // updated listeners 4140 vnode, // new parent vnode 4141 options.children // new children 4142 ); 4143 }, 4144 4145 insert: function insert(vnode) { 4146 var context = vnode.context; 4147 var componentInstance = vnode.componentInstance; 4148 if (!componentInstance._isMounted) { 4149 componentInstance._isMounted = true; 4150 callHook(componentInstance, 'mounted'); 4151 } 4152 if (vnode.data.keepAlive) { 4153 if (context._isMounted) { 4154 // vue-router#1212 4155 // During updates, a kept-alive component's child components may 4156 // change, so directly walking the tree here may call activated hooks 4157 // on incorrect children. Instead we push them into a queue which will 4158 // be processed after the whole patch process ended. 4159 queueActivatedComponent(componentInstance); 4160 } else { 4161 activateChildComponent(componentInstance, true /* direct */ ); 4162 } 4163 } 4164 }, 4165 4166 destroy: function destroy(vnode) { 4167 var componentInstance = vnode.componentInstance; 4168 if (!componentInstance._isDestroyed) { 4169 if (!vnode.data.keepAlive) { 4170 componentInstance.$destroy(); 4171 } else { 4172 deactivateChildComponent(componentInstance, true /* direct */ ); 4173 } 4174 } 4175 } 4176 }; 4177 4178 var hooksToMerge = Object.keys(componentVNodeHooks); 4179 4180 function createComponent( 4181 Ctor, 4182 data, 4183 context, 4184 children, 4185 tag 4186 ) { 4187 if (isUndef(Ctor)) { 4188 return 4189 } 4190 4191 var baseCtor = context.$options._base; 4192 4193 // plain options object: turn it into a constructor 4194 if (isObject(Ctor)) { 4195 Ctor = baseCtor.extend(Ctor); 4196 } 4197 4198 // if at this stage it's not a constructor or an async component factory, 4199 // reject. 4200 if (typeof Ctor !== 'function') { 4201 { 4202 warn(("Invalid Component definition: " + (String(Ctor))), context); 4203 } 4204 return 4205 } 4206 4207 // async component 4208 var asyncFactory; 4209 if (isUndef(Ctor.cid)) { 4210 asyncFactory = Ctor; 4211 Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context); 4212 if (Ctor === undefined) { 4213 // return a placeholder node for async component, which is rendered 4214 // as a comment node but preserves all the raw information for the node. 4215 // the information will be used for async server-rendering and hydration. 4216 return createAsyncPlaceholder( 4217 asyncFactory, 4218 data, 4219 context, 4220 children, 4221 tag 4222 ) 4223 } 4224 } 4225 4226 data = data || {}; 4227 4228 // resolve constructor options in case global mixins are applied after 4229 // component constructor creation 4230 resolveConstructorOptions(Ctor); 4231 4232 // transform component v-model data into props & events 4233 if (isDef(data.model)) { 4234 transformModel(Ctor.options, data); 4235 } 4236 4237 // extract props 4238 var propsData = extractPropsFromVNodeData(data, Ctor, tag); 4239 4240 // functional component 4241 if (isTrue(Ctor.options.functional)) { 4242 return createFunctionalComponent(Ctor, propsData, data, context, children) 4243 } 4244 4245 // extract listeners, since these needs to be treated as 4246 // child component listeners instead of DOM listeners 4247 var listeners = data.on; 4248 // replace with listeners with .native modifier 4249 // so it gets processed during parent component patch. 4250 data.on = data.nativeOn; 4251 4252 if (isTrue(Ctor.options.abstract)) { 4253 // abstract components do not keep anything 4254 // other than props & listeners & slot 4255 4256 // work around flow 4257 var slot = data.slot; 4258 data = {}; 4259 if (slot) { 4260 data.slot = slot; 4261 } 4262 } 4263 4264 // install component management hooks onto the placeholder node 4265 installComponentHooks(data); 4266 4267 // return a placeholder vnode 4268 var name = Ctor.options.name || tag; 4269 var vnode = new VNode( 4270 ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')), 4271 data, undefined, undefined, undefined, context, { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }, 4272 asyncFactory 4273 ); 4274 4275 // Weex specific: invoke recycle-list optimized @render function for 4276 // extracting cell-slot template. 4277 // https://github.com/Hanks10100/weex-native-directive/tree/master/component 4278 /* istanbul ignore if */ 4279 return vnode 4280 } 4281 4282 function createComponentInstanceForVnode( 4283 vnode, // we know it's MountedComponentVNode but flow doesn't 4284 parent, // activeInstance in lifecycle state 4285 parentElm, 4286 refElm 4287 ) { 4288 var options = { 4289 _isComponent: true, 4290 parent: parent, 4291 _parentVnode: vnode, 4292 _parentElm: parentElm || null, 4293 _refElm: refElm || null 4294 }; 4295 // check inline-template render functions 4296 var inlineTemplate = vnode.data.inlineTemplate; 4297 if (isDef(inlineTemplate)) { 4298 options.render = inlineTemplate.render; 4299 options.staticRenderFns = inlineTemplate.staticRenderFns; 4300 } 4301 return new vnode.componentOptions.Ctor(options) 4302 } 4303 4304 function installComponentHooks(data) { 4305 var hooks = data.hook || (data.hook = {}); 4306 for (var i = 0; i < hooksToMerge.length; i++) { 4307 var key = hooksToMerge[i]; 4308 hooks[key] = componentVNodeHooks[key]; 4309 } 4310 } 4311 4312 // transform component v-model info (value and callback) into 4313 // prop and event handler respectively. 4314 function transformModel(options, data) { 4315 var prop = (options.model && options.model.prop) || 'value'; 4316 var event = (options.model && options.model.event) || 'input'; 4317 (data.props || (data.props = {}))[prop] = data.model.value; 4318 var on = data.on || (data.on = {}); 4319 if (isDef(on[event])) { 4320 on[event] = [data.model.callback].concat(on[event]); 4321 } else { 4322 on[event] = data.model.callback; 4323 } 4324 } 4325 4326 /* */ 4327 4328 var SIMPLE_NORMALIZE = 1; 4329 var ALWAYS_NORMALIZE = 2; 4330 4331 // wrapper function for providing a more flexible interface 4332 // without getting yelled at by flow 4333 function createElement( 4334 context, 4335 tag, 4336 data, 4337 children, 4338 normalizationType, 4339 alwaysNormalize 4340 ) { 4341 if (Array.isArray(data) || isPrimitive(data)) { 4342 normalizationType = children; 4343 children = data; 4344 data = undefined; 4345 } 4346 if (isTrue(alwaysNormalize)) { 4347 normalizationType = ALWAYS_NORMALIZE; 4348 } 4349 return _createElement(context, tag, data, children, normalizationType) 4350 } 4351 4352 function _createElement( 4353 context, 4354 tag, 4355 data, 4356 children, 4357 normalizationType 4358 ) { 4359 if (isDef(data) && isDef((data).__ob__)) { 4360 "development" !== 'production' && warn( 4361 "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" + 4362 'Always create fresh vnode data objects in each render!', 4363 context 4364 ); 4365 return createEmptyVNode() 4366 } 4367 // object syntax in v-bind 4368 if (isDef(data) && isDef(data.is)) { 4369 tag = data.is; 4370 } 4371 if (!tag) { 4372 // in case of component :is set to falsy value 4373 return createEmptyVNode() 4374 } 4375 // warn against non-primitive key 4376 if ("development" !== 'production' && 4377 isDef(data) && isDef(data.key) && !isPrimitive(data.key) 4378 ) { 4379 { 4380 warn( 4381 'Avoid using non-primitive value as key, ' + 4382 'use string/number value instead.', 4383 context 4384 ); 4385 } 4386 } 4387 // support single function children as default scoped slot 4388 if (Array.isArray(children) && 4389 typeof children[0] === 'function' 4390 ) { 4391 data = data || {}; 4392 data.scopedSlots = { default: children[0] }; 4393 children.length = 0; 4394 } 4395 if (normalizationType === ALWAYS_NORMALIZE) { 4396 children = normalizeChildren(children); 4397 } else if (normalizationType === SIMPLE_NORMALIZE) { 4398 children = simpleNormalizeChildren(children); 4399 } 4400 var vnode, ns; 4401 if (typeof tag === 'string') { 4402 var Ctor; 4403 ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag); 4404 if (config.isReservedTag(tag)) { 4405 // platform built-in elements 4406 vnode = new VNode( 4407 config.parsePlatformTagName(tag), data, children, 4408 undefined, undefined, context 4409 ); 4410 } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) { 4411 // component 4412 vnode = createComponent(Ctor, data, context, children, tag); 4413 } else { 4414 // unknown or unlisted namespaced elements 4415 // check at runtime because it may get assigned a namespace when its 4416 // parent normalizes children 4417 vnode = new VNode( 4418 tag, data, children, 4419 undefined, undefined, context 4420 ); 4421 } 4422 } else { 4423 // direct component options / constructor 4424 vnode = createComponent(tag, data, context, children); 4425 } 4426 if (Array.isArray(vnode)) { 4427 return vnode 4428 }
4428 else if (isDef(vnode)) { 4429 if (isDef(ns)) { applyNS(vnode, ns); } 4430 if (isDef(data)) { registerDeepBindings(data); } 4431 return vnode 4432 } else { 4433 return createEmptyVNode() 4434 } 4435 } 4436 4437 function applyNS(vnode, ns, force) { 4438 vnode.ns = ns; 4439 if (vnode.tag === 'foreignObject') { 4440 // use default namespace inside foreignObject 4441 ns = undefined; 4442 force = true; 4443 } 4444 if (isDef(vnode.children)) { 4445 for (var i = 0, l = vnode.children.length; i < l; i++) { 4446 var child = vnode.children[i]; 4447 if (isDef(child.tag) && ( 4448 isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) { 4449 applyNS(child, ns, force); 4450 } 4451 } 4452 } 4453 } 4454 4455 // ref #5318 4456 // necessary to ensure parent re-render when deep bindings like :style and 4457 // :class are used on slot nodes 4458 function registerDeepBindings(data) { 4459 if (isObject(data.style)) { 4460 traverse(data.style); 4461 } 4462 if (isObject(data.class)) { 4463 traverse(data.class); 4464 } 4465 } 4466 4467 /* */ 4468 4469 function initRender(vm) { 4470 vm._vnode = null; // the root of the child tree 4471 vm._staticTrees = null; // v-once cached trees 4472 var options = vm.$options; 4473 var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree 4474 var renderContext = parentVnode && parentVnode.context; 4475 vm.$slots = resolveSlots(options._renderChildren, renderContext); 4476 vm.$scopedSlots = emptyObject; 4477 // bind the createElement fn to this instance 4478 // so that we get proper render context inside it. 4479 // args order: tag, data, children, normalizationType, alwaysNormalize 4480 // internal version is used by render functions compiled from templates 4481 vm._c = function(a, b, c, d) { return createElement(vm, a, b, c, d, false); }; 4482 // normalization is always applied for the public version, used in 4483 // user-written render functions. 4484 vm.$createElement = function(a, b, c, d) { return createElement(vm, a, b, c, d, true); }; 4485 4486 // $attrs & $listeners are exposed for easier HOC creation. 4487 // they need to be reactive so that HOCs using them are always updated 4488 var parentData = parentVnode && parentVnode.data; 4489 4490 /* istanbul ignore else */ 4491 { 4492 defineReactive(vm, '$attrs', parentData && parentData.attrs || emptyObject, function() { 4493 !isUpdatingChildComponent && warn("$attrs is readonly.", vm); 4494 }, true); 4495 defineReactive(vm, '$listeners', options._parentListeners || emptyObject, function() { 4496 !isUpdatingChildComponent && warn("$listeners is readonly.", vm); 4497 }, true); 4498 } 4499 } 4500 4501 function renderMixin(Vue) { 4502 // install runtime convenience helpers 4503 installRenderHelpers(Vue.prototype); 4504 4505 Vue.prototype.$nextTick = function(fn) { 4506 return nextTick(fn, this) 4507 }; 4508 4509 Vue.prototype._render = function() { 4510 var vm = this; 4511 var ref = vm.$options; 4512 var render = ref.render; 4513 var _parentVnode = ref._parentVnode; 4514 4515 // reset _rendered flag on slots for duplicate slot check 4516 { 4517 for (var key in vm.$slots) { 4518 // $flow-disable-line 4519 vm.$slots[key]._rendered = false; 4520 } 4521 } 4522 4523 if (_parentVnode) { 4524 vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject; 4525 } 4526 4527 // set parent vnode. this allows render functions to have access 4528 // to the data on the placeholder node. 4529 vm.$vnode = _parentVnode; 4530 // render self 4531 var vnode; 4532 try { 4533 vnode = render.call(vm._renderProxy, vm.$createElement); 4534 } catch (e) { 4535 handleError(e, vm, "render"); 4536 // return error render result, 4537 // or previous vnode to prevent render error causing blank component 4538 /* istanbul ignore else */ 4539 { 4540 if (vm.$options.renderError) { 4541 try { 4542 vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e); 4543 } catch (e) { 4544 handleError(e, vm, "renderError"); 4545 vnode = vm._vnode; 4546 } 4547 } else { 4548 vnode = vm._vnode; 4549 } 4550 } 4551 } 4552 // return empty vnode in case the render function errored out 4553 if (!(vnode instanceof VNode)) { 4554 if ("development" !== 'production' && Array.isArray(vnode)) { 4555 warn( 4556 'Multiple root nodes returned from render function. Render function ' + 4557 'should return a single root node.', 4558 vm 4559 ); 4560 } 4561 vnode = createEmptyVNode(); 4562 } 4563 // set parent 4564 vnode.parent = _parentVnode; 4565 return vnode 4566 }; 4567 } 4568 4569 /* */ 4570 4571 var uid$3 = 0; 4572 4573 function initMixin(Vue) { 4574 Vue.prototype._init = function(options) { 4575 var vm = this; 4576 // a uid 4577 vm._uid = uid$3++; 4578 4579 var startTag, endTag; 4580 /* istanbul ignore if */ 4581 if ("development" !== 'production' && config.performance && mark) { 4582 startTag = "vue-perf-start:" + (vm._uid); 4583 endTag = "vue-perf-end:" + (vm._uid); 4584 mark(startTag); 4585 } 4586 4587 // a flag to avoid this being observed 4588 vm._isVue = true; 4589 // merge options 4590 if (options && options._isComponent) {
vendor: 5,505 bytes, lines 4591-4737
4591 // optimize internal component instantiation 4592 // since dynamic options merging is pretty slow, and none of the 4593 // internal component options needs special treatment. 4594 initInternalComponent(vm, options); 4595 } else { 4596 vm.$options = mergeOptions( 4597 resolveConstructorOptions(vm.constructor), 4598 options || {}, 4599 vm 4600 ); 4601 } 4602 /* istanbul ignore else */ 4603 { 4604 initProxy(vm); 4605 } 4606 // expose real self 4607 vm._self = vm; 4608 initLifecycle(vm); 4609 initEvents(vm); 4610 initRender(vm); 4611 callHook(vm, 'beforeCreate'); 4612 initInjections(vm); // resolve injections before data/props 4613 initState(vm); 4614 initProvide(vm); // resolve provide after data/props 4615 callHook(vm, 'created'); 4616 4617 /* istanbul ignore if */ 4618 if ("development" !== 'production' && config.performance && mark) { 4619 vm._name = formatComponentName(vm, false); 4620 mark(endTag); 4621 measure(("vue " + (vm._name) + " init"), startTag, endTag); 4622 } 4623 4624 if (vm.$options.el) { 4625 vm.$mount(vm.$options.el); 4626 } 4627 }; 4628 } 4629 4630 function initInternalComponent(vm, options) { 4631 var opts = vm.$options = Object.create(vm.constructor.options); 4632 // doing this because it's faster than dynamic enumeration. 4633 var parentVnode = options._parentVnode; 4634 opts.parent = options.parent; 4635 opts._parentVnode = parentVnode; 4636 opts._parentElm = options._parentElm; 4637 opts._refElm = options._refElm; 4638 4639 var vnodeComponentOptions = parentVnode.componentOptions; 4640 opts.propsData = vnodeComponentOptions.propsData; 4641 opts._parentListeners = vnodeComponentOptions.listeners; 4642 opts._renderChildren = vnodeComponentOptions.children; 4643 opts._componentTag = vnodeComponentOptions.tag; 4644 4645 if (options.render) { 4646 opts.render = options.render; 4647 opts.staticRenderFns = options.staticRenderFns; 4648 } 4649 } 4650 4651 function resolveConstructorOptions(Ctor) { 4652 var options = Ctor.options; 4653 if (Ctor.super) { 4654 var superOptions = resolveConstructorOptions(Ctor.super); 4655 var cachedSuperOptions = Ctor.superOptions; 4656 if (superOptions !== cachedSuperOptions) { 4657 // super option changed, 4658 // need to resolve new options. 4659 Ctor.superOptions = superOptions; 4660 // check if there are any late-modified/attached options (#4976) 4661 var modifiedOptions = resolveModifiedOptions(Ctor); 4662 // update base extend options 4663 if (modifiedOptions) { 4664 extend(Ctor.extendOptions, modifiedOptions); 4665 } 4666 options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions); 4667 if (options.name) { 4668 options.components[options.name] = Ctor; 4669 } 4670 } 4671 } 4672 return options 4673 } 4674 4675 function resolveModifiedOptions(Ctor) { 4676 var modified; 4677 var latest = Ctor.options; 4678 var extended = Ctor.extendOptions; 4679 var sealed = Ctor.sealedOptions; 4680 for (var key in latest) { 4681 if (latest[key] !== sealed[key]) { 4682 if (!modified) { modified = {}; } 4683 modified[key] = dedupe(latest[key], extended[key], sealed[key]); 4684 } 4685 } 4686 return modified 4687 } 4688 4689 function dedupe(latest, extended, sealed) { 4690 // compare latest and sealed to ensure lifecycle hooks won't be duplicated 4691 // between merges 4692 if (Array.isArray(latest)) { 4693 var res = []; 4694 sealed = Array.isArray(sealed) ? sealed : [sealed]; 4695 extended = Array.isArray(extended) ? extended : [extended]; 4696 for (var i = 0; i < latest.length; i++) { 4697 // push original options and not sealed options to exclude duplicated options 4698 if (extended.indexOf(latest[i]) >= 0 || sealed.indexOf(latest[i]) < 0) { 4699 res.push(latest[i]); 4700 } 4701 } 4702 return res 4703 } else { 4704 return latest 4705 } 4706 } 4707 4708 function Vue(options) { 4709 if ("development" !== 'production' && 4710 !(this instanceof Vue) 4711 ) { 4712 warn('Vue is a constructor and should be called with the `new` keyword'); 4713 } 4714 this._init(options); 4715 } 4716 4717 initMixin(Vue); 4718 stateMixin(Vue); 4719 eventsMixin(Vue); 4720 lifecycleMixin(Vue); 4721 renderMixin(Vue); 4722 4723 /* */ 4724 4725 function initUse(Vue) { 4726 Vue.use = function(plugin) { 4727 var installedPlugins = (this._installedPlugins || (this._installedPlugins = [])); 4728 if (installedPlugins.indexOf(plugin) > -1) { 4729 return this 4730 } 4731 4732 // additional parameters 4733 var args = toArray(arguments, 1); 4734 args.unshift(this); 4735 if (typeof plugin.install === 'function') { 4736 plugin.install.apply(plugin, args); 4737 } else if (typeof plugin === 'function') {
vendor: 2,951 bytes, lines 4738-4825
4738 plugin.apply(null, args); 4739 } 4740 installedPlugins.push(plugin); 4741 return this 4742 }; 4743 } 4744 4745 /* */ 4746 4747 function initMixin$1(Vue) { 4748 Vue.mixin = function(mixin) { 4749 this.options = mergeOptions(this.options, mixin); 4750 return this 4751 }; 4752 } 4753 4754 /* */ 4755 4756 function initExtend(Vue) { 4757 /** 4758 * Each instance constructor, including Vue, has a unique 4759 * cid. This enables us to create wrapped "child 4760 * constructors" for prototypal inheritance and cache them. 4761 */ 4762 Vue.cid = 0; 4763 var cid = 1; 4764 4765 /** 4766 * Class inheritance 4767 */ 4768 Vue.extend = function(extendOptions) { 4769 extendOptions = extendOptions || {}; 4770 var Super = this; 4771 var SuperId = Super.cid; 4772 var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {}); 4773 if (cachedCtors[SuperId]) { 4774 return cachedCtors[SuperId] 4775 } 4776 4777 var name = extendOptions.name || Super.options.name; 4778 if ("development" !== 'production' && name) { 4779 validateComponentName(name); 4780 } 4781 4782 var Sub = function VueComponent(options) { 4783 this._init(options); 4784 }; 4785 Sub.prototype = Object.create(Super.prototype); 4786 Sub.prototype.constructor = Sub; 4787 Sub.cid = cid++; 4788 Sub.options = mergeOptions( 4789 Super.options, 4790 extendOptions 4791 ); 4792 Sub['super'] = Super; 4793 4794 // For props and computed properties, we define the proxy getters on 4795 // the Vue instances at extension time, on the extended prototype. This 4796 // avoids Object.defineProperty calls for each instance created. 4797 if (Sub.options.props) { 4798 initProps$1(Sub); 4799 } 4800 if (Sub.options.computed) { 4801 initComputed$1(Sub); 4802 } 4803 4804 // allow further extension/mixin/plugin usage 4805 Sub.extend = Super.extend; 4806 Sub.mixin = Super.mixin; 4807 Sub.use = Super.use; 4808 4809 // create asset registers, so extended classes 4810 // can have their private assets too. 4811 ASSET_TYPES.forEach(function(type) { 4812 Sub[type] = Super[type]; 4813 }); 4814 // enable recursive self-lookup 4815 if (name) { 4816 Sub.options.components[name] = Sub; 4817 } 4818 4819 // keep a reference to the super options at extension time. 4820 // later at instantiation we can check if Super's options have 4821 // been updated. 4822 Sub.superOptions = Super.options; 4823 Sub.extendOptions = extendOptions; 4824 Sub.sealedOptions = extend({}, Sub.options); 4825
vendor: 5,379 bytes, lines 4826-4989
4826 // cache constructor 4827 cachedCtors[SuperId] = Sub; 4828 return Sub 4829 }; 4830 } 4831 4832 function initProps$1(Comp) { 4833 var props = Comp.options.props; 4834 for (var key in props) { 4835 proxy(Comp.prototype, "_props", key); 4836 } 4837 } 4838 4839 function initComputed$1(Comp) { 4840 var computed = Comp.options.computed; 4841 for (var key in computed) { 4842 defineComputed(Comp.prototype, key, computed[key]); 4843 } 4844 } 4845 4846 /* */ 4847 4848 function initAssetRegisters(Vue) { 4849 /** 4850 * Create asset registration methods. 4851 */ 4852 ASSET_TYPES.forEach(function(type) { 4853 Vue[type] = function( 4854 id, 4855 definition 4856 ) { 4857 if (!definition) { 4858 return this.options[type + 's'][id] 4859 } else { 4860 /* istanbul ignore if */ 4861 if ("development" !== 'production' && type === 'component') { 4862 validateComponentName(id); 4863 } 4864 if (type === 'component' && isPlainObject(definition)) { 4865 definition.name = definition.name || id; 4866 definition = this.options._base.extend(definition); 4867 } 4868 if (type === 'directive' && typeof definition === 'function') { 4869 definition = { bind: definition, update: definition }; 4870 } 4871 this.options[type + 's'][id] = definition; 4872 return definition 4873 } 4874 }; 4875 }); 4876 } 4877 4878 /* */ 4879 4880 function getComponentName(opts) { 4881 return opts && (opts.Ctor.options.name || opts.tag) 4882 } 4883 4884 function matches(pattern, name) { 4885 if (Array.isArray(pattern)) { 4886 return pattern.indexOf(name) > -1 4887 } else if (typeof pattern === 'string') { 4888 return pattern.split(',').indexOf(name) > -1 4889 } else if (isRegExp(pattern)) { 4890 return pattern.test(name) 4891 } 4892 /* istanbul ignore next */ 4893 return false 4894 } 4895 4896 function pruneCache(keepAliveInstance, filter) { 4897 var cache = keepAliveInstance.cache; 4898 var keys = keepAliveInstance.keys; 4899 var _vnode = keepAliveInstance._vnode; 4900 for (var key in cache) { 4901 var cachedNode = cache[key]; 4902 if (cachedNode) { 4903 var name = getComponentName(cachedNode.componentOptions); 4904 if (name && !filter(name)) { 4905 pruneCacheEntry(cache, key, keys, _vnode); 4906 } 4907 } 4908 } 4909 } 4910 4911 function pruneCacheEntry( 4912 cache, 4913 key, 4914 keys, 4915 current 4916 ) { 4917 var cached$$1 = cache[key]; 4918 if (cached$$1 && (!current || cached$$1.tag !== current.tag)) { 4919 cached$$1.componentInstance.$destroy(); 4920 } 4921 cache[key] = null; 4922 remove(keys, key); 4923 } 4924 4925 var patternTypes = [String, RegExp, Array]; 4926 4927 var KeepAlive = { 4928 name: 'keep-alive', 4929 abstract: true, 4930 4931 props: { 4932 include: patternTypes, 4933 exclude: patternTypes, 4934 max: [String, Number] 4935 }, 4936 4937 created: function created() { 4938 this.cache = Object.create(null); 4939 this.keys = []; 4940 }, 4941 4942 destroyed: function destroyed() { 4943 var this$1 = this; 4944 4945 for (var key in this$1.cache) { 4946 pruneCacheEntry(this$1.cache, key, this$1.keys); 4947 } 4948 }, 4949 4950 mounted: function mounted() { 4951 var this$1 = this; 4952 4953 this.$watch('include', function(val) { 4954 pruneCache(this$1, function(name) { return matches(val, name); }); 4955 }); 4956 this.$watch('exclude', function(val) { 4957 pruneCache(this$1, function(name) { return !matches(val, name); }); 4958 }); 4959 }, 4960 4961 render: function render() { 4962 var slot = this.$slots.default; 4963 var vnode = getFirstComponentChild(slot); 4964 var componentOptions = vnode && vnode.componentOptions; 4965 if (componentOptions) { 4966 // check pattern 4967 var name = getComponentName(componentOptions); 4968 var ref = this; 4969 var include = ref.include; 4970 var exclude = ref.exclude; 4971 if ( 4972 // not included 4973 (include && (!name || !matches(include, name))) || 4974 // excluded 4975 (exclude && name && matches(exclude, name)) 4976 ) { 4977 return vnode 4978 } 4979 4980 var ref$1 = this; 4981 var cache = ref$1.cache; 4982 var keys = ref$1.keys; 4983 var key = vnode.key == null 4984 // same constructor may get registered as different local components 4985 // so cid alone is not enough (#3269) 4986 ? 4987 componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '') : 4988 vnode.key; 4989 if (cache[key]) {
4990 vnode.componentInstance = cache[key].componentInstance; 4991 // make current key freshest 4992 remove(keys, key); 4993 keys.push(key); 4994 } else { 4995 cache[key] = vnode; 4996 keys.push(key); 4997 // prune oldest entry 4998 if (this.max && keys.length > parseInt(this.max)) { 4999 pruneCacheEntry(cache, keys[0], keys, this._vnode); 5000 } 5001 } 5002 5003 vnode.data.keepAlive = true; 5004 } 5005 return vnode || (slot && slot[0]) 5006 } 5007 } 5008 5009 var builtInComponents = { 5010 KeepAlive: KeepAlive 5011 } 5012 5013 /* */ 5014 5015 function initGlobalAPI(Vue) { 5016 // config 5017 var configDef = {}; 5018 configDef.get = function() { return config; }; { 5019 configDef.set = function() { 5020 warn( 5021 'Do not replace the Vue.config object, set individual fields instead.' 5022 ); 5023 }; 5024 } 5025 Object.defineProperty(Vue, 'config', configDef); 5026 5027 // exposed util methods. 5028 // NOTE: these are not considered part of the public API - avoid relying on 5029 // them unless you are aware of the risk. 5030 Vue.util = { 5031 warn: warn, 5032 extend: extend, 5033 mergeOptions: mergeOptions, 5034 defineReactive: defineReactive 5035 }; 5036 5037 Vue.set = set; 5038 Vue.delete = del; 5039 Vue.nextTick = nextTick; 5040 5041 Vue.options = Object.create(null); 5042 ASSET_TYPES.forEach(function(type) { 5043 Vue.options[type + 's'] = Object.create(null); 5044 }); 5045 5046 // this is used to identify the "base" constructor to extend all plain-object 5047 // components with in Weex's multi-instance scenarios. 5048 Vue.options._base = Vue; 5049 5050 extend(Vue.options.components, builtInComponents); 5051 5052 initUse(Vue); 5053 initMixin$1(Vue); 5054 initExtend(Vue); 5055 initAssetRegisters(Vue); 5056 } 5057 5058 initGlobalAPI(Vue); 5059
vendor: 9,729 bytes, lines 5060-5369
5060 Object.defineProperty(Vue.prototype, '$isServer', { 5061 get: isServerRendering 5062 }); 5063 5064 Object.defineProperty(Vue.prototype, '$ssrContext', { 5065 get: function get() { 5066 /* istanbul ignore next */ 5067 return this.$vnode && this.$vnode.ssrContext 5068 } 5069 }); 5070 5071 // expose FunctionalRenderContext for ssr runtime helper installation 5072 Object.defineProperty(Vue, 'FunctionalRenderContext', { 5073 value: FunctionalRenderContext 5074 }); 5075 5076 Vue.version = '2.5.17'; 5077 5078 /* */ 5079 5080 // these are reserved for web because they are directly compiled away 5081 // during template compilation 5082 var isReservedAttr = makeMap('style,class'); 5083 5084 // attributes that should be using props for binding 5085 var acceptValue = makeMap('input,textarea,option,select,progress'); 5086 var mustUseProp = function(tag, type, attr) { 5087 return ( 5088 (attr === 'value' && acceptValue(tag)) && type !== 'button' || 5089 (attr === 'selected' && tag === 'option') || 5090 (attr === 'checked' && tag === 'input') || 5091 (attr === 'muted' && tag === 'video') 5092 ) 5093 }; 5094 5095 var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck'); 5096 5097 var isBooleanAttr = makeMap( 5098 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' + 5099 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + 5100 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + 5101 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + 5102 'required,reversed,scoped,seamless,selected,sortable,translate,' + 5103 'truespeed,typemustmatch,visible' 5104 ); 5105 5106 var xlinkNS = 'http://www.w3.org/1999/xlink'; 5107 5108 var isXlink = function(name) { 5109 return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink' 5110 }; 5111 5112 var getXlinkProp = function(name) { 5113 return isXlink(name) ? name.slice(6, name.length) : '' 5114 }; 5115 5116 var isFalsyAttrValue = function(val) { 5117 return val == null || val === false 5118 }; 5119 5120 /* */ 5121 5122 function genClassForVnode(vnode) { 5123 var data = vnode.data; 5124 var parentNode = vnode; 5125 var childNode = vnode; 5126 while (isDef(childNode.componentInstance)) { 5127 childNode = childNode.componentInstance._vnode; 5128 if (childNode && childNode.data) { 5129 data = mergeClassData(childNode.data, data); 5130 } 5131 } 5132 while (isDef(parentNode = parentNode.parent)) { 5133 if (parentNode && parentNode.data) { 5134 data = mergeClassData(data, parentNode.data); 5135 } 5136 } 5137 return renderClass(data.staticClass, data.class) 5138 } 5139 5140 function mergeClassData(child, parent) { 5141 return { 5142 staticClass: concat(child.staticClass, parent.staticClass), 5143 class: isDef(child.class) ? 5144 [child.class, parent.class] : 5145 parent.class 5146 } 5147 } 5148 5149 function renderClass( 5150 staticClass, 5151 dynamicClass 5152 ) { 5153 if (isDef(staticClass) || isDef(dynamicClass)) { 5154 return concat(staticClass, stringifyClass(dynamicClass)) 5155 } 5156 /* istanbul ignore next */ 5157 return '' 5158 } 5159 5160 function concat(a, b) { 5161 return a ? b ? (a + ' ' + b) : a : (b || '') 5162 } 5163 5164 function stringifyClass(value) { 5165 if (Array.isArray(value)) { 5166 return stringifyArray(value) 5167 } 5168 if (isObject(value)) { 5169 return stringifyObject(value) 5170 } 5171 if (typeof value === 'string') { 5172 return value 5173 } 5174 /* istanbul ignore next */ 5175 return '' 5176 } 5177 5178 function stringifyArray(value) { 5179 var res = ''; 5180 var stringified; 5181 for (var i = 0, l = value.length; i < l; i++) { 5182 if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') { 5183 if (res) { res += ' '; } 5184 res += stringified; 5185 } 5186 } 5187 return res 5188 } 5189 5190 function stringifyObject(value) { 5191 var res = ''; 5192 for (var key in value) { 5193 if (value[key]) { 5194 if (res) { res += ' '; } 5195 res += key; 5196 } 5197 } 5198 return res 5199 } 5200 5201 /* */ 5202 5203 var namespaceMap = { 5204 svg: 'http://www.w3.org/2000/svg', 5205 math: 'http://www.w3.org/1998/Math/MathML' 5206 }; 5207 5208 var isHTMLTag = makeMap( 5209 'html,body,base,head,link,meta,style,title,' + 5210 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + 5211 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' + 5212 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' + 5213 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' + 5214 'embed,object,param,source,canvas,script,noscript,del,ins,' + 5215 'caption,col,colgroup,table,thead,tbody,td,th,tr,' + 5216 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + 5217 'output,progress,select,textarea,' + 5218 'details,dialog,menu,menuitem,summary,' + 5219 'content,element,shadow,template,blockquote,iframe,tfoot' 5220 ); 5221 5222 // this map is intentionally selective, only covering SVG elements that may 5223 // contain child elements. 5224 var isSVG = makeMap( 5225 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' + 5226 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + 5227 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', 5228 true 5229 ); 5230 5231 var isPreTag = function(tag) { return tag === 'pre'; }; 5232 5233 var isReservedTag = function(tag) { 5234 return isHTMLTag(tag) || isSVG(tag) 5235 }; 5236 5237 function getTagNamespace(tag) { 5238 if (isSVG(tag)) { 5239 return 'svg' 5240 } 5241 // basic support for MathML 5242 // note it doesn't support other MathML elements being component roots 5243 if (tag === 'math') { 5244 return 'math' 5245 } 5246 } 5247 5248 var unknownElementCache = Object.create(null); 5249 5250 function isUnknownElement(tag) { 5251 /* istanbul ignore if */ 5252 if (!inBrowser) { 5253 return true 5254 } 5255 if (isReservedTag(tag)) { 5256 return false 5257 } 5258 tag = tag.toLowerCase(); 5259 /* istanbul ignore if */ 5260 if (unknownElementCache[tag] != null) { 5261 return unknownElementCache[tag] 5262 } 5263 var el = document.createElement(tag); 5264 if (tag.indexOf('-') > -1) { 5265 // http://stackoverflow.com/a/28210364/1070244 5266 return (unknownElementCache[tag] = ( 5267 el.constructor === window.HTMLUnknownElement || 5268 el.constructor === window.HTMLElement 5269 )) 5270 } else { 5271 return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString())) 5272 } 5273 } 5274 5275 var isTextInputType = makeMap('text,number,password,search,email,tel,url'); 5276 5277 /* */ 5278 5279 /** 5280 * Query an element selector if it's not an element already. 5281 */ 5282 function query(el) { 5283 if (typeof el === 'string') { 5284 var selected = document.querySelector(el); 5285 if (!selected) { 5286 "development" !== 'production' && warn( 5287 'Cannot find element: ' + el 5288 ); 5289 return document.createElement('div') 5290 } 5291 return selected 5292 } else { 5293 return el 5294 } 5295 } 5296 5297 /* */ 5298 5299 function createElement$1(tagName, vnode) { 5300 var elm = document.createElement(tagName); 5301 if (tagName !== 'select') { 5302 return elm 5303 } 5304 // false or null will remove the attribute but undefined will not 5305 if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) { 5306 elm.setAttribute('multiple', 'multiple'); 5307 } 5308 return elm 5309 } 5310 5311 function createElementNS(namespace, tagName) { 5312 return document.createElementNS(namespaceMap[namespace], tagName) 5313 } 5314 5315 function createTextNode(text) { 5316 return document.createTextNode(text) 5317 } 5318 5319 function createComment(text) { 5320 return document.createComment(text) 5321 } 5322 5323 function insertBefore(parentNode, newNode, referenceNode) { 5324 parentNode.insertBefore(newNode, referenceNode); 5325 } 5326 5327 function removeChild(node, child) { 5328 node.removeChild(child); 5329 } 5330 5331 function appendChild(node, child) { 5332 node.appendChild(child); 5333 } 5334 5335 function parentNode(node) { 5336 return node.parentNode 5337 } 5338 5339 function nextSibling(node) { 5340 return node.nextSibling 5341 } 5342 5343 function tagName(node) { 5344 return node.tagName 5345 } 5346 5347 function setTextContent(node, text) { 5348 node.textContent = text; 5349 } 5350 5351 function setStyleScope(node, scopeId) { 5352 node.setAttribute(scopeId, ''); 5353 } 5354 5355 5356 var nodeOps = Object.freeze({ 5357 createElement: createElement$1, 5358 createElementNS: createElementNS, 5359 createTextNode: createTextNode, 5360 createComment: createComment, 5361 insertBefore: insertBefore, 5362 removeChild: removeChild, 5363 appendChild: appendChild, 5364 parentNode: parentNode, 5365 nextSibling: nextSibling, 5366 tagName: tagName, 5367 setTextContent: setTextContent, 5368 setStyleScope: setStyleScope 5369 });
vendor: 4,935 bytes, lines 5370-5529
5370 5371 /* */ 5372 5373 var ref = { 5374 create: function create(_, vnode) { 5375 registerRef(vnode); 5376 }, 5377 update: function update(oldVnode, vnode) { 5378 if (oldVnode.data.ref !== vnode.data.ref) { 5379 registerRef(oldVnode, true); 5380 registerRef(vnode); 5381 } 5382 }, 5383 destroy: function destroy(vnode) { 5384 registerRef(vnode, true); 5385 } 5386 } 5387 5388 function registerRef(vnode, isRemoval) { 5389 var key = vnode.data.ref; 5390 if (!isDef(key)) { return } 5391 5392 var vm = vnode.context; 5393 var ref = vnode.componentInstance || vnode.elm; 5394 var refs = vm.$refs; 5395 if (isRemoval) { 5396 if (Array.isArray(refs[key])) { 5397 remove(refs[key], ref); 5398 } else if (refs[key] === ref) { 5399 refs[key] = undefined; 5400 } 5401 } else { 5402 if (vnode.data.refInFor) { 5403 if (!Array.isArray(refs[key])) { 5404 refs[key] = [ref]; 5405 } else if (refs[key].indexOf(ref) < 0) { 5406 // $flow-disable-line 5407 refs[key].push(ref); 5408 } 5409 } else { 5410 refs[key] = ref; 5411 } 5412 } 5413 } 5414 5415 /** 5416 * Virtual DOM patching algorithm based on Snabbdom by 5417 * Simon Friis Vindum (@paldepind) 5418 * Licensed under the MIT License 5419 * https://github.com/paldepind/snabbdom/blob/master/LICENSE 5420 * 5421 * modified by Evan You (@yyx990803) 5422 * 5423 * Not type-checking this because this file is perf-critical and the cost 5424 * of making flow understand it is not worth it. 5425 */ 5426 5427 var emptyNode = new VNode('', {}, []); 5428 5429 var hooks = ['create', 'activate', 'update', 'remove', 'destroy']; 5430 5431 function sameVnode(a, b) { 5432 return ( 5433 a.key === b.key && ( 5434 ( 5435 a.tag === b.tag && 5436 a.isComment === b.isComment && 5437 isDef(a.data) === isDef(b.data) && 5438 sameInputType(a, b) 5439 ) || ( 5440 isTrue(a.isAsyncPlaceholder) && 5441 a.asyncFactory === b.asyncFactory && 5442 isUndef(b.asyncFactory.error) 5443 ) 5444 ) 5445 ) 5446 } 5447 5448 function sameInputType(a, b) { 5449 if (a.tag !== 'input') { return true } 5450 var i; 5451 var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type; 5452 var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type; 5453 return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB) 5454 } 5455 5456 function createKeyToOldIdx(children, beginIdx, endIdx) { 5457 var i, key; 5458 var map = {}; 5459 for (i = beginIdx; i <= endIdx; ++i) { 5460 key = children[i].key; 5461 if (isDef(key)) { map[key] = i; } 5462 } 5463 return map 5464 } 5465 5466 function createPatchFunction(backend) { 5467 var i, j; 5468 var cbs = {}; 5469 5470 var modules = backend.modules; 5471 var nodeOps = backend.nodeOps; 5472 5473 for (i = 0; i < hooks.length; ++i) { 5474 cbs[hooks[i]] = []; 5475 for (j = 0; j < modules.length; ++j) { 5476 if (isDef(modules[j][hooks[i]])) { 5477 cbs[hooks[i]].push(modules[j][hooks[i]]); 5478 } 5479 } 5480 } 5481 5482 function emptyNodeAt(elm) { 5483 return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm) 5484 } 5485 5486 function createRmCb(childElm, listeners) { 5487 function remove() { 5488 if (--remove.listeners === 0) { 5489 removeNode(childElm); 5490 } 5491 } 5492 remove.listeners = listeners; 5493 return remove 5494 } 5495 5496 function removeNode(el) { 5497 var parent = nodeOps.parentNode(el); 5498 // element may have already been removed due to v-html / v-text 5499 if (isDef(parent)) { 5500 nodeOps.removeChild(parent, el); 5501 } 5502 } 5503 5504 function isUnknownElement$$1(vnode, inVPre) { 5505 return (!inVPre && 5506 !vnode.ns && 5507 !( 5508 config.ignoredElements.length && 5509 config.ignoredElements.some(function(ignore) { 5510 return isRegExp(ignore) ? 5511 ignore.test(vnode.tag) : 5512 ignore === vnode.tag 5513 }) 5514 ) && 5515 config.isUnknownElement(vnode.tag) 5516 ) 5517 } 5518 5519 var creatingElmInVPre = 0; 5520 5521 function createElm( 5522 vnode, 5523 insertedVnodeQueue, 5524 parentElm, 5525 refElm, 5526 nested, 5527 ownerArray, 5528 index 5529 ) {
5530 if (isDef(vnode.elm) && isDef(ownerArray)) { 5531 // This vnode was used in a previous render! 5532 // now it's used as a new node, overwriting its elm would cause 5533 // potential patch errors down the road when it's used as an insertion 5534 // reference node. Instead, we clone the node on-demand before creating 5535 // associated DOM element for it. 5536 vnode = ownerArray[index] = cloneVNode(vnode); 5537 } 5538 5539 vnode.isRootInsert = !nested; // for transition enter check 5540 if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) { 5541 return 5542 } 5543 5544 var data = vnode.data; 5545 var children = vnode.children; 5546 var tag = vnode.tag; 5547 if (isDef(tag)) { 5548 { 5549 if (data && data.pre) { 5550 creatingElmInVPre++; 5551 } 5552 if (isUnknownElement$$1(vnode, creatingElmInVPre)) { 5553 warn( 5554 'Unknown custom element: <' + tag + '> - did you ' + 5555 'register the component correctly? For recursive components, ' + 5556 'make sure to provide the "name" option.', 5557 vnode.context 5558 ); 5559 } 5560 } 5561 5562 vnode.elm = vnode.ns ? 5563 nodeOps.createElementNS(vnode.ns, tag) : 5564 nodeOps.createElement(tag, vnode); 5565 setScope(vnode); 5566 5567 /* istanbul ignore if */ 5568 { 5569 createChildren(vnode, children, insertedVnodeQueue); 5570 if (isDef(data)) { 5571 invokeCreateHooks(vnode, insertedVnodeQueue); 5572 } 5573 insert(parentElm, vnode.elm, refElm); 5574 } 5575 5576 if ("development" !== 'production' && data && data.pre) { 5577 creatingElmInVPre--; 5578 } 5579 } else if (isTrue(vnode.isComment)) { 5580 vnode.elm = nodeOps.createComment(vnode.text); 5581 insert(parentElm, vnode.elm, refElm); 5582 } else { 5583 vnode.elm = nodeOps.createTextNode(vnode.text); 5584 insert(parentElm, vnode.elm, refElm); 5585 } 5586 } 5587 5588 function createComponent(vnode, insertedVnodeQueue, parentElm, refElm) { 5589 var i = vnode.data; 5590 if (isDef(i)) { 5591 var isReactivated = isDef(vnode.componentInstance) && i.keepAlive; 5592 if (isDef(i = i.hook) && isDef(i = i.init)) { 5593 i(vnode, false /* hydrating */ , parentElm, refElm); 5594 } 5595 // after calling the init hook, if the vnode is a child component 5596 // it should've created a child instance and mounted it. the child 5597 // component also has set the placeholder vnode's elm. 5598 // in that case we can just return the element and be done.
vendor: 24,366 bytes, lines 5599-6124
5599 if (isDef(vnode.componentInstance)) { 5600 initComponent(vnode, insertedVnodeQueue); 5601 if (isTrue(isReactivated)) { 5602 reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm); 5603 } 5604 return true 5605 } 5606 } 5607 } 5608 5609 function initComponent(vnode, insertedVnodeQueue) { 5610 if (isDef(vnode.data.pendingInsert)) { 5611 insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert); 5612 vnode.data.pendingInsert = null; 5613 } 5614 vnode.elm = vnode.componentInstance.$el; 5615 if (isPatchable(vnode)) { 5616 invokeCreateHooks(vnode, insertedVnodeQueue); 5617 setScope(vnode); 5618 } else { 5619 // empty component root. 5620 // skip all element-related modules except for ref (#3455) 5621 registerRef(vnode); 5622 // make sure to invoke the insert hook 5623 insertedVnodeQueue.push(vnode); 5624 } 5625 } 5626 5627 function reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm) { 5628 var i; 5629 // hack for #4339: a reactivated component with inner transition 5630 // does not trigger because the inner node's created hooks are not called 5631 // again. It's not ideal to involve module-specific logic in here but 5632 // there doesn't seem to be a better way to do it. 5633 var innerNode = vnode; 5634 while (innerNode.componentInstance) { 5635 innerNode = innerNode.componentInstance._vnode; 5636 if (isDef(i = innerNode.data) && isDef(i = i.transition)) { 5637 for (i = 0; i < cbs.activate.length; ++i) { 5638 cbs.activate[i](emptyNode, innerNode); 5639 } 5640 insertedVnodeQueue.push(innerNode); 5641 break 5642 } 5643 } 5644 // unlike a newly created component, 5645 // a reactivated keep-alive component doesn't insert itself 5646 insert(parentElm, vnode.elm, refElm); 5647 } 5648 5649 function insert(parent, elm, ref$$1) { 5650 if (isDef(parent)) { 5651 if (isDef(ref$$1)) { 5652 if (ref$$1.parentNode === parent) { 5653 nodeOps.insertBefore(parent, elm, ref$$1); 5654 } 5655 } else { 5656 nodeOps.appendChild(parent, elm); 5657 } 5658 } 5659 } 5660 5661 function createChildren(vnode, children, insertedVnodeQueue) { 5662 if (Array.isArray(children)) { 5663 { 5664 checkDuplicateKeys(children); 5665 } 5666 for (var i = 0; i < children.length; ++i) { 5667 createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i); 5668 } 5669 } else if (isPrimitive(vnode.text)) { 5670 nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text))); 5671 } 5672 } 5673 5674 function isPatchable(vnode) { 5675 while (vnode.componentInstance) { 5676 vnode = vnode.componentInstance._vnode; 5677 } 5678 return isDef(vnode.tag) 5679 } 5680 5681 function invokeCreateHooks(vnode, insertedVnodeQueue) { 5682 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) { 5683 cbs.create[i$1](emptyNode, vnode); 5684 } 5685 i = vnode.data.hook; // Reuse variable 5686 if (isDef(i)) { 5687 if (isDef(i.create)) { i.create(emptyNode, vnode); } 5688 if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); } 5689 } 5690 } 5691 5692 // set scope id attribute for scoped CSS. 5693 // this is implemented as a special case to avoid the overhead 5694 // of going through the normal attribute patching process. 5695 function setScope(vnode) { 5696 var i; 5697 if (isDef(i = vnode.fnScopeId)) { 5698 nodeOps.setStyleScope(vnode.elm, i); 5699 } else { 5700 var ancestor = vnode; 5701 while (ancestor) { 5702 if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) { 5703 nodeOps.setStyleScope(vnode.elm, i); 5704 } 5705 ancestor = ancestor.parent; 5706 } 5707 } 5708 // for slot content they should also get the scopeId from the host instance. 5709 if (isDef(i = activeInstance) && 5710 i !== vnode.context && 5711 i !== vnode.fnContext && 5712 isDef(i = i.$options._scopeId) 5713 ) { 5714 nodeOps.setStyleScope(vnode.elm, i); 5715 } 5716 } 5717 5718 function addVnodes(parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) { 5719 for (; startIdx <= endIdx; ++startIdx) { 5720 createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx); 5721 } 5722 } 5723 5724 function invokeDestroyHook(vnode) { 5725 var i, j; 5726 var data = vnode.data; 5727 if (isDef(data)) { 5728 if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); } 5729 for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); } 5730 } 5731 if (isDef(i = vnode.children)) { 5732 for (j = 0; j < vnode.children.length; ++j) { 5733 invokeDestroyHook(vnode.children[j]); 5734 } 5735 } 5736 } 5737 5738 function removeVnodes(parentElm, vnodes, startIdx, endIdx) { 5739 for (; startIdx <= endIdx; ++startIdx) { 5740 var ch = vnodes[startIdx]; 5741 if (isDef(ch)) { 5742 if (isDef(ch.tag)) { 5743 removeAndInvokeRemoveHook(ch); 5744 invokeDestroyHook(ch); 5745 } else { // Text node 5746 removeNode(ch.elm); 5747 } 5748 } 5749 } 5750 } 5751 5752 function removeAndInvokeRemoveHook(vnode, rm) { 5753 if (isDef(rm) || isDef(vnode.data)) { 5754 var i; 5755 var listeners = cbs.remove.length + 1; 5756 if (isDef(rm)) { 5757 // we have a recursively passed down rm callback 5758 // increase the listeners count 5759 rm.listeners += listeners; 5760 } else { 5761 // directly removing 5762 rm = createRmCb(vnode.elm, listeners); 5763 } 5764 // recursively invoke hooks on child component root node 5765 if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) { 5766 removeAndInvokeRemoveHook(i, rm); 5767 } 5768 for (i = 0; i < cbs.remove.length; ++i) { 5769 cbs.remove[i](vnode, rm); 5770 } 5771 if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) { 5772 i(vnode, rm); 5773 } else { 5774 rm(); 5775 } 5776 } else { 5777 removeNode(vnode.elm); 5778 } 5779 } 5780 5781 function updateChildren(parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) { 5782 var oldStartIdx = 0; 5783 var newStartIdx = 0; 5784 var oldEndIdx = oldCh.length - 1; 5785 var oldStartVnode = oldCh[0]; 5786 var oldEndVnode = oldCh[oldEndIdx]; 5787 var newEndIdx = newCh.length - 1; 5788 var newStartVnode = newCh[0]; 5789 var newEndVnode = newCh[newEndIdx]; 5790 var oldKeyToIdx, idxInOld, vnodeToMove, refElm; 5791 5792 // removeOnly is a special flag used only by <transition-group> 5793 // to ensure removed elements stay in correct relative positions 5794 // during leaving transitions 5795 var canMove = !removeOnly; 5796 5797 { 5798 checkDuplicateKeys(newCh); 5799 } 5800 5801 while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) { 5802 if (isUndef(oldStartVnode)) { 5803 oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left 5804 } else if (isUndef(oldEndVnode)) { 5805 oldEndVnode = oldCh[--oldEndIdx]; 5806 } else if (sameVnode(oldStartVnode, newStartVnode)) { 5807 patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue); 5808 oldStartVnode = oldCh[++oldStartIdx]; 5809 newStartVnode = newCh[++newStartIdx]; 5810 } else if (sameVnode(oldEndVnode, newEndVnode)) { 5811 patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue); 5812 oldEndVnode = oldCh[--oldEndIdx]; 5813 newEndVnode = newCh[--newEndIdx]; 5814 } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right 5815 patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue); 5816 canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm)); 5817 oldStartVnode = oldCh[++oldStartIdx]; 5818 newEndVnode = newCh[--newEndIdx]; 5819 } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left 5820 patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue); 5821 canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm); 5822 oldEndVnode = oldCh[--oldEndIdx]; 5823 newStartVnode = newCh[++newStartIdx]; 5824 } else { 5825 if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); } 5826 idxInOld = isDef(newStartVnode.key) ? 5827 oldKeyToIdx[newStartVnode.key] : 5828 findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx); 5829 if (isUndef(idxInOld)) { // New element 5830 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); 5831 } else { 5832 vnodeToMove = oldCh[idxInOld]; 5833 if (sameVnode(vnodeToMove, newStartVnode)) { 5834 patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue); 5835 oldCh[idxInOld] = undefined; 5836 canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm); 5837 } else { 5838 // same key but different element. treat as new element 5839 createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx); 5840 } 5841 } 5842 newStartVnode = newCh[++newStartIdx]; 5843 } 5844 } 5845 if (oldStartIdx > oldEndIdx) { 5846 refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm; 5847 addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue); 5848 } else if (newStartIdx > newEndIdx) { 5849 removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx); 5850 } 5851 } 5852 5853 function checkDuplicateKeys(children) { 5854 var seenKeys = {}; 5855 for (var i = 0; i < children.length; i++) { 5856 var vnode = children[i]; 5857 var key = vnode.key; 5858 if (isDef(key)) { 5859 if (seenKeys[key]) { 5860 warn( 5861 ("Duplicate keys detected: '" + key + "'. This may cause an update error."), 5862 vnode.context 5863 ); 5864 } else { 5865 seenKeys[key] = true; 5866 } 5867 } 5868 } 5869 } 5870 5871 function findIdxInOld(node, oldCh, start, end) { 5872 for (var i = start; i < end; i++) { 5873 var c = oldCh[i]; 5874 if (isDef(c) && sameVnode(node, c)) { return i } 5875 } 5876 } 5877 5878 function patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly) { 5879 if (oldVnode === vnode) { 5880 return 5881 } 5882 5883 var elm = vnode.elm = oldVnode.elm; 5884 5885 if (isTrue(oldVnode.isAsyncPlaceholder)) { 5886 if (isDef(vnode.asyncFactory.resolved)) { 5887 hydrate(oldVnode.elm, vnode, insertedVnodeQueue); 5888 } else { 5889 vnode.isAsyncPlaceholder = true; 5890 } 5891 return 5892 } 5893 5894 // reuse element for static trees. 5895 // note we only do this if the vnode is cloned - 5896 // if the new node is not cloned it means the render functions have been 5897 // reset by the hot-reload-api and we need to do a proper re-render. 5898 if (isTrue(vnode.isStatic) && 5899 isTrue(oldVnode.isStatic) && 5900 vnode.key === oldVnode.key && 5901 (isTrue(vnode.isCloned) || isTrue(vnode.isOnce)) 5902 ) { 5903 vnode.componentInstance = oldVnode.componentInstance; 5904 return 5905 } 5906 5907 var i; 5908 var data = vnode.data; 5909 if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) { 5910 i(oldVnode, vnode); 5911 } 5912 5913 var oldCh = oldVnode.children; 5914 var ch = vnode.children; 5915 if (isDef(data) && isPatchable(vnode)) { 5916 for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); } 5917 if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); } 5918 } 5919 if (isUndef(vnode.text)) { 5920 if (isDef(oldCh) && isDef(ch)) { 5921 if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); } 5922 } else if (isDef(ch)) { 5923 if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); } 5924 addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue); 5925 } else if (isDef(oldCh)) { 5926 removeVnodes(elm, oldCh, 0, oldCh.length - 1); 5927 } else if (isDef(oldVnode.text)) { 5928 nodeOps.setTextContent(elm, ''); 5929 } 5930 } else if (oldVnode.text !== vnode.text) { 5931 nodeOps.setTextContent(elm, vnode.text); 5932 } 5933 if (isDef(data)) { 5934 if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); } 5935 } 5936 } 5937 5938 function invokeInsertHook(vnode, queue, initial) { 5939 // delay insert hooks for component root nodes, invoke them after the 5940 // element is really inserted 5941 if (isTrue(initial) && isDef(vnode.parent)) { 5942 vnode.parent.data.pendingInsert = queue; 5943 } else { 5944 for (var i = 0; i < queue.length; ++i) { 5945 queue[i].data.hook.insert(queue[i]); 5946 } 5947 } 5948 } 5949 5950 var hydrationBailed = false; 5951 // list of modules that can skip create hook during hydration because they 5952 // are already rendered on the client or has no need for initialization 5953 // Note: style is excluded because it relies on initial clone for future 5954 // deep updates (#7063). 5955 var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key'); 5956 5957 // Note: this is a browser-only function so we can assume elms are DOM nodes. 5958 function hydrate(elm, vnode, insertedVnodeQueue, inVPre) { 5959 var i; 5960 var tag = vnode.tag; 5961 var data = vnode.data; 5962 var children = vnode.children; 5963 inVPre = inVPre || (data && data.pre); 5964 vnode.elm = elm; 5965 5966 if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) { 5967 vnode.isAsyncPlaceholder = true; 5968 return true 5969 } 5970 // assert node match 5971 { 5972 if (!assertNodeMatch(elm, vnode, inVPre)) { 5973 return false 5974 } 5975 } 5976 if (isDef(data)) { 5977 if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */ ); } 5978 if (isDef(i = vnode.componentInstance)) { 5979 // child component. it should have hydrated its own tree. 5980 initComponent(vnode, insertedVnodeQueue); 5981 return true 5982 } 5983 } 5984 if (isDef(tag)) { 5985 if (isDef(children)) { 5986 // empty element, allow client to pick up and populate children 5987 if (!elm.hasChildNodes()) { 5988 createChildren(vnode, children, insertedVnodeQueue); 5989 } else { 5990 // v-html and domProps: innerHTML 5991 if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) { 5992 if (i !== elm.innerHTML) { 5993 /* istanbul ignore if */ 5994 if ("development" !== 'production' && 5995 typeof console !== 'undefined' && 5996 !hydrationBailed 5997 ) { 5998 hydrationBailed = true; 5999 console.warn('Parent: ', elm); 6000 console.warn('server innerHTML: ', i); 6001 console.warn('client innerHTML: ', elm.innerHTML); 6002 } 6003 return false 6004 } 6005 } else { 6006 // iterate and compare children lists 6007 var childrenMatch = true; 6008 var childNode = elm.firstChild; 6009 for (var i$1 = 0; i$1 < children.length; i$1++) { 6010 if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) { 6011 childrenMatch = false; 6012 break 6013 } 6014 childNode = childNode.nextSibling; 6015 } 6016 // if childNode is not null, it means the actual childNodes list is 6017 // longer than the virtual children list. 6018 if (!childrenMatch || childNode) { 6019 /* istanbul ignore if */ 6020 if ("development" !== 'production' && 6021 typeof console !== 'undefined' && 6022 !hydrationBailed 6023 ) { 6024 hydrationBailed = true; 6025 console.warn('Parent: ', elm); 6026 console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); 6027 } 6028 return false 6029 } 6030 } 6031 } 6032 } 6033 if (isDef(data)) { 6034 var fullInvoke = false; 6035 for (var key in data) { 6036 if (!isRenderedModule(key)) { 6037 fullInvoke = true; 6038 invokeCreateHooks(vnode, insertedVnodeQueue); 6039 break 6040 } 6041 } 6042 if (!fullInvoke && data['class']) { 6043 // ensure collecting deps for deep class bindings for future updates 6044 traverse(data['class']); 6045 } 6046 } 6047 } else if (elm.data !== vnode.text) { 6048 elm.data = vnode.text; 6049 } 6050 return true 6051 } 6052 6053 function assertNodeMatch(node, vnode, inVPre) { 6054 if (isDef(vnode.tag)) { 6055 return vnode.tag.indexOf('vue-component') === 0 || (!isUnknownElement$$1(vnode, inVPre) && 6056 vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase()) 6057 ) 6058 } else { 6059 return node.nodeType === (vnode.isComment ? 8 : 3) 6060 } 6061 } 6062 6063 return function patch(oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) { 6064 if (isUndef(vnode)) { 6065 if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); } 6066 return 6067 } 6068 6069 var isInitialPatch = false; 6070 var insertedVnodeQueue = []; 6071 6072 if (isUndef(oldVnode)) { 6073 // empty mount (likely as component), create new root element 6074 isInitialPatch = true; 6075 createElm(vnode, insertedVnodeQueue, parentElm, refElm); 6076 } else { 6077 var isRealElement = isDef(oldVnode.nodeType); 6078 if (!isRealElement && sameVnode(oldVnode, vnode)) { 6079 // patch existing root node 6080 patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly); 6081 } else { 6082 if (isRealElement) { 6083 // mounting to a real element 6084 // check if this is server-rendered content and if we can perform 6085 // a successful hydration. 6086 if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) { 6087 oldVnode.removeAttribute(SSR_ATTR); 6088 hydrating = true; 6089 } 6090 if (isTrue(hydrating)) { 6091 if (hydrate(oldVnode, vnode, insertedVnodeQueue)) { 6092 invokeInsertHook(vnode, insertedVnodeQueue, true); 6093 return oldVnode 6094 } else { 6095 warn( 6096 'The client-side rendered virtual DOM tree is not matching ' + 6097 'server-rendered content. This is likely caused by incorrect ' + 6098 'HTML markup, for example nesting block-level elements inside ' + 6099 '<p>, or missing <tbody>. Bailing hydration and performing ' + 6100 'full client-side render.' 6101 ); 6102 } 6103 } 6104 // either not server-rendered, or hydration failed. 6105 // create an empty node and replace it 6106 oldVnode = emptyNodeAt(oldVnode); 6107 } 6108 6109 // replacing existing element 6110 var oldElm = oldVnode.elm; 6111 var parentElm$1 = nodeOps.parentNode(oldElm); 6112 6113 // create new node 6114 createElm( 6115 vnode, 6116 insertedVnodeQueue, 6117 // extremely rare edge case: do not insert if old element is in a 6118 // leaving transition. Only happens when combining transition + 6119 // keep-alive + HOCs. (#4590) 6120 oldElm._leaveCb ? null : parentElm$1, 6121 nodeOps.nextSibling(oldElm) 6122 ); 6123 6124 // update parent placeholder node element, recursively
vendor: 10,569 bytes, lines 6125-6430
6125 if (isDef(vnode.parent)) { 6126 var ancestor = vnode.parent; 6127 var patchable = isPatchable(vnode); 6128 while (ancestor) { 6129 for (var i = 0; i < cbs.destroy.length; ++i) { 6130 cbs.destroy[i](ancestor); 6131 } 6132 ancestor.elm = vnode.elm; 6133 if (patchable) { 6134 for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) { 6135 cbs.create[i$1](emptyNode, ancestor); 6136 } 6137 // #6513 6138 // invoke insert hooks that may have been merged by create hooks. 6139 // e.g. for directives that uses the "inserted" hook. 6140 var insert = ancestor.data.hook.insert; 6141 if (insert.merged) { 6142 // start at index 1 to avoid re-invoking component mounted hook 6143 for (var i$2 = 1; i$2 < insert.fns.length; i$2++) { 6144 insert.fns[i$2](); 6145 } 6146 } 6147 } else { 6148 registerRef(ancestor); 6149 } 6150 ancestor = ancestor.parent; 6151 } 6152 } 6153 6154 // destroy old node 6155 if (isDef(parentElm$1)) { 6156 removeVnodes(parentElm$1, [oldVnode], 0, 0); 6157 } else if (isDef(oldVnode.tag)) { 6158 invokeDestroyHook(oldVnode); 6159 } 6160 } 6161 } 6162 6163 invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch); 6164 return vnode.elm 6165 } 6166 } 6167 6168 /* */ 6169 6170 var directives = { 6171 create: updateDirectives, 6172 update: updateDirectives, 6173 destroy: function unbindDirectives(vnode) { 6174 updateDirectives(vnode, emptyNode); 6175 } 6176 } 6177 6178 function updateDirectives(oldVnode, vnode) { 6179 if (oldVnode.data.directives || vnode.data.directives) { 6180 _update(oldVnode, vnode); 6181 } 6182 } 6183 6184 function _update(oldVnode, vnode) { 6185 var isCreate = oldVnode === emptyNode; 6186 var isDestroy = vnode === emptyNode; 6187 var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context); 6188 var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context); 6189 6190 var dirsWithInsert = []; 6191 var dirsWithPostpatch = []; 6192 6193 var key, oldDir, dir; 6194 for (key in newDirs) { 6195 oldDir = oldDirs[key]; 6196 dir = newDirs[key]; 6197 if (!oldDir) { 6198 // new directive, bind 6199 callHook$1(dir, 'bind', vnode, oldVnode); 6200 if (dir.def && dir.def.inserted) { 6201 dirsWithInsert.push(dir); 6202 } 6203 } else { 6204 // existing directive, update 6205 dir.oldValue = oldDir.value; 6206 callHook$1(dir, 'update', vnode, oldVnode); 6207 if (dir.def && dir.def.componentUpdated) { 6208 dirsWithPostpatch.push(dir); 6209 } 6210 } 6211 } 6212 6213 if (dirsWithInsert.length) { 6214 var callInsert = function() { 6215 for (var i = 0; i < dirsWithInsert.length; i++) { 6216 callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode); 6217 } 6218 }; 6219 if (isCreate) { 6220 mergeVNodeHook(vnode, 'insert', callInsert); 6221 } else { 6222 callInsert(); 6223 } 6224 } 6225 6226 if (dirsWithPostpatch.length) { 6227 mergeVNodeHook(vnode, 'postpatch', function() { 6228 for (var i = 0; i < dirsWithPostpatch.length; i++) { 6229 callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode); 6230 } 6231 }); 6232 } 6233 6234 if (!isCreate) { 6235 for (key in oldDirs) { 6236 if (!newDirs[key]) { 6237 // no longer present, unbind 6238 callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy); 6239 } 6240 } 6241 } 6242 } 6243 6244 var emptyModifiers = Object.create(null); 6245 6246 function normalizeDirectives$1( 6247 dirs, 6248 vm 6249 ) { 6250 var res = Object.create(null); 6251 if (!dirs) { 6252 // $flow-disable-line 6253 return res 6254 } 6255 var i, dir; 6256 for (i = 0; i < dirs.length; i++) { 6257 dir = dirs[i]; 6258 if (!dir.modifiers) { 6259 // $flow-disable-line 6260 dir.modifiers = emptyModifiers; 6261 } 6262 res[getRawDirName(dir)] = dir; 6263 dir.def = resolveAsset(vm.$options, 'directives', dir.name, true); 6264 } 6265 // $flow-disable-line 6266 return res 6267 } 6268 6269 function getRawDirName(dir) { 6270 return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.'))) 6271 } 6272 6273 function callHook$1(dir, hook, vnode, oldVnode, isDestroy) { 6274 var fn = dir.def && dir.def[hook]; 6275 if (fn) { 6276 try { 6277 fn(vnode.elm, dir, vnode, oldVnode, isDestroy); 6278 } catch (e) { 6279 handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook")); 6280 } 6281 } 6282 } 6283 6284 var baseModules = [ 6285 ref, 6286 directives 6287 ] 6288 6289 /* */ 6290 6291 function updateAttrs(oldVnode, vnode) { 6292 var opts = vnode.componentOptions; 6293 if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) { 6294 return 6295 } 6296 if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) { 6297 return 6298 } 6299 var key, cur, old; 6300 var elm = vnode.elm; 6301 var oldAttrs = oldVnode.data.attrs || {}; 6302 var attrs = vnode.data.attrs || {}; 6303 // clone observed objects, as the user probably wants to mutate it 6304 if (isDef(attrs.__ob__)) { 6305 attrs = vnode.data.attrs = extend({}, attrs); 6306 } 6307 6308 for (key in attrs) { 6309 cur = attrs[key]; 6310 old = oldAttrs[key]; 6311 if (old !== cur) { 6312 setAttr(elm, key, cur); 6313 } 6314 } 6315 // #4391: in IE9, setting type can reset value for input[type=radio] 6316 // #6666: IE/Edge forces progress value down to 1 before setting a max 6317 /* istanbul ignore if */ 6318 if ((isIE || isEdge) && attrs.value !== oldAttrs.value) { 6319 setAttr(elm, 'value', attrs.value); 6320 } 6321 for (key in oldAttrs) { 6322 if (isUndef(attrs[key])) { 6323 if (isXlink(key)) { 6324 elm.removeAttributeNS(xlinkNS, getXlinkProp(key)); 6325 } else if (!isEnumeratedAttr(key)) { 6326 elm.removeAttribute(key); 6327 } 6328 } 6329 } 6330 } 6331 6332 function setAttr(el, key, value) { 6333 if (el.tagName.indexOf('-') > -1) { 6334 baseSetAttr(el, key, value); 6335 } else if (isBooleanAttr(key)) { 6336 // set attribute for blank value 6337 // e.g. <option disabled>Select one</option> 6338 if (isFalsyAttrValue(value)) { 6339 el.removeAttribute(key); 6340 } else { 6341 // technically allowfullscreen is a boolean attribute for <iframe>, 6342 // but Flash expects a value of "true" when used on <embed> tag 6343 value = key === 'allowfullscreen' && el.tagName === 'EMBED' ? 6344 'true' : 6345 key; 6346 el.setAttribute(key, value); 6347 } 6348 } else if (isEnumeratedAttr(key)) { 6349 el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true'); 6350 } else if (isXlink(key)) { 6351 if (isFalsyAttrValue(value)) { 6352 el.removeAttributeNS(xlinkNS, getXlinkProp(key)); 6353 } else { 6354 el.setAttributeNS(xlinkNS, key, value); 6355 } 6356 } else { 6357 baseSetAttr(el, key, value); 6358 } 6359 } 6360 6361 function baseSetAttr(el, key, value) { 6362 if (isFalsyAttrValue(value)) { 6363 el.removeAttribute(key); 6364 } else { 6365 // #7138: IE10 & 11 fires input event when setting placeholder on 6366 // <textarea>... block the first input event and remove the blocker 6367 // immediately. 6368 /* istanbul ignore if */ 6369 if ( 6370 isIE && !isIE9 && 6371 el.tagName === 'TEXTAREA' && 6372 key === 'placeholder' && !el.__ieph 6373 ) { 6374 var blocker = function(e) { 6375 e.stopImmediatePropagation(); 6376 el.removeEventListener('input', blocker); 6377 }; 6378 el.addEventListener('input', blocker); 6379 // $flow-disable-line 6380 el.__ieph = true; /* IE placeholder patched */ 6381 } 6382 el.setAttribute(key, value); 6383 } 6384 } 6385 6386 var attrs = { 6387 create: updateAttrs, 6388 update: updateAttrs 6389 } 6390 6391 /* */ 6392 6393 function updateClass(oldVnode, vnode) { 6394 var el = vnode.elm; 6395 var data = vnode.data; 6396 var oldData = oldVnode.data; 6397 if ( 6398 isUndef(data.staticClass) && 6399 isUndef(data.class) && ( 6400 isUndef(oldData) || ( 6401 isUndef(oldData.staticClass) && 6402 isUndef(oldData.class) 6403 ) 6404 ) 6405 ) { 6406 return 6407 } 6408 6409 var cls = genClassForVnode(vnode); 6410 6411 // handle transition classes 6412 var transitionClass = el._transitionClasses; 6413 if (isDef(transitionClass)) { 6414 cls = concat(cls, stringifyClass(transitionClass)); 6415 } 6416 6417 // set the class 6418 if (cls !== el._prevClass) { 6419 el.setAttribute('class', cls); 6420 el._prevClass = cls; 6421 } 6422 } 6423 6424 var klass = { 6425 create: updateClass, 6426 update: updateClass 6427 } 6428 6429 /* */ 6430
6431 var validDivisionCharRE = /[\w).+\-_$\]]/; 6432 6433 function parseFilters(exp) { 6434 var inSingle = false; 6435 var inDouble = false; 6436 var inTemplateString = false; 6437 var inRegex = false; 6438 var curly = 0; 6439 var square = 0; 6440 var paren = 0; 6441 var lastFilterIndex = 0; 6442 var c, prev, i, expression, filters; 6443 6444 for (i = 0; i < exp.length; i++) { 6445 prev = c; 6446 c = exp.charCodeAt(i); 6447 if (inSingle) { 6448 if (c === 0x27 && prev !== 0x5C) { inSingle = false; } 6449 } else if (inDouble) { 6450 if (c === 0x22 && prev !== 0x5C) { inDouble = false; } 6451 } else if (inTemplateString) { 6452 if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; } 6453 } else if (inRegex) { 6454 if (c === 0x2f && prev !== 0x5C) { inRegex = false; } 6455 } else if ( 6456 c === 0x7C && // pipe 6457 exp.charCodeAt(i + 1) !== 0x7C && 6458 exp.charCodeAt(i - 1) !== 0x7C && 6459 !curly && !square && !paren 6460 ) { 6461 if (expression === undefined) { 6462 // first filter, end of expression 6463 lastFilterIndex = i + 1; 6464 expression = exp.slice(0, i).trim(); 6465 } else { 6466 pushFilter(); 6467 } 6468 } else { 6469 switch (c) { 6470 case 0x22: 6471 inDouble = true; 6472 break // " 6473 case 0x27: 6474 inSingle = true; 6475 break // ' 6476 case 0x60: 6477 inTemplateString = true; 6478 break // ` 6479 case 0x28: 6480 paren++; 6481 break // ( 6482 case 0x29: 6483 paren--; 6484 break // ) 6485 case 0x5B: 6486 square++; 6487 break // [ 6488 case 0x5D: 6489 square--; 6490 break // ] 6491 case 0x7B: 6492 curly++; 6493 break // { 6494 case 0x7D: 6495 curly--; 6496 break // } 6497 } 6498 if (c === 0x2f) { // / 6499 var j = i - 1; 6500 var p = (void 0); 6501 // find first non-whitespace prev char 6502 for (; j >= 0; j--) { 6503 p = exp.charAt(j); 6504 if (p !== ' ') { break } 6505 } 6506 if (!p || !validDivisionCharRE.test(p)) { 6507 inRegex = true; 6508 } 6509 } 6510 } 6511 } 6512 6513 if (expression === undefined) { 6514 expression = exp.slice(0, i).trim(); 6515 } else if (lastFilterIndex !== 0) { 6516 pushFilter(); 6517 } 6518 6519 function pushFilter() { 6520 (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim()); 6521 lastFilterIndex = i + 1; 6522 } 6523 6524 if (filters) { 6525 for (i = 0; i < filters.length; i++) { 6526 expression = wrapFilter(expression, filters[i]); 6527 } 6528 } 6529 6530 return expression 6531 } 6532 6533 function wrapFilter(exp, filter) { 6534 var i = filter.indexOf('('); 6535 if (i < 0) { 6536 // _f: resolveFilter 6537 return ("_f(\"" + filter + "\")(" + exp + ")") 6538 } else { 6539 var name = filter.slice(0, i); 6540 var args = filter.slice(i + 1); 6541 return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args)) 6542 } 6543 } 6544 6545 /* */ 6546 6547 function baseWarn(msg) { 6548 console.error(("[Vue compiler]: " + msg)); 6549 } 6550 6551 function pluckModuleFunction( 6552 modules, 6553 key 6554 ) { 6555 return modules ? 6556 modules.map(function(m) { return m[key]; }).filter(function(_) { return _; }) : 6557 [] 6558 } 6559 6560 function addProp(el, name, value) { 6561 (el.props || (el.props = [])).push({ name: name, value: value });
6562 el.plain = false; 6563 } 6564 6565 function addAttr(el, name, value) { 6566 (el.attrs || (el.attrs = [])).push({ name: name, value: value }); 6567 el.plain = false; 6568 } 6569 6570 // add a raw attr (use this in preTransforms) 6571 function addRawAttr(el, name, value) { 6572 el.attrsMap[name] = value; 6573 el.attrsList.push({ name: name, value: value }); 6574 } 6575 6576 function addDirective( 6577 el, 6578 name, 6579 rawName, 6580 value, 6581 arg, 6582 modifiers 6583 ) { 6584 (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers }); 6585 el.plain = false; 6586 } 6587 6588 function addHandler( 6589 el, 6590 name, 6591 value, 6592 modifiers, 6593 important, 6594 warn 6595 ) { 6596 modifiers = modifiers || emptyObject; 6597 // warn prevent and passive modifier 6598 /* istanbul ignore if */ 6599 if ( 6600 "development" !== 'production' && warn && 6601 modifiers.prevent && modifiers.passive 6602 ) { 6603 warn( 6604 'passive and prevent can\'t be used together. ' + 6605 'Passive handler can\'t prevent default event.' 6606 ); 6607 } 6608 6609 // check capture modifier 6610 if (modifiers.capture) { 6611 delete modifiers.capture; 6612 name = '!' + name; // mark the event as captured 6613 } 6614 if (modifiers.once) { 6615 delete modifiers.once; 6616 name = '~' + name; // mark the event as once 6617 } 6618 /* istanbul ignore if */ 6619 if (modifiers.passive) { 6620 delete modifiers.passive; 6621 name = '&' + name; // mark the event as passive 6622 } 6623 6624 // normalize click.right and click.middle since they don't actually fire 6625 // this is technically browser-specific, but at least for now browsers are 6626 // the only target envs that have right/middle clicks. 6627 if (name === 'click') { 6628 if (modifiers.right) { 6629 name = 'contextmenu'; 6630 delete modifiers.right; 6631 } else if (modifiers.middle) { 6632 name = 'mouseup'; 6633 } 6634 } 6635 6636 var events; 6637 if (modifiers.native) { 6638 delete modifiers.native; 6639 events = el.nativeEvents || (el.nativeEvents = {}); 6640 } else { 6641 events = el.events || (el.events = {}); 6642 } 6643 6644 var newHandler = { 6645 value: value.trim() 6646 }; 6647 if (modifiers !== emptyObject) { 6648 newHandler.modifiers = modifiers; 6649 } 6650 6651 var handlers = events[name]; 6652 /* istanbul ignore if */ 6653 if (Array.isArray(handlers)) { 6654 important ? handlers.unshift(newHandler) : handlers.push(newHandler); 6655 } else if (handlers) { 6656 events[name] = important ? [newHandler, handlers] : [handlers, newHandler]; 6657 } else { 6658 events[name] = newHandler; 6659 } 6660 6661 el.plain = false; 6662 } 6663 6664 function getBindingAttr( 6665 el, 6666 name, 6667 getStatic 6668 ) { 6669 var dynamicValue = 6670 getAndRemoveAttr(el, ':' + name) || 6671 getAndRemoveAttr(el, 'v-bind:' + name); 6672 if (dynamicValue != null) { 6673 return parseFilters(dynamicValue) 6674 } else if (getStatic !== false) { 6675 var staticValue = getAndRemoveAttr(el, name); 6676 if (staticValue != null) { 6677 return JSON.stringify(staticValue) 6678 } 6679 } 6680 } 6681 6682 // note: this only removes the attr from the Array (attrsList) so that it 6683 // doesn't get processed by processAttrs. 6684 // By default it does NOT remove it from the map (attrsMap) because the map is 6685 // needed during codegen. 6686 function getAndRemoveAttr( 6687 el, 6688 name, 6689 removeFromMap 6690 ) { 6691 var val; 6692 if ((val = el.attrsMap[name]) != null) { 6693 var list = el.attrsList; 6694 for (var i = 0, l = list.length; i < l; i++) { 6695 if (list[i].name === name) { 6696 list.splice(i, 1); 6697 break 6698 } 6699 } 6700 } 6701 if (removeFromMap) { 6702 delete el.attrsMap[name]; 6703 } 6704 return val 6705 } 6706 6707 /* */ 6708 6709 /** 6710 * Cross-platform code generation for component v-model 6711 */ 6712 function genComponentModel( 6713 el, 6714 value, 6715 modifiers 6716 ) { 6717 var ref = modifiers || {}; 6718 var number = ref.number; 6719 var trim = ref.trim; 6720 6721 var baseValueExpression = '$$v'; 6722 var valueExpression = baseValueExpression; 6723 if (trim) { 6724 valueExpression = 6725 "(typeof " + baseValueExpression + " === 'string'" + 6726 "? " + baseValueExpression + ".trim()" + 6727 ": " + baseValueExpression + ")"; 6728 } 6729 if (number) { 6730 valueExpression = "_n(" + valueExpression + ")"; 6731 }
6732 var assignment = genAssignmentCode(value, valueExpression); 6733 6734 el.model = { 6735 value: ("(" + value + ")"), 6736 expression: ("\"" + value + "\""), 6737 callback: ("function (" + baseValueExpression + ") {" + assignment + "}") 6738 }; 6739 } 6740 6741 /** 6742 * Cross-platform codegen helper for generating v-model value assignment code. 6743 */ 6744 function genAssignmentCode( 6745 value, 6746 assignment 6747 ) { 6748 var res = parseModel(value); 6749 if (res.key === null) { 6750 return (value + "=" + assignment) 6751 } else { 6752 return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")") 6753 } 6754 } 6755 6756 /** 6757 * Parse a v-model expression into a base path and a final key segment. 6758 * Handles both dot-path and possible square brackets. 6759 * 6760 * Possible cases: 6761 * 6762 * - test 6763 * - test[key] 6764 * - test[test1[key]] 6765 * - test["a"][key] 6766 * - xxx.test[a[a].test1[key]] 6767 * - test.xxx.a["asa"][test1[key]] 6768 * 6769 */ 6770 6771 var len; 6772 var str; 6773 var chr; 6774 var index$1; 6775 var expressionPos; 6776 var expressionEndPos; 6777 6778 6779 6780 function parseModel(val) { 6781 // Fix https://github.com/vuejs/vue/pull/7730 6782 // allow v-model="obj.val " (trailing whitespace) 6783 val = val.trim(); 6784 len = val.length; 6785 6786 if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) { 6787 index$1 = val.lastIndexOf('.'); 6788 if (index$1 > -1) { 6789 return { 6790 exp: val.slice(0, index$1), 6791 key: '"' + val.slice(index$1 + 1) + '"' 6792 } 6793 } else { 6794 return { 6795 exp: val, 6796 key: null 6797 } 6798 } 6799 } 6800 6801 str = val; 6802 index$1 = expressionPos = expressionEndPos = 0; 6803 6804 while (!eof()) { 6805 chr = next(); 6806 /* istanbul ignore if */ 6807 if (isStringStart(chr)) { 6808 parseString(chr); 6809 } else if (chr === 0x5B) { 6810 parseBracket(chr); 6811 } 6812 } 6813 6814 return { 6815 exp: val.slice(0, expressionPos), 6816 key: val.slice(expressionPos + 1, expressionEndPos) 6817 } 6818 } 6819 6820 function next() { 6821 return str.charCodeAt(++index$1) 6822 } 6823 6824 function eof() { 6825 return index$1 >= len 6826 } 6827 6828 function isStringStart(chr) { 6829 return chr === 0x22 || chr === 0x27 6830 } 6831 6832 function parseBracket(chr) { 6833 var inBracket = 1; 6834 expressionPos = index$1; 6835 while (!eof()) { 6836 chr = next(); 6837 if (isStringStart(chr)) { 6838 parseString(chr); 6839 continue 6840 } 6841 if (chr === 0x5B) { inBracket++; } 6842 if (chr === 0x5D) { inBracket--; } 6843 if (inBracket === 0) { 6844 expressionEndPos = index$1; 6845 break 6846 } 6847 } 6848 } 6849 6850 function parseString(chr) { 6851 var stringQuote = chr; 6852 while (!eof()) { 6853 chr = next(); 6854 if (chr === stringQuote) { 6855 break 6856 } 6857 } 6858 } 6859 6860 /* */ 6861 6862 var warn$1; 6863 6864 // in some cases, the event used has to be determined at runtime 6865 // so we used some reserved tokens during compile. 6866 var RANGE_TOKEN = '__r'; 6867 var CHECKBOX_RADIO_TOKEN = '__c'; 6868 6869 function model( 6870 el, 6871 dir, 6872 _warn 6873 ) { 6874 warn$1 = _warn; 6875 var value = dir.value; 6876 var modifiers = dir.modifiers; 6877 var tag = el.tag; 6878 var type = el.attrsMap.type; 6879 6880 { 6881 // inputs with type="file" are read only and setting the input's 6882 // value will throw an error. 6883 if (tag === 'input' && type === 'file') { 6884 warn$1( 6885 "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" + 6886 "File inputs are read only. Use a v-on:change listener instead." 6887 ); 6888 } 6889 } 6890 6891 if (el.component) { 6892 genComponentModel(el, value, modifiers); 6893 // component v-model doesn't need extra runtime 6894 return false 6895 } else if (tag === 'select') { 6896 genSelect(el, value, modifiers); 6897 } else if (tag === 'input' && type === 'checkbox') {
6898 genCheckboxModel(el, value, modifiers); 6899 } else if (tag === 'input' && type === 'radio') { 6900 genRadioModel(el, value, modifiers); 6901 } else if (tag === 'input' || tag === 'textarea') { 6902 genDefaultModel(el, value, modifiers); 6903 } else if (!config.isReservedTag(tag)) { 6904 genComponentModel(el, value, modifiers); 6905 // component v-model doesn't need extra runtime 6906 return false 6907 } else { 6908 warn$1( 6909 "<" + (el.tag) + " v-model=\"" + value + "\">: " + 6910 "v-model is not supported on this element type. " + 6911 'If you are working with contenteditable, it\'s recommended to ' + 6912 'wrap a library dedicated for that purpose inside a custom component.' 6913 ); 6914 } 6915 6916 // ensure runtime directive metadata 6917 return true 6918 } 6919 6920 function genCheckboxModel( 6921 el, 6922 value, 6923 modifiers 6924 ) { 6925 var number = modifiers && modifiers.number; 6926 var valueBinding = getBindingAttr(el, 'value') || 'null'; 6927 var trueValueBinding = getBindingAttr(el, 'true-value') || 'true'; 6928 var falseValueBinding = getBindingAttr(el, 'false-value') || 'false'; 6929 addProp(el, 'checked', 6930 "Array.isArray(" + value + ")" + 6931 "?_i(" + value + "," + valueBinding + ")>-1" + ( 6932 trueValueBinding === 'true' ? 6933 (":(" + value + ")") : 6934 (":_q(" + value + "," + trueValueBinding + ")") 6935 ) 6936 ); 6937 addHandler(el, 'change', 6938 "var $$a=" + value + "," + 6939 '$$el=$event.target,' + 6940 "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" + 6941 'if(Array.isArray($$a)){' + 6942 "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," + 6943 '$$i=_i($$a,$$v);' + 6944 "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" + 6945 "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" + 6946 "}else{" + (genAssignmentCode(value, '$$c')) + "}", 6947 null, true 6948 ); 6949 } 6950 6951 function genRadioModel( 6952 el, 6953 value, 6954 modifiers 6955 ) { 6956 var number = modifiers && modifiers.number; 6957 var valueBinding = getBindingAttr(el, 'value') || 'null'; 6958 valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding; 6959 addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")")); 6960 addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true); 6961 } 6962 6963 function genSelect( 6964 el, 6965 value, 6966 modifiers 6967 ) { 6968 var number = modifiers && modifiers.number; 6969 var selectedVal = "Array.prototype.filter" + 6970 ".call($event.target.options,function(o){return o.selected})" + 6971 ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" + 6972 "return " + (number ? '_n(val)' : 'val') + "})"; 6973 6974 var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]'; 6975 var code = "var $$selectedVal = " + selectedVal + ";"; 6976 code = code + " " + (genAssignmentCode(value, assignment)); 6977 addHandler(el, 'change', code, null, true); 6978 } 6979 6980 function genDefaultModel( 6981 el, 6982 value, 6983 modifiers 6984 ) { 6985 var type = el.attrsMap.type; 6986 6987 // warn if v-bind:value conflicts with v-model 6988 // except for inputs with v-bind:type 6989 { 6990 var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value']; 6991 var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type']; 6992 if (value$1 && !typeBinding) { 6993 var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value'; 6994 warn$1( 6995 binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " + 6996 'because the latter already expands to a value binding internally' 6997 ); 6998 } 6999 } 7000 7001 var ref = modifiers || {}; 7002 var lazy = ref.lazy; 7003 var number = ref.number; 7004 var trim = ref.trim; 7005 var needCompositionGuard = !lazy && type !== 'range'; 7006 var event = lazy ? 7007 'change' : 7008 type === 'range' ? 7009 RANGE_TOKEN : 7010 'input'; 7011 7012 var valueExpression = '$event.target.value'; 7013 if (trim) { 7014 valueExpression = "$event.target.value.trim()"; 7015 } 7016 if (number) { 7017 valueExpression = "_n(" + valueExpression + ")"; 7018 } 7019
vendor: 12,204 bytes, lines 7020-7384
7020 var code = genAssignmentCode(value, valueExpression); 7021 if (needCompositionGuard) { 7022 code = "if($event.target.composing)return;" + code; 7023 } 7024 7025 addProp(el, 'value', ("(" + value + ")")); 7026 addHandler(el, event, code, null, true); 7027 if (trim || number) { 7028 addHandler(el, 'blur', '$forceUpdate()'); 7029 } 7030 } 7031 7032 /* */ 7033 7034 // normalize v-model event tokens that can only be determined at runtime. 7035 // it's important to place the event as the first in the array because 7036 // the whole point is ensuring the v-model callback gets called before 7037 // user-attached handlers. 7038 function normalizeEvents(on) { 7039 /* istanbul ignore if */ 7040 if (isDef(on[RANGE_TOKEN])) { 7041 // IE input[type=range] only supports `change` event 7042 var event = isIE ? 'change' : 'input'; 7043 on[event] = [].concat(on[RANGE_TOKEN], on[event] || []); 7044 delete on[RANGE_TOKEN]; 7045 } 7046 // This was originally intended to fix #4521 but no longer necessary 7047 // after 2.5. Keeping it for backwards compat with generated code from < 2.4 7048 /* istanbul ignore if */ 7049 if (isDef(on[CHECKBOX_RADIO_TOKEN])) { 7050 on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []); 7051 delete on[CHECKBOX_RADIO_TOKEN]; 7052 } 7053 } 7054 7055 var target$1; 7056 7057 function createOnceHandler(handler, event, capture) { 7058 var _target = target$1; // save current target element in closure 7059 return function onceHandler() { 7060 var res = handler.apply(null, arguments); 7061 if (res !== null) { 7062 remove$2(event, onceHandler, capture, _target); 7063 } 7064 } 7065 } 7066 7067 function add$1( 7068 event, 7069 handler, 7070 once$$1, 7071 capture, 7072 passive 7073 ) { 7074 handler = withMacroTask(handler); 7075 if (once$$1) { handler = createOnceHandler(handler, event, capture); } 7076 target$1.addEventListener( 7077 event, 7078 handler, 7079 supportsPassive ? 7080 { capture: capture, passive: passive } : 7081 capture 7082 ); 7083 } 7084 7085 function remove$2( 7086 event, 7087 handler, 7088 capture, 7089 _target 7090 ) { 7091 (_target || target$1).removeEventListener( 7092 event, 7093 handler._withTask || handler, 7094 capture 7095 ); 7096 } 7097 7098 function updateDOMListeners(oldVnode, vnode) { 7099 if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) { 7100 return 7101 } 7102 var on = vnode.data.on || {}; 7103 var oldOn = oldVnode.data.on || {}; 7104 target$1 = vnode.elm; 7105 normalizeEvents(on); 7106 updateListeners(on, oldOn, add$1, remove$2, vnode.context); 7107 target$1 = undefined; 7108 } 7109 7110 var events = { 7111 create: updateDOMListeners, 7112 update: updateDOMListeners 7113 } 7114 7115 /* */ 7116 7117 function updateDOMProps(oldVnode, vnode) { 7118 if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) { 7119 return 7120 } 7121 var key, cur; 7122 var elm = vnode.elm; 7123 var oldProps = oldVnode.data.domProps || {}; 7124 var props = vnode.data.domProps || {}; 7125 // clone observed objects, as the user probably wants to mutate it 7126 if (isDef(props.__ob__)) { 7127 props = vnode.data.domProps = extend({}, props); 7128 } 7129 7130 for (key in oldProps) { 7131 if (isUndef(props[key])) { 7132 elm[key] = ''; 7133 } 7134 } 7135 for (key in props) { 7136 cur = props[key]; 7137 // ignore children if the node has textContent or innerHTML, 7138 // as these will throw away existing DOM nodes and cause removal errors 7139 // on subsequent patches (#3360) 7140 if (key === 'textContent' || key === 'innerHTML') { 7141 if (vnode.children) { vnode.children.length = 0; } 7142 if (cur === oldProps[key]) { continue } 7143 // #6601 work around Chrome version <= 55 bug where single textNode 7144 // replaced by innerHTML/textContent retains its parentNode property 7145 if (elm.childNodes.length === 1) { 7146 elm.removeChild(elm.childNodes[0]); 7147 } 7148 } 7149 7150 if (key === 'value') { 7151 // store value as _value as well since 7152 // non-string values will be stringified 7153 elm._value = cur; 7154 // avoid resetting cursor position when value is the same 7155 var strCur = isUndef(cur) ? '' : String(cur); 7156 if (shouldUpdateValue(elm, strCur)) { 7157 elm.value = strCur; 7158 } 7159 } else { 7160 elm[key] = cur; 7161 } 7162 } 7163 } 7164 7165 // check platforms/web/util/attrs.js acceptValue 7166 7167 7168 function shouldUpdateValue(elm, checkVal) { 7169 return (!elm.composing && ( 7170 elm.tagName === 'OPTION' || 7171 isNotInFocusAndDirty(elm, checkVal) || 7172 isDirtyWithModifiers(elm, checkVal) 7173 )) 7174 } 7175 7176 function isNotInFocusAndDirty(elm, checkVal) { 7177 // return true when textbox (.number and .trim) loses focus and its value is 7178 // not equal to the updated value 7179 var notInFocus = true; 7180 // #6157 7181 // work around IE bug when accessing document.activeElement in an iframe 7182 try { notInFocus = document.activeElement !== elm; } catch (e) {} 7183 return notInFocus && elm.value !== checkVal 7184 } 7185 7186 function isDirtyWithModifiers(elm, newVal) { 7187 var value = elm.value; 7188 var modifiers = elm._vModifiers; // injected by v-model runtime 7189 if (isDef(modifiers)) { 7190 if (modifiers.lazy) { 7191 // inputs with lazy should only be updated when not in focus 7192 return false 7193 } 7194 if (modifiers.number) { 7195 return toNumber(value) !== toNumber(newVal) 7196 } 7197 if (modifiers.trim) { 7198 return value.trim() !== newVal.trim() 7199 } 7200 } 7201 return value !== newVal 7202 } 7203 7204 var domProps = { 7205 create: updateDOMProps, 7206 update: updateDOMProps 7207 } 7208 7209 /* */ 7210 7211 var parseStyleText = cached(function(cssText) { 7212 var res = {}; 7213 var listDelimiter = /;(?![^(]*\))/g; 7214 var propertyDelimiter = /:(.+)/; 7215 cssText.split(listDelimiter).forEach(function(item) { 7216 if (item) { 7217 var tmp = item.split(propertyDelimiter); 7218 tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim()); 7219 } 7220 }); 7221 return res 7222 }); 7223 7224 // merge static and dynamic style data on the same vnode 7225 function normalizeStyleData(data) { 7226 var style = normalizeStyleBinding(data.style); 7227 // static style is pre-processed into an object during compilation 7228 // and is always a fresh object, so it's safe to merge into it 7229 return data.staticStyle ? 7230 extend(data.staticStyle, style) : 7231 style 7232 } 7233 7234 // normalize possible array / string values into Object 7235 function normalizeStyleBinding(bindingStyle) { 7236 if (Array.isArray(bindingStyle)) { 7237 return toObject(bindingStyle) 7238 } 7239 if (typeof bindingStyle === 'string') { 7240 return parseStyleText(bindingStyle) 7241 } 7242 return bindingStyle 7243 } 7244 7245 /** 7246 * parent component style should be after child's 7247 * so that parent component's style could override it 7248 */ 7249 function getStyle(vnode, checkChild) { 7250 var res = {}; 7251 var styleData; 7252 7253 if (checkChild) { 7254 var childNode = vnode; 7255 while (childNode.componentInstance) { 7256 childNode = childNode.componentInstance._vnode; 7257 if ( 7258 childNode && childNode.data && 7259 (styleData = normalizeStyleData(childNode.data)) 7260 ) { 7261 extend(res, styleData); 7262 } 7263 } 7264 } 7265 7266 if ((styleData = normalizeStyleData(vnode.data))) { 7267 extend(res, styleData); 7268 } 7269 7270 var parentNode = vnode; 7271 while ((parentNode = parentNode.parent)) { 7272 if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) { 7273 extend(res, styleData); 7274 } 7275 } 7276 return res 7277 } 7278 7279 /* */ 7280 7281 var cssVarRE = /^--/; 7282 var importantRE = /\s*!important$/; 7283 var setProp = function(el, name, val) { 7284 /* istanbul ignore if */ 7285 if (cssVarRE.test(name)) { 7286 el.style.setProperty(name, val); 7287 } else if (importantRE.test(val)) { 7288 el.style.setProperty(name, val.replace(importantRE, ''), 'important'); 7289 } else { 7290 var normalizedName = normalize(name); 7291 if (Array.isArray(val)) { 7292 // Support values array created by autoprefixer, e.g. 7293 // {display: ["-webkit-box", "-ms-flexbox", "flex"]} 7294 // Set them one by one, and the browser will only set those it can recognize 7295 for (var i = 0, len = val.length; i < len; i++) { 7296 el.style[normalizedName] = val[i]; 7297 } 7298 } else { 7299 el.style[normalizedName] = val; 7300 } 7301 } 7302 }; 7303 7304 var vendorNames = ['Webkit', 'Moz', 'ms']; 7305 7306 var emptyStyle; 7307 var normalize = cached(function(prop) { 7308 emptyStyle = emptyStyle || document.createElement('div').style; 7309 prop = camelize(prop); 7310 if (prop !== 'filter' && (prop in emptyStyle)) { 7311 return prop 7312 } 7313 var capName = prop.charAt(0).toUpperCase() + prop.slice(1); 7314 for (var i = 0; i < vendorNames.length; i++) { 7315 var name = vendorNames[i] + capName; 7316 if (name in emptyStyle) { 7317 return name 7318 } 7319 } 7320 }); 7321 7322 function updateStyle(oldVnode, vnode) { 7323 var data = vnode.data; 7324 var oldData = oldVnode.data; 7325 7326 if (isUndef(data.staticStyle) && isUndef(data.style) && 7327 isUndef(oldData.staticStyle) && isUndef(oldData.style) 7328 ) { 7329 return 7330 } 7331 7332 var cur, name; 7333 var el = vnode.elm; 7334 var oldStaticStyle = oldData.staticStyle; 7335 var oldStyleBinding = oldData.normalizedStyle || oldData.style || {}; 7336 7337 // if static style exists, stylebinding already merged into it when doing normalizeStyleData 7338 var oldStyle = oldStaticStyle || oldStyleBinding; 7339 7340 var style = normalizeStyleBinding(vnode.data.style) || {}; 7341 7342 // store normalized style under a different key for next diff 7343 // make sure to clone it if it's reactive, since the user likely wants 7344 // to mutate it. 7345 vnode.data.normalizedStyle = isDef(style.__ob__) ? 7346 extend({}, style) : 7347 style; 7348 7349 var newStyle = getStyle(vnode, true); 7350 7351 for (name in oldStyle) { 7352 if (isUndef(newStyle[name])) { 7353 setProp(el, name, ''); 7354 } 7355 } 7356 for (name in newStyle) { 7357 cur = newStyle[name]; 7358 if (cur !== oldStyle[name]) { 7359 // ie9 setting to null has no effect, must use empty string 7360 setProp(el, name, cur == null ? '' : cur); 7361 } 7362 } 7363 } 7364 7365 var style = { 7366 create: updateStyle, 7367 update: updateStyle 7368 } 7369 7370 /* */ 7371 7372 /** 7373 * Add class with compatibility for SVG since classList is not supported on 7374 * SVG elements in IE 7375 */ 7376 function addClass(el, cls) { 7377 /* istanbul ignore if */ 7378 if (!cls || !(cls = cls.trim())) { 7379 return 7380 } 7381 7382 /* istanbul ignore else */ 7383 if (el.classList) { 7384 if (cls.indexOf(' ') > -1) {
vendor: 10,582 bytes, lines 7385-7702
7385 cls.split(/\s+/).forEach(function(c) { return el.classList.add(c); }); 7386 } else { 7387 el.classList.add(cls); 7388 } 7389 } else { 7390 var cur = " " + (el.getAttribute('class') || '') + " "; 7391 if (cur.indexOf(' ' + cls + ' ') < 0) { 7392 el.setAttribute('class', (cur + cls).trim()); 7393 } 7394 } 7395 } 7396 7397 /** 7398 * Remove class with compatibility for SVG since classList is not supported on 7399 * SVG elements in IE 7400 */ 7401 function removeClass(el, cls) { 7402 /* istanbul ignore if */ 7403 if (!cls || !(cls = cls.trim())) { 7404 return 7405 } 7406 7407 /* istanbul ignore else */ 7408 if (el.classList) { 7409 if (cls.indexOf(' ') > -1) { 7410 cls.split(/\s+/).forEach(function(c) { return el.classList.remove(c); }); 7411 } else { 7412 el.classList.remove(cls); 7413 } 7414 if (!el.classList.length) { 7415 el.removeAttribute('class'); 7416 } 7417 } else { 7418 var cur = " " + (el.getAttribute('class') || '') + " "; 7419 var tar = ' ' + cls + ' '; 7420 while (cur.indexOf(tar) >= 0) { 7421 cur = cur.replace(tar, ' '); 7422 } 7423 cur = cur.trim(); 7424 if (cur) { 7425 el.setAttribute('class', cur); 7426 } else { 7427 el.removeAttribute('class'); 7428 } 7429 } 7430 } 7431 7432 /* */ 7433 7434 function resolveTransition(def) { 7435 if (!def) { 7436 return 7437 } 7438 /* istanbul ignore else */ 7439 if (typeof def === 'object') { 7440 var res = {}; 7441 if (def.css !== false) { 7442 extend(res, autoCssTransition(def.name || 'v')); 7443 } 7444 extend(res, def); 7445 return res 7446 } else if (typeof def === 'string') { 7447 return autoCssTransition(def) 7448 } 7449 } 7450 7451 var autoCssTransition = cached(function(name) { 7452 return { 7453 enterClass: (name + "-enter"), 7454 enterToClass: (name + "-enter-to"), 7455 enterActiveClass: (name + "-enter-active"), 7456 leaveClass: (name + "-leave"), 7457 leaveToClass: (name + "-leave-to"), 7458 leaveActiveClass: (name + "-leave-active") 7459 } 7460 }); 7461 7462 var hasTransition = inBrowser && !isIE9; 7463 var TRANSITION = 'transition'; 7464 var ANIMATION = 'animation'; 7465 7466 // Transition property/event sniffing 7467 var transitionProp = 'transition'; 7468 var transitionEndEvent = 'transitionend'; 7469 var animationProp = 'animation'; 7470 var animationEndEvent = 'animationend'; 7471 if (hasTransition) { 7472 /* istanbul ignore if */ 7473 if (window.ontransitionend === undefined && 7474 window.onwebkittransitionend !== undefined 7475 ) { 7476 transitionProp = 'WebkitTransition'; 7477 transitionEndEvent = 'webkitTransitionEnd'; 7478 } 7479 if (window.onanimationend === undefined && 7480 window.onwebkitanimationend !== undefined 7481 ) { 7482 animationProp = 'WebkitAnimation'; 7483 animationEndEvent = 'webkitAnimationEnd'; 7484 } 7485 } 7486 7487 // binding to window is necessary to make hot reload work in IE in strict mode 7488 var raf = inBrowser ? 7489 window.requestAnimationFrame ? 7490 window.requestAnimationFrame.bind(window) : 7491 setTimeout : 7492 /* istanbul ignore next */ function(fn) { return fn(); }; 7493 7494 function nextFrame(fn) { 7495 raf(function() { 7496 raf(fn); 7497 }); 7498 } 7499 7500 function addTransitionClass(el, cls) { 7501 var transitionClasses = el._transitionClasses || (el._transitionClasses = []); 7502 if (transitionClasses.indexOf(cls) < 0) { 7503 transitionClasses.push(cls); 7504 addClass(el, cls); 7505 } 7506 } 7507 7508 function removeTransitionClass(el, cls) { 7509 if (el._transitionClasses) { 7510 remove(el._transitionClasses, cls); 7511 } 7512 removeClass(el, cls); 7513 } 7514 7515 function whenTransitionEnds( 7516 el, 7517 expectedType, 7518 cb 7519 ) { 7520 var ref = getTransitionInfo(el, expectedType); 7521 var type = ref.type; 7522 var timeout = ref.timeout; 7523 var propCount = ref.propCount; 7524 if (!type) { return cb() } 7525 var event = type === TRANSITION ? transitionEndEvent : animationEndEvent; 7526 var ended = 0; 7527 var end = function() { 7528 el.removeEventListener(event, onEnd); 7529 cb(); 7530 }; 7531 var onEnd = function(e) { 7532 if (e.target === el) { 7533 if (++ended >= propCount) { 7534 end(); 7535 } 7536 } 7537 }; 7538 setTimeout(function() { 7539 if (ended < propCount) { 7540 end(); 7541 } 7542 }, timeout + 1); 7543 el.addEventListener(event, onEnd); 7544 } 7545 7546 var transformRE = /\b(transform|all)(,|$)/; 7547 7548 function getTransitionInfo(el, expectedType) { 7549 var styles = window.getComputedStyle(el); 7550 var transitionDelays = styles[transitionProp + 'Delay'].split(', '); 7551 var transitionDurations = styles[transitionProp + 'Duration'].split(', '); 7552 var transitionTimeout = getTimeout(transitionDelays, transitionDurations); 7553 var animationDelays = styles[animationProp + 'Delay'].split(', '); 7554 var animationDurations = styles[animationProp + 'Duration'].split(', '); 7555 var animationTimeout = getTimeout(animationDelays, animationDurations); 7556 7557 var type; 7558 var timeout = 0; 7559 var propCount = 0; 7560 /* istanbul ignore if */ 7561 if (expectedType === TRANSITION) { 7562 if (transitionTimeout > 0) { 7563 type = TRANSITION; 7564 timeout = transitionTimeout; 7565 propCount = transitionDurations.length; 7566 } 7567 } else if (expectedType === ANIMATION) { 7568 if (animationTimeout > 0) { 7569 type = ANIMATION; 7570 timeout = animationTimeout; 7571 propCount = animationDurations.length; 7572 } 7573 } else { 7574 timeout = Math.max(transitionTimeout, animationTimeout); 7575 type = timeout > 0 ? 7576 transitionTimeout > animationTimeout ? 7577 TRANSITION : 7578 ANIMATION : 7579 null; 7580 propCount = type ? 7581 type === TRANSITION ? 7582 transitionDurations.length : 7583 animationDurations.length : 7584 0; 7585 } 7586 var hasTransform = 7587 type === TRANSITION && 7588 transformRE.test(styles[transitionProp + 'Property']); 7589 return { 7590 type: type, 7591 timeout: timeout, 7592 propCount: propCount, 7593 hasTransform: hasTransform 7594 } 7595 } 7596 7597 function getTimeout(delays, durations) { 7598 /* istanbul ignore next */ 7599 while (delays.length < durations.length) { 7600 delays = delays.concat(delays); 7601 } 7602 7603 return Math.max.apply(null, durations.map(function(d, i) { 7604 return toMs(d) + toMs(delays[i]) 7605 })) 7606 } 7607 7608 function toMs(s) { 7609 return Number(s.slice(0, -1)) * 1000 7610 } 7611 7612 /* */ 7613 7614 function enter(vnode, toggleDisplay) { 7615 var el = vnode.elm; 7616 7617 // call leave callback now 7618 if (isDef(el._leaveCb)) { 7619 el._leaveCb.cancelled = true; 7620 el._leaveCb(); 7621 } 7622 7623 var data = resolveTransition(vnode.data.transition); 7624 if (isUndef(data)) { 7625 return 7626 } 7627 7628 /* istanbul ignore if */ 7629 if (isDef(el._enterCb) || el.nodeType !== 1) { 7630 return 7631 } 7632 7633 var css = data.css; 7634 var type = data.type; 7635 var enterClass = data.enterClass; 7636 var enterToClass = data.enterToClass; 7637 var enterActiveClass = data.enterActiveClass; 7638 var appearClass = data.appearClass; 7639 var appearToClass = data.appearToClass; 7640 var appearActiveClass = data.appearActiveClass; 7641 var beforeEnter = data.beforeEnter; 7642 var enter = data.enter; 7643 var afterEnter = data.afterEnter; 7644 var enterCancelled = data.enterCancelled; 7645 var beforeAppear = data.beforeAppear; 7646 var appear = data.appear; 7647 var afterAppear = data.afterAppear; 7648 var appearCancelled = data.appearCancelled; 7649 var duration = data.duration; 7650 7651 // activeInstance will always be the <transition> component managing this 7652 // transition. One edge case to check is when the <transition> is placed 7653 // as the root node of a child component. In that case we need to check 7654 // <transition>'s parent for appear check. 7655 var context = activeInstance; 7656 var transitionNode = activeInstance.$vnode; 7657 while (transitionNode && transitionNode.parent) { 7658 transitionNode = transitionNode.parent; 7659 context = transitionNode.context; 7660 } 7661 7662 var isAppear = !context._isMounted || !vnode.isRootInsert; 7663 7664 if (isAppear && !appear && appear !== '') { 7665 return 7666 } 7667 7668 var startClass = isAppear && appearClass ? 7669 appearClass : 7670 enterClass; 7671 var activeClass = isAppear && appearActiveClass ? 7672 appearActiveClass : 7673 enterActiveClass; 7674 var toClass = isAppear && appearToClass ? 7675 appearToClass : 7676 enterToClass; 7677 7678 var beforeEnterHook = isAppear ? 7679 (beforeAppear || beforeEnter) : 7680 beforeEnter; 7681 var enterHook = isAppear ? 7682 (typeof appear === 'function' ? appear : enter) : 7683 enter; 7684 var afterEnterHook = isAppear ? 7685 (afterAppear || afterEnter) : 7686 afterEnter; 7687 var enterCancelledHook = isAppear ? 7688 (appearCancelled || enterCancelled) : 7689 enterCancelled; 7690 7691 var explicitEnterDuration = toNumber( 7692 isObject(duration) ? 7693 duration.enter : 7694 duration 7695 ); 7696 7697 if ("development" !== 'production' && explicitEnterDuration != null) { 7698 checkDuration(explicitEnterDuration, 'enter', vnode); 7699 } 7700 7701 var expectsCSS = css !== false && !isIE9; 7702 var userWantsControl = getHookArgumentsLength(enterHook);
vendor: 15,349 bytes, lines 7703-8143
7703 7704 var cb = el._enterCb = once(function() { 7705 if (expectsCSS) { 7706 removeTransitionClass(el, toClass); 7707 removeTransitionClass(el, activeClass); 7708 } 7709 if (cb.cancelled) { 7710 if (expectsCSS) { 7711 removeTransitionClass(el, startClass); 7712 } 7713 enterCancelledHook && enterCancelledHook(el); 7714 } else { 7715 afterEnterHook && afterEnterHook(el); 7716 } 7717 el._enterCb = null; 7718 }); 7719 7720 if (!vnode.data.show) { 7721 // remove pending leave element on enter by injecting an insert hook 7722 mergeVNodeHook(vnode, 'insert', function() { 7723 var parent = el.parentNode; 7724 var pendingNode = parent && parent._pending && parent._pending[vnode.key]; 7725 if (pendingNode && 7726 pendingNode.tag === vnode.tag && 7727 pendingNode.elm._leaveCb 7728 ) { 7729 pendingNode.elm._leaveCb(); 7730 } 7731 enterHook && enterHook(el, cb); 7732 }); 7733 } 7734 7735 // start enter transition 7736 beforeEnterHook && beforeEnterHook(el); 7737 if (expectsCSS) { 7738 addTransitionClass(el, startClass); 7739 addTransitionClass(el, activeClass); 7740 nextFrame(function() { 7741 removeTransitionClass(el, startClass); 7742 if (!cb.cancelled) { 7743 addTransitionClass(el, toClass); 7744 if (!userWantsControl) { 7745 if (isValidDuration(explicitEnterDuration)) { 7746 setTimeout(cb, explicitEnterDuration); 7747 } else { 7748 whenTransitionEnds(el, type, cb); 7749 } 7750 } 7751 } 7752 }); 7753 } 7754 7755 if (vnode.data.show) { 7756 toggleDisplay && toggleDisplay(); 7757 enterHook && enterHook(el, cb); 7758 } 7759 7760 if (!expectsCSS && !userWantsControl) { 7761 cb(); 7762 } 7763 } 7764 7765 function leave(vnode, rm) { 7766 var el = vnode.elm; 7767 7768 // call enter callback now 7769 if (isDef(el._enterCb)) { 7770 el._enterCb.cancelled = true; 7771 el._enterCb(); 7772 } 7773 7774 var data = resolveTransition(vnode.data.transition); 7775 if (isUndef(data) || el.nodeType !== 1) { 7776 return rm() 7777 } 7778 7779 /* istanbul ignore if */ 7780 if (isDef(el._leaveCb)) { 7781 return 7782 } 7783 7784 var css = data.css; 7785 var type = data.type; 7786 var leaveClass = data.leaveClass; 7787 var leaveToClass = data.leaveToClass; 7788 var leaveActiveClass = data.leaveActiveClass; 7789 var beforeLeave = data.beforeLeave; 7790 var leave = data.leave; 7791 var afterLeave = data.afterLeave; 7792 var leaveCancelled = data.leaveCancelled; 7793 var delayLeave = data.delayLeave; 7794 var duration = data.duration; 7795 7796 var expectsCSS = css !== false && !isIE9; 7797 var userWantsControl = getHookArgumentsLength(leave); 7798 7799 var explicitLeaveDuration = toNumber( 7800 isObject(duration) ? 7801 duration.leave : 7802 duration 7803 ); 7804 7805 if ("development" !== 'production' && isDef(explicitLeaveDuration)) { 7806 checkDuration(explicitLeaveDuration, 'leave', vnode); 7807 } 7808 7809 var cb = el._leaveCb = once(function() { 7810 if (el.parentNode && el.parentNode._pending) { 7811 el.parentNode._pending[vnode.key] = null; 7812 } 7813 if (expectsCSS) { 7814 removeTransitionClass(el, leaveToClass); 7815 removeTransitionClass(el, leaveActiveClass); 7816 } 7817 if (cb.cancelled) { 7818 if (expectsCSS) { 7819 removeTransitionClass(el, leaveClass); 7820 } 7821 leaveCancelled && leaveCancelled(el); 7822 } else { 7823 rm(); 7824 afterLeave && afterLeave(el); 7825 } 7826 el._leaveCb = null; 7827 }); 7828 7829 if (delayLeave) { 7830 delayLeave(performLeave); 7831 } else { 7832 performLeave(); 7833 } 7834 7835 function performLeave() { 7836 // the delayed leave may have already been cancelled 7837 if (cb.cancelled) { 7838 return 7839 } 7840 // record leaving element 7841 if (!vnode.data.show) { 7842 (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode; 7843 } 7844 beforeLeave && beforeLeave(el); 7845 if (expectsCSS) { 7846 addTransitionClass(el, leaveClass); 7847 addTransitionClass(el, leaveActiveClass); 7848 nextFrame(function() { 7849 removeTransitionClass(el, leaveClass); 7850 if (!cb.cancelled) { 7851 addTransitionClass(el, leaveToClass); 7852 if (!userWantsControl) { 7853 if (isValidDuration(explicitLeaveDuration)) { 7854 setTimeout(cb, explicitLeaveDuration); 7855 } else { 7856 whenTransitionEnds(el, type, cb); 7857 } 7858 } 7859 } 7860 }); 7861 } 7862 leave && leave(el, cb); 7863 if (!expectsCSS && !userWantsControl) { 7864 cb(); 7865 } 7866 } 7867 } 7868 7869 // only used in dev mode 7870 function checkDuration(val, name, vnode) { 7871 if (typeof val !== 'number') { 7872 warn( 7873 "<transition> explicit " + name + " duration is not a valid number - " + 7874 "got " + (JSON.stringify(val)) + ".", 7875 vnode.context 7876 ); 7877 } else if (isNaN(val)) { 7878 warn( 7879 "<transition> explicit " + name + " duration is NaN - " + 7880 'the duration expression might be incorrect.', 7881 vnode.context 7882 ); 7883 } 7884 } 7885 7886 function isValidDuration(val) { 7887 return typeof val === 'number' && !isNaN(val) 7888 } 7889 7890 /** 7891 * Normalize a transition hook's argument length. The hook may be: 7892 * - a merged hook (invoker) with the original in .fns 7893 * - a wrapped component method (check ._length) 7894 * - a plain function (.length) 7895 */ 7896 function getHookArgumentsLength(fn) { 7897 if (isUndef(fn)) { 7898 return false 7899 } 7900 var invokerFns = fn.fns; 7901 if (isDef(invokerFns)) { 7902 // invoker 7903 return getHookArgumentsLength( 7904 Array.isArray(invokerFns) ? 7905 invokerFns[0] : 7906 invokerFns 7907 ) 7908 } else { 7909 return (fn._length || fn.length) > 1 7910 } 7911 } 7912 7913 function _enter(_, vnode) { 7914 if (vnode.data.show !== true) { 7915 enter(vnode); 7916 } 7917 } 7918 7919 var transition = inBrowser ? { 7920 create: _enter, 7921 activate: _enter, 7922 remove: function remove$$1(vnode, rm) { 7923 /* istanbul ignore else */ 7924 if (vnode.data.show !== true) { 7925 leave(vnode, rm); 7926 } else { 7927 rm(); 7928 } 7929 } 7930 } : {} 7931 7932 var platformModules = [ 7933 attrs, 7934 klass, 7935 events, 7936 domProps, 7937 style, 7938 transition 7939 ] 7940 7941 /* */ 7942 7943 // the directive module should be applied last, after all 7944 // built-in modules have been applied. 7945 var modules = platformModules.concat(baseModules); 7946 7947 var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules }); 7948 7949 /** 7950 * Not type checking this file because flow doesn't like attaching 7951 * properties to Elements. 7952 */ 7953 7954 /* istanbul ignore if */ 7955 if (isIE9) { 7956 // http://www.matts411.com/post/internet-explorer-9-oninput/ 7957 document.addEventListener('selectionchange', function() { 7958 var el = document.activeElement; 7959 if (el && el.vmodel) { 7960 trigger(el, 'input'); 7961 } 7962 }); 7963 } 7964 7965 var directive = { 7966 inserted: function inserted(el, binding, vnode, oldVnode) { 7967 if (vnode.tag === 'select') { 7968 // #6903 7969 if (oldVnode.elm && !oldVnode.elm._vOptions) { 7970 mergeVNodeHook(vnode, 'postpatch', function() { 7971 directive.componentUpdated(el, binding, vnode); 7972 }); 7973 } else { 7974 setSelected(el, binding, vnode.context); 7975 } 7976 el._vOptions = [].map.call(el.options, getValue); 7977 } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) { 7978 el._vModifiers = binding.modifiers; 7979 if (!binding.modifiers.lazy) { 7980 el.addEventListener('compositionstart', onCompositionStart); 7981 el.addEventListener('compositionend', onCompositionEnd); 7982 // Safari < 10.2 & UIWebView doesn't fire compositionend when 7983 // switching focus before confirming composition choice 7984 // this also fixes the issue where some browsers e.g. iOS Chrome 7985 // fires "change" instead of "input" on autocomplete. 7986 el.addEventListener('change', onCompositionEnd); 7987 /* istanbul ignore if */ 7988 if (isIE9) { 7989 el.vmodel = true; 7990 } 7991 } 7992 } 7993 }, 7994 7995 componentUpdated: function componentUpdated(el, binding, vnode) { 7996 if (vnode.tag === 'select') { 7997 setSelected(el, binding, vnode.context); 7998 // in case the options rendered by v-for have changed, 7999 // it's possible that the value is out-of-sync with the rendered options. 8000 // detect such cases and filter out values that no longer has a matching 8001 // option in the DOM. 8002 var prevOptions = el._vOptions; 8003 var curOptions = el._vOptions = [].map.call(el.options, getValue); 8004 if (curOptions.some(function(o, i) { return !looseEqual(o, prevOptions[i]); })) { 8005 // trigger change event if 8006 // no matching option found for at least one value 8007 var needReset = el.multiple ? 8008 binding.value.some(function(v) { return hasNoMatchingOption(v, curOptions); }) : 8009 binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions); 8010 if (needReset) { 8011 trigger(el, 'change'); 8012 } 8013 } 8014 } 8015 } 8016 }; 8017 8018 function setSelected(el, binding, vm) { 8019 actuallySetSelected(el, binding, vm); 8020 /* istanbul ignore if */ 8021 if (isIE || isEdge) { 8022 setTimeout(function() { 8023 actuallySetSelected(el, binding, vm); 8024 }, 0); 8025 } 8026 } 8027 8028 function actuallySetSelected(el, binding, vm) { 8029 var value = binding.value; 8030 var isMultiple = el.multiple; 8031 if (isMultiple && !Array.isArray(value)) { 8032 "development" !== 'production' && warn( 8033 "<select multiple v-model=\"" + (binding.expression) + "\"> " + 8034 "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)), 8035 vm 8036 ); 8037 return 8038 } 8039 var selected, option; 8040 for (var i = 0, l = el.options.length; i < l; i++) { 8041 option = el.options[i]; 8042 if (isMultiple) { 8043 selected = looseIndexOf(value, getValue(option)) > -1; 8044 if (option.selected !== selected) { 8045 option.selected = selected; 8046 } 8047 } else { 8048 if (looseEqual(getValue(option), value)) { 8049 if (el.selectedIndex !== i) { 8050 el.selectedIndex = i; 8051 } 8052 return 8053 } 8054 } 8055 } 8056 if (!isMultiple) { 8057 el.selectedIndex = -1; 8058 } 8059 } 8060 8061 function hasNoMatchingOption(value, options) { 8062 return options.every(function(o) { return !looseEqual(o, value); }) 8063 } 8064 8065 function getValue(option) { 8066 return '_value' in option ? 8067 option._value : 8068 option.value 8069 } 8070 8071 function onCompositionStart(e) { 8072 e.target.composing = true; 8073 } 8074 8075 function onCompositionEnd(e) { 8076 // prevent triggering an input event for no reason 8077 if (!e.target.composing) { return } 8078 e.target.composing = false; 8079 trigger(e.target, 'input'); 8080 } 8081 8082 function trigger(el, type) { 8083 var e = document.createEvent('HTMLEvents'); 8084 e.initEvent(type, true, true); 8085 el.dispatchEvent(e); 8086 } 8087 8088 /* */ 8089 8090 // recursively search for possible transition defined inside the component root 8091 function locateNode(vnode) { 8092 return vnode.componentInstance && (!vnode.data || !vnode.data.transition) ? 8093 locateNode(vnode.componentInstance._vnode) : 8094 vnode 8095 } 8096 8097 var show = { 8098 bind: function bind(el, ref, vnode) { 8099 var value = ref.value; 8100 8101 vnode = locateNode(vnode); 8102 var transition$$1 = vnode.data && vnode.data.transition; 8103 var originalDisplay = el.__vOriginalDisplay = 8104 el.style.display === 'none' ? '' : el.style.display; 8105 if (value && transition$$1) { 8106 vnode.data.show = true; 8107 enter(vnode, function() { 8108 el.style.display = originalDisplay; 8109 }); 8110 } else { 8111 el.style.display = value ? originalDisplay : 'none'; 8112 } 8113 }, 8114 8115 update: function update(el, ref, vnode) { 8116 var value = ref.value; 8117 var oldValue = ref.oldValue; 8118 8119 /* istanbul ignore if */ 8120 if (!value === !oldValue) { return } 8121 vnode = locateNode(vnode); 8122 var transition$$1 = vnode.data && vnode.data.transition; 8123 if (transition$$1) { 8124 vnode.data.show = true; 8125 if (value) { 8126 enter(vnode, function() { 8127 el.style.display = el.__vOriginalDisplay; 8128 }); 8129 } else { 8130 leave(vnode, function() { 8131 el.style.display = 'none'; 8132 }); 8133 } 8134 } else { 8135 el.style.display = value ? el.__vOriginalDisplay : 'none'; 8136 } 8137 }, 8138 8139 unbind: function unbind( 8140 el, 8141 binding, 8142 vnode, 8143 oldVnode,
vendor: 10,438 bytes, lines 8144-8431
8144 isDestroy 8145 ) { 8146 if (!isDestroy) { 8147 el.style.display = el.__vOriginalDisplay; 8148 } 8149 } 8150 } 8151 8152 var platformDirectives = { 8153 model: directive, 8154 show: show 8155 } 8156 8157 /* */ 8158 8159 // Provides transition support for a single element/component. 8160 // supports transition mode (out-in / in-out) 8161 8162 var transitionProps = { 8163 name: String, 8164 appear: Boolean, 8165 css: Boolean, 8166 mode: String, 8167 type: String, 8168 enterClass: String, 8169 leaveClass: String, 8170 enterToClass: String, 8171 leaveToClass: String, 8172 enterActiveClass: String, 8173 leaveActiveClass: String, 8174 appearClass: String, 8175 appearActiveClass: String, 8176 appearToClass: String, 8177 duration: [Number, String, Object] 8178 }; 8179 8180 // in case the child is also an abstract component, e.g. <keep-alive> 8181 // we want to recursively retrieve the real component to be rendered 8182 function getRealChild(vnode) { 8183 var compOptions = vnode && vnode.componentOptions; 8184 if (compOptions && compOptions.Ctor.options.abstract) { 8185 return getRealChild(getFirstComponentChild(compOptions.children)) 8186 } else { 8187 return vnode 8188 } 8189 } 8190 8191 function extractTransitionData(comp) { 8192 var data = {}; 8193 var options = comp.$options; 8194 // props 8195 for (var key in options.propsData) { 8196 data[key] = comp[key]; 8197 } 8198 // events. 8199 // extract listeners and pass them directly to the transition methods 8200 var listeners = options._parentListeners; 8201 for (var key$1 in listeners) { 8202 data[camelize(key$1)] = listeners[key$1]; 8203 } 8204 return data 8205 } 8206 8207 function placeholder(h, rawChild) { 8208 if (/\d-keep-alive$/.test(rawChild.tag)) { 8209 return h('keep-alive', { 8210 props: rawChild.componentOptions.propsData 8211 }) 8212 } 8213 } 8214 8215 function hasParentTransition(vnode) { 8216 while ((vnode = vnode.parent)) { 8217 if (vnode.data.transition) { 8218 return true 8219 } 8220 } 8221 } 8222 8223 function isSameChild(child, oldChild) { 8224 return oldChild.key === child.key && oldChild.tag === child.tag 8225 } 8226 8227 var Transition = { 8228 name: 'transition', 8229 props: transitionProps, 8230 abstract: true, 8231 8232 render: function render(h) { 8233 var this$1 = this; 8234 8235 var children = this.$slots.default; 8236 if (!children) { 8237 return 8238 } 8239 8240 // filter out text nodes (possible whitespaces) 8241 children = children.filter(function(c) { return c.tag || isAsyncPlaceholder(c); }); 8242 /* istanbul ignore if */ 8243 if (!children.length) { 8244 return 8245 } 8246 8247 // warn multiple elements 8248 if ("development" !== 'production' && children.length > 1) { 8249 warn( 8250 '<transition> can only be used on a single element. Use ' + 8251 '<transition-group> for lists.', 8252 this.$parent 8253 ); 8254 } 8255 8256 var mode = this.mode; 8257 8258 // warn invalid mode 8259 if ("development" !== 'production' && 8260 mode && mode !== 'in-out' && mode !== 'out-in' 8261 ) { 8262 warn( 8263 'invalid <transition> mode: ' + mode, 8264 this.$parent 8265 ); 8266 } 8267 8268 var rawChild = children[0]; 8269 8270 // if this is a component root node and the component's 8271 // parent container node also has transition, skip. 8272 if (hasParentTransition(this.$vnode)) { 8273 return rawChild 8274 } 8275 8276 // apply transition data to child 8277 // use getRealChild() to ignore abstract components e.g. keep-alive 8278 var child = getRealChild(rawChild); 8279 /* istanbul ignore if */ 8280 if (!child) { 8281 return rawChild 8282 } 8283 8284 if (this._leaving) { 8285 return placeholder(h, rawChild) 8286 } 8287 8288 // ensure a key that is unique to the vnode type and to this transition 8289 // component instance. This key will be used to remove pending leaving nodes 8290 // during entering. 8291 var id = "__transition-" + (this._uid) + "-"; 8292 child.key = child.key == null ? 8293 child.isComment ? 8294 id + 'comment' : 8295 id + child.tag : 8296 isPrimitive(child.key) ? 8297 (String(child.key).indexOf(id) === 0 ? child.key : id + child.key) : 8298 child.key; 8299 8300 var data = (child.data || (child.data = {})).transition = extractTransitionData(this); 8301 var oldRawChild = this._vnode; 8302 var oldChild = getRealChild(oldRawChild); 8303 8304 // mark v-show 8305 // so that the transition module can hand over the control to the directive 8306 if (child.data.directives && child.data.directives.some(function(d) { return d.name === 'show'; })) { 8307 child.data.show = true; 8308 } 8309 8310 if ( 8311 oldChild && 8312 oldChild.data && 8313 !isSameChild(child, oldChild) && 8314 !isAsyncPlaceholder(oldChild) && 8315 // #6687 component root is a comment node 8316 !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment) 8317 ) { 8318 // replace old child transition data with fresh one 8319 // important for dynamic transitions! 8320 var oldData = oldChild.data.transition = extend({}, data); 8321 // handle transition mode 8322 if (mode === 'out-in') { 8323 // return placeholder node and queue update when leave finishes 8324 this._leaving = true; 8325 mergeVNodeHook(oldData, 'afterLeave', function() { 8326 this$1._leaving = false; 8327 this$1.$forceUpdate(); 8328 }); 8329 return placeholder(h, rawChild) 8330 } else if (mode === 'in-out') { 8331 if (isAsyncPlaceholder(child)) { 8332 return oldRawChild 8333 } 8334 var delayedLeave; 8335 var performLeave = function() { delayedLeave(); }; 8336 mergeVNodeHook(data, 'afterEnter', performLeave); 8337 mergeVNodeHook(data, 'enterCancelled', performLeave); 8338 mergeVNodeHook(oldData, 'delayLeave', function(leave) { delayedLeave = leave; }); 8339 } 8340 } 8341 8342 return rawChild 8343 } 8344 } 8345 8346 /* */ 8347 8348 // Provides transition support for list items. 8349 // supports move transitions using the FLIP technique. 8350 8351 // Because the vdom's children update algorithm is "unstable" - i.e. 8352 // it doesn't guarantee the relative positioning of removed elements, 8353 // we force transition-group to update its children into two passes: 8354 // in the first pass, we remove all nodes that need to be removed, 8355 // triggering their leaving transition; in the second pass, we insert/move 8356 // into the final desired state. This way in the second pass removed 8357 // nodes will remain where they should be. 8358 8359 var props = extend({ 8360 tag: String, 8361 moveClass: String 8362 }, transitionProps); 8363 8364 delete props.mode; 8365 8366 var TransitionGroup = { 8367 props: props, 8368 8369 render: function render(h) { 8370 var tag = this.tag || this.$vnode.data.tag || 'span'; 8371 var map = Object.create(null); 8372 var prevChildren = this.prevChildren = this.children; 8373 var rawChildren = this.$slots.default || []; 8374 var children = this.children = []; 8375 var transitionData = extractTransitionData(this); 8376 8377 for (var i = 0; i < rawChildren.length; i++) { 8378 var c = rawChildren[i]; 8379 if (c.tag) { 8380 if (c.key != null && String(c.key).indexOf('__vlist') !== 0) { 8381 children.push(c); 8382 map[c.key] = c; 8383 (c.data || (c.data = {})).transition = transitionData; 8384 } else { 8385 var opts = c.componentOptions; 8386 var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag; 8387 warn(("<transition-group> children must be keyed: <" + name + ">")); 8388 } 8389 } 8390 } 8391 8392 if (prevChildren) { 8393 var kept = []; 8394 var removed = []; 8395 for (var i$1 = 0; i$1 < prevChildren.length; i$1++) { 8396 var c$1 = prevChildren[i$1]; 8397 c$1.data.transition = transitionData; 8398 c$1.data.pos = c$1.elm.getBoundingClientRect(); 8399 if (map[c$1.key]) { 8400 kept.push(c$1); 8401 } else { 8402 removed.push(c$1); 8403 } 8404 } 8405 this.kept = h(tag, null, kept); 8406 this.removed = removed; 8407 } 8408 8409 return h(tag, null, children) 8410 }, 8411 8412 beforeUpdate: function beforeUpdate() { 8413 // force removing pass 8414 this.__patch__( 8415 this._vnode, 8416 this.kept, 8417 false, // hydrating 8418 true // removeOnly (!important, avoids unnecessary moves) 8419 ); 8420 this._vnode = this.kept; 8421 }, 8422 8423 updated: function updated() { 8424 var children = this.prevChildren; 8425 var moveClass = this.moveClass || ((this.name || 'v') + '-move'); 8426 if (!children.length || !this.hasMove(children[0].elm, moveClass)) { 8427 return 8428 } 8429 8430 // we divide the work into three loops to avoid mixing DOM reads and writes 8431 // in each iteration - which helps prevent layout thrashing.
8432 children.forEach(callPendingCbs); 8433 children.forEach(recordPosition); 8434 children.forEach(applyTranslation); 8435 8436 // force reflow to put everything in position 8437 // assign to this to avoid being removed in tree-shaking 8438 // $flow-disable-line 8439 this._reflow = document.body.offsetHeight; 8440 8441 children.forEach(function(c) { 8442 if (c.data.moved) { 8443 var el = c.elm; 8444 var s = el.style; 8445 addTransitionClass(el, moveClass); 8446 s.transform = s.WebkitTransform = s.transitionDuration = ''; 8447 el.addEventListener(transitionEndEvent, el._moveCb = function cb(e) { 8448 if (!e || /transform$/.test(e.propertyName)) { 8449 el.removeEventListener(transitionEndEvent, cb); 8450 el._moveCb = null; 8451 removeTransitionClass(el, moveClass); 8452 } 8453 }); 8454 } 8455 }); 8456 }, 8457 8458 methods: { 8459 hasMove: function hasMove(el, moveClass) { 8460 /* istanbul ignore if */ 8461 if (!hasTransition) { 8462 return false 8463 } 8464 /* istanbul ignore if */ 8465 if (this._hasMove) { 8466 return this._hasMove 8467 } 8468 // Detect whether an element with the move class applied has 8469 // CSS transitions. Since the element may be inside an entering 8470 // transition at this very moment, we make a clone of it and remove 8471 // all other transition classes applied to ensure only the move class 8472 // is applied. 8473 var clone = el.cloneNode(); 8474 if (el._transitionClasses) { 8475 el._transitionClasses.forEach(function(cls) { removeClass(clone, cls); }); 8476 } 8477 addClass(clone, moveClass); 8478 clone.style.display = 'none'; 8479 this.$el.appendChild(clone); 8480 var info = getTransitionInfo(clone); 8481 this.$el.removeChild(clone); 8482 return (this._hasMove = info.hasTransform) 8483 } 8484 } 8485 } 8486 8487 function callPendingCbs(c) { 8488 /* istanbul ignore if */ 8489 if (c.elm._moveCb) { 8490 c.elm._moveCb(); 8491 } 8492 /* istanbul ignore if */ 8493 if (c.elm._enterCb) { 8494 c.elm._enterCb(); 8495 } 8496 } 8497 8498 function recordPosition(c) { 8499 c.data.newPos = c.elm.getBoundingClientRect(); 8500 } 8501 8502 function applyTranslation(c) { 8503 var oldPos = c.data.pos; 8504 var newPos = c.data.newPos; 8505 var dx = oldPos.left - newPos.left; 8506 var dy = oldPos.top - newPos.top; 8507 if (dx || dy) { 8508 c.data.moved = true; 8509 var s = c.elm.style; 8510 s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)"; 8511 s.transitionDuration = '0s'; 8512 } 8513 } 8514 8515 var platformComponents = { 8516 Transition: Transition, 8517 TransitionGroup: TransitionGroup 8518 } 8519 8520 /* */ 8521 8522 // install platform specific utils 8523 Vue.config.mustUseProp = mustUseProp; 8524 Vue.config.isReservedTag = isReservedTag; 8525 Vue.config.isReservedAttr = isReservedAttr; 8526 Vue.config.getTagNamespace = getTagNamespace; 8527 Vue.config.isUnknownElement = isUnknownElement; 8528 8529 // install platform runtime directives & components 8530 extend(Vue.options.directives, platformDirectives); 8531 extend(Vue.options.components, platformComponents); 8532 8533 // install platform patch function 8534 Vue.prototype.__patch__ = inBrowser ? patch : noop; 8535 8536 // public mount method 8537 Vue.prototype.$mount = function( 8538 el, 8539 hydrating 8540 ) { 8541 el = el && inBrowser ? query(el) : undefined; 8542 return mountComponent(this, el, hydrating) 8543 }; 8544 8545 // devtools global hook 8546 /* istanbul ignore next */ 8547 if (inBrowser) { 8548 setTimeout(function() { 8549 if (config.devtools) { 8550 if (devtools) { 8551 devtools.emit('init', Vue); 8552 } else if ( 8553 "development" !== 'production' && 8554 "development" !== 'test' && 8555 isChrome 8556 ) { 8557 console[console.info ? 'info' : 'log']( 8558 'Download the Vue Devtools extension for a better development experience:\n' + 8559 'https://github.com/vuejs/vue-devtools' 8560 ); 8561 } 8562 } 8563 if ("development" !== 'production' && 8564 "development" !== 'test' && 8565 config.productionTip !== false && 8566 typeof console !== 'undefined' 8567 ) { 8568 console[console.info ? 'info' : 'log']( 8569 "You are running Vue in development mode.\n" + 8570 "Make sure to turn on production mode when deploying for production.\n" + 8571 "See more tips at https://vuejs.org/guide/deployment.html" 8572 ); 8573 } 8574 }, 0); 8575 } 8576 8577 /* */ 8578 8579 var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g; 8580 var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g; 8581 8582 var buildRegex = cached(function(delimiters) { 8583 var open = delimiters[0].replace(regexEscapeRE, '\\$&'); 8584 var close = delimiters[1].replace(regexEscapeRE, '\\$&'); 8585 return new RegExp(open + '((?:.|\\n)+?)' + close, 'g') 8586 });
8587 8588 8589 8590 function parseText( 8591 text, 8592 delimiters 8593 ) { 8594 var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE; 8595 if (!tagRE.test(text)) { 8596 return 8597 } 8598 var tokens = []; 8599 var rawTokens = []; 8600 var lastIndex = tagRE.lastIndex = 0; 8601 var match, index, tokenValue; 8602 while ((match = tagRE.exec(text))) { 8603 index = match.index; 8604 // push text token 8605 if (index > lastIndex) { 8606 rawTokens.push(tokenValue = text.slice(lastIndex, index)); 8607 tokens.push(JSON.stringify(tokenValue)); 8608 } 8609 // tag token 8610 var exp = parseFilters(match[1].trim()); 8611 tokens.push(("_s(" + exp + ")")); 8612 rawTokens.push({ '@binding': exp }); 8613 lastIndex = index + match[0].length; 8614 } 8615 if (lastIndex < text.length) { 8616 rawTokens.push(tokenValue = text.slice(lastIndex)); 8617 tokens.push(JSON.stringify(tokenValue)); 8618 } 8619 return { 8620 expression: tokens.join('+'), 8621 tokens: rawTokens 8622 } 8623 } 8624 8625 /* */ 8626 8627 function transformNode(el, options) { 8628 var warn = options.warn || baseWarn; 8629 var staticClass = getAndRemoveAttr(el, 'class'); 8630 if ("development" !== 'production' && staticClass) { 8631 var res = parseText(staticClass, options.delimiters); 8632 if (res) { 8633 warn( 8634 "class=\"" + staticClass + "\": " + 8635 'Interpolation inside attributes has been removed. ' + 8636 'Use v-bind or the colon shorthand instead. For example, ' + 8637 'instead of <div class="{{ val }}">, use <div :class="val">.' 8638 ); 8639 } 8640 } 8641 if (staticClass) { 8642 el.staticClass = JSON.stringify(staticClass); 8643 } 8644 var classBinding = getBindingAttr(el, 'class', false /* getStatic */ ); 8645 if (classBinding) { 8646 el.classBinding = classBinding; 8647 } 8648 } 8649 8650 function genData(el) { 8651 var data = ''; 8652 if (el.staticClass) { 8653 data += "staticClass:" + (el.staticClass) + ","; 8654 } 8655 if (el.classBinding) { 8656 data += "class:" + (el.classBinding) + ","; 8657 } 8658 return data 8659 } 8660 8661 var klass$1 = { 8662 staticKeys: ['staticClass'], 8663 transformNode: transformNode, 8664 genData: genData 8665 } 8666 8667 /* */ 8668 8669 function transformNode$1(el, options) { 8670 var warn = options.warn || baseWarn; 8671 var staticStyle = getAndRemoveAttr(el, 'style'); 8672 if (staticStyle) { 8673 /* istanbul ignore if */ 8674 { 8675 var res = parseText(staticStyle, options.delimiters); 8676 if (res) { 8677 warn( 8678 "style=\"" + staticStyle + "\": " + 8679 'Interpolation inside attributes has been removed. ' + 8680 'Use v-bind or the colon shorthand instead. For example, ' + 8681 'instead of <div style="{{ val }}">, use <div :style="val">.' 8682 ); 8683 } 8684 } 8685 el.staticStyle = JSON.stringify(parseStyleText(staticStyle)); 8686 } 8687 8688 var styleBinding = getBindingAttr(el, 'style', false /* getStatic */ ); 8689 if (styleBinding) { 8690 el.styleBinding = styleBinding; 8691 } 8692 } 8693 8694 function genData$1(el) { 8695 var data = ''; 8696 if (el.staticStyle) { 8697 data += "staticStyle:" + (el.staticStyle) + ","; 8698 } 8699 if (el.styleBinding) { 8700 data += "style:(" + (el.styleBinding) + "),"; 8701 } 8702 return data 8703 } 8704 8705 var style$1 = { 8706 staticKeys: ['staticStyle'], 8707 transformNode: transformNode$1, 8708 genData: genData$1 8709 } 8710 8711 /* */ 8712 8713 var decoder; 8714 8715 var he = { 8716 decode: function decode(html) { 8717 decoder = decoder || document.createElement('div'); 8718 decoder.innerHTML = html; 8719 return decoder.textContent 8720 } 8721 } 8722 8723 /* */ 8724 8725 var isUnaryTag = makeMap( 8726 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + 8727 'link,meta,param,source,track,wbr' 8728 ); 8729 8730 // Elements that you can, intentionally, leave open 8731 // (and which close themselves) 8732 var canBeLeftOpenTag = makeMap( 8733 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source' 8734 ); 8735 8736 // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3 8737 // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content 8738 var isNonPhrasingTag = makeMap( 8739 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' + 8740 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' + 8741 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' + 8742 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' + 8743 'title,tr,track' 8744 ); 8745 8746 /** 8747 * Not type-checking this file because it's mostly vendor code. 8748 */ 8749 8750 /*! 8751 * HTML Parser By John Resig (ejohn.org) 8752 * Modified by Juriy "kangax" Zaytsev
8753 * Original code by Erik Arvidsson, Mozilla Public License 8754 * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js 8755 */ 8756 8757 // Regular Expressions for parsing tags and attributes 8758 var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/; 8759 // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName 8760 // but for Vue templates we can enforce a simple charset 8761 var ncname = '[a-zA-Z_][\\w\\-\\.]*'; 8762 var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")"; 8763 var startTagOpen = new RegExp(("^<" + qnameCapture)); 8764 var startTagClose = /^\s*(\/?)>/; 8765 var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>")); 8766 var doctype = /^<!DOCTYPE [^>]+>/i; 8767 // #7298: escape - to avoid being pased as HTML comment when inlined in page 8768 var comment = /^<!\--/; 8769 var conditionalComment = /^<!\[/; 8770 8771 var IS_REGEX_CAPTURING_BROKEN = false; 8772 'x'.replace(/x(.)?/g, function(m, g) { 8773 IS_REGEX_CAPTURING_BROKEN = g === ''; 8774 }); 8775 8776 // Special Elements (can contain anything) 8777 var isPlainTextElement = makeMap('script,style,textarea', true); 8778 var reCache = {}; 8779 8780 var decodingMap = { 8781 '<': '<', 8782 '>': '>', 8783 '"': '"', 8784 '&': '&', 8785 ' ': '\n', 8786 '	': '\t' 8787 }; 8788 var encodedAttr = /&(?:lt|gt|quot|amp);/g; 8789 var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10|#9);/g; 8790 8791 // #5992 8792 var isIgnoreNewlineTag = makeMap('pre,textarea', true); 8793 var shouldIgnoreFirstNewline = function(tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; }; 8794 8795 function decodeAttr(value, shouldDecodeNewlines) { 8796 var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr; 8797 return value.replace(re, function(match) { return decodingMap[match]; }) 8798 } 8799 8800 function parseHTML(html, options) { 8801 var stack = []; 8802 var expectHTML = options.expectHTML; 8803 var isUnaryTag$$1 = options.isUnaryTag || no; 8804 var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no; 8805 var index = 0; 8806 var last, lastTag; 8807 while (html) { 8808 last = html; 8809 // Make sure we're not in a plaintext content element like script/style 8810 if (!lastTag || !isPlainTextElement(lastTag)) { 8811 var textEnd = html.indexOf('<'); 8812 if (textEnd === 0) { 8813 // Comment: 8814 if (comment.test(html)) { 8815 var commentEnd = html.indexOf('-->'); 8816 8817 if (commentEnd >= 0) { 8818 if (options.shouldKeepComment) { 8819 options.comment(html.substring(4, commentEnd)); 8820 } 8821 advance(commentEnd + 3); 8822 continue 8823 } 8824 } 8825 8826 // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment 8827 if (conditionalComment.test(html)) { 8828 var conditionalEnd = html.indexOf(']>'); 8829 8830 if (conditionalEnd >= 0) { 8831 advance(conditionalEnd + 2); 8832 continue 8833 } 8834 } 8835 8836 // Doctype: 8837 var doctypeMatch = html.match(doctype); 8838 if (doctypeMatch) { 8839 advance(doctypeMatch[0].length); 8840 continue 8841 } 8842 8843 // End tag: 8844 var endTagMatch = html.match(endTag); 8845 if (endTagMatch) { 8846 var curIndex = index; 8847 advance(endTagMatch[0].length); 8848 parseEndTag(endTagMatch[1], curIndex, index); 8849 continue 8850 } 8851 8852 // Start tag: 8853 var startTagMatch = parseStartTag(); 8854 if (startTagMatch) { 8855 handleStartTag(startTagMatch); 8856 if (shouldIgnoreFirstNewline(lastTag, html)) { 8857 advance(1); 8858 } 8859 continue 8860 } 8861 } 8862 8863 var text = (void 0), 8864 rest = (void 0), 8865 next = (void 0); 8866 if (textEnd >= 0) { 8867 rest = html.slice(textEnd);
8868 while (!endTag.test(rest) && 8869 !startTagOpen.test(rest) && 8870 !comment.test(rest) && 8871 !conditionalComment.test(rest) 8872 ) { 8873 // < in plain text, be forgiving and treat it as text 8874 next = rest.indexOf('<', 1); 8875 if (next < 0) { break } 8876 textEnd += next; 8877 rest = html.slice(textEnd); 8878 } 8879 text = html.substring(0, textEnd); 8880 advance(textEnd); 8881 } 8882 8883 if (textEnd < 0) { 8884 text = html; 8885 html = ''; 8886 } 8887 8888 if (options.chars && text) { 8889 options.chars(text); 8890 } 8891 } else { 8892 var endTagLength = 0; 8893 var stackedTag = lastTag.toLowerCase(); 8894 var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i')); 8895 var rest$1 = html.replace(reStackedTag, function(all, text, endTag) { 8896 endTagLength = endTag.length; 8897 if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') { 8898 text = text 8899 .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298 8900 .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1'); 8901 } 8902 if (shouldIgnoreFirstNewline(stackedTag, text)) { 8903 text = text.slice(1); 8904 } 8905 if (options.chars) { 8906 options.chars(text); 8907 } 8908 return '' 8909 }); 8910 index += html.length - rest$1.length; 8911 html = rest$1; 8912 parseEndTag(stackedTag, index - endTagLength, index); 8913 } 8914 8915 if (html === last) { 8916 options.chars && options.chars(html); 8917 if ("development" !== 'production' && !stack.length && options.warn) { 8918 options.warn(("Mal-formatted tag at end of template: \"" + html + "\"")); 8919 } 8920 break 8921 } 8922 } 8923 8924 // Clean up any remaining tags 8925 parseEndTag(); 8926 8927 function advance(n) { 8928 index += n; 8929 html = html.substring(n); 8930 } 8931 8932 function parseStartTag() { 8933 var start = html.match(startTagOpen); 8934 if (start) { 8935 var match = { 8936 tagName: start[1], 8937 attrs: [], 8938 start: index 8939 }; 8940 advance(start[0].length); 8941 var end, attr; 8942 while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) { 8943 advance(attr[0].length); 8944 match.attrs.push(attr); 8945 } 8946 if (end) { 8947 match.unarySlash = end[1]; 8948 advance(end[0].length); 8949 match.end = index; 8950 return match 8951 } 8952 } 8953 } 8954 8955 function handleStartTag(match) { 8956 var tagName = match.tagName; 8957 var unarySlash = match.unarySlash; 8958 8959 if (expectHTML) { 8960 if (lastTag === 'p' && isNonPhrasingTag(tagName)) { 8961 parseEndTag(lastTag); 8962 } 8963 if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) { 8964 parseEndTag(tagName); 8965 } 8966 } 8967 8968 var unary = isUnaryTag$$1(tagName) || !!unarySlash; 8969 8970 var l = match.attrs.length; 8971 var attrs = new Array(l); 8972 for (var i = 0; i < l; i++) { 8973 var args = match.attrs[i]; 8974 // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778 8975 if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) { 8976 if (args[3] === '') { delete args[3]; } 8977 if (args[4] === '') { delete args[4]; } 8978 if (args[5] === '') { delete args[5]; } 8979 } 8980 var value = args[3] || args[4] || args[5] || ''; 8981 var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href' ? 8982 options.shouldDecodeNewlinesForHref : 8983 options.shouldDecodeNewlines; 8984 attrs[i] = { 8985 name: args[1], 8986 value: decodeAttr(value, shouldDecodeNewlines) 8987 }; 8988 } 8989 8990 if (!unary) { 8991 stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs }); 8992 lastTag = tagName; 8993 } 8994 8995 if (options.start) { 8996 options.start(tagName, attrs, unary, match.start, match.end); 8997 } 8998 } 8999 9000 function parseEndTag(tagName, start, end) { 9001 var pos, lowerCasedTagName; 9002 if (start == null) { start = index; } 9003 if (end == null) { end = index; } 9004 9005 if (tagName) { 9006 lowerCasedTagName = tagName.toLowerCase(); 9007 } 9008 9009 // Find the closest opened tag of the same type 9010 if (tagName) { 9011 for (pos = stack.length - 1; pos >= 0; pos--) { 9012 if (stack[pos].lowerCasedTag === lowerCasedTagName) { 9013 break 9014 } 9015 } 9016 } else { 9017 // If no tag name is provided, clean shop 9018 pos = 0; 9019 } 9020 9021 if (pos >= 0) { 9022 // Close all the open elements, up the stack 9023 for (var i = stack.length - 1; i >= pos; i--) { 9024 if ("development" !== 'production' && 9025 (i > pos || !tagName) && 9026 options.warn 9027 ) { 9028 options.warn( 9029 ("tag <" + (stack[i].tag) + "> has no matching end tag.") 9030 ); 9031 } 9032 if (options.end) { 9033 options.end(stack[i].tag, start, end); 9034 } 9035 } 9036 9037 // Remove the open elements from the stack 9038 stack.length = pos; 9039 lastTag = pos && stack[pos - 1].tag; 9040 } else if (lowerCasedTagName === 'br') { 9041 if (options.start) { 9042 options.start(tagName, [], true, start, end); 9043 } 9044 } else if (lowerCasedTagName === 'p') { 9045 if (options.start) { 9046 options.start(tagName, [], false, start, end); 9047 } 9048 if (options.end) { 9049 options.end(tagName, start, end); 9050 } 9051 } 9052 } 9053 } 9054 9055 /* */ 9056 9057 var onRE = /^@|^v-on:/; 9058 var dirRE = /^v-|^@|^:/; 9059 var forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/; 9060 var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/; 9061 var stripParensRE = /^\(|\)$/g; 9062 9063 var argRE = /:(.*)$/; 9064 var bindRE = /^:|^v-bind:/; 9065 var modifierRE = /\.[^.]+/g; 9066
9067 var decodeHTMLCached = cached(he.decode); 9068 9069 // configurable state 9070 var warn$2; 9071 var delimiters; 9072 var transforms; 9073 var preTransforms; 9074 var postTransforms; 9075 var platformIsPreTag; 9076 var platformMustUseProp; 9077 var platformGetTagNamespace; 9078 9079 9080 9081 function createASTElement( 9082 tag, 9083 attrs, 9084 parent 9085 ) { 9086 return { 9087 type: 1, 9088 tag: tag, 9089 attrsList: attrs, 9090 attrsMap: makeAttrsMap(attrs), 9091 parent: parent, 9092 children: [] 9093 } 9094 } 9095 9096 /** 9097 * Convert HTML string to AST. 9098 */ 9099 function parse( 9100 template, 9101 options 9102 ) { 9103 warn$2 = options.warn || baseWarn; 9104 9105 platformIsPreTag = options.isPreTag || no; 9106 platformMustUseProp = options.mustUseProp || no; 9107 platformGetTagNamespace = options.getTagNamespace || no; 9108 9109 transforms = pluckModuleFunction(options.modules, 'transformNode'); 9110 preTransforms = pluckModuleFunction(options.modules, 'preTransformNode'); 9111 postTransforms = pluckModuleFunction(options.modules, 'postTransformNode'); 9112 9113 delimiters = options.delimiters; 9114 9115 var stack = []; 9116 var preserveWhitespace = options.preserveWhitespace !== false; 9117 var root; 9118 var currentParent; 9119 var inVPre = false; 9120 var inPre = false; 9121 var warned = false; 9122 9123 function warnOnce(msg) { 9124 if (!warned) { 9125 warned = true; 9126 warn$2(msg); 9127 } 9128 } 9129 9130 function closeElement(element) { 9131 // check pre state 9132 if (element.pre) { 9133 inVPre = false; 9134 } 9135 if (platformIsPreTag(element.tag)) { 9136 inPre = false; 9137 } 9138 // apply post-transforms 9139 for (var i = 0; i < postTransforms.length; i++) { 9140 postTransforms[i](element, options); 9141 } 9142 } 9143 9144 parseHTML(template, { 9145 warn: warn$2, 9146 expectHTML: options.expectHTML, 9147 isUnaryTag: options.isUnaryTag, 9148 canBeLeftOpenTag: options.canBeLeftOpenTag, 9149 shouldDecodeNewlines: options.shouldDecodeNewlines, 9150 shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref, 9151 shouldKeepComment: options.comments, 9152 start: function start(tag, attrs, unary) { 9153 // check namespace. 9154 // inherit parent ns if there is one 9155 var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag); 9156 9157 // handle IE svg bug 9158 /* istanbul ignore if */ 9159 if (isIE && ns === 'svg') { 9160 attrs = guardIESVGBug(attrs); 9161 } 9162 9163 var element = createASTElement(tag, attrs, currentParent); 9164 if (ns) { 9165 element.ns = ns; 9166 } 9167 9168 if (isForbiddenTag(element) && !isServerRendering()) { 9169 element.forbidden = true; 9170 "development" !== 'production' && warn$2( 9171 'Templates should only be responsible for mapping the state to the ' + 9172 'UI. Avoid placing tags with side-effects in your templates, such as ' + 9173 "<" + tag + ">" + ', as they will not be parsed.' 9174 ); 9175 } 9176 9177 // apply pre-transforms 9178 for (var i = 0; i < preTransforms.length; i++) { 9179 element = preTransforms[i](element, options) || element; 9180 } 9181 9182 if (!inVPre) { 9183 processPre(element); 9184 if (element.pre) { 9185 inVPre = true; 9186 } 9187 } 9188 if (platformIsPreTag(element.tag)) { 9189 inPre = true; 9190 } 9191 if (inVPre) { 9192 processRawAttrs(element); 9193 } else if (!element.processed) { 9194 // structural directives 9195 processFor(element); 9196 processIf(element); 9197 processOnce(element); 9198 // element-scope stuff 9199 processElement(element, options); 9200 } 9201 9202 function checkRootConstraints(el) { 9203 { 9204 if (el.tag === 'slot' || el.tag === 'template') { 9205 warnOnce( 9206 "Cannot use <" + (el.tag) + "> as component root element because it may " + 9207 'contain multiple nodes.' 9208 ); 9209 } 9210 if (el.attrsMap.hasOwnProperty('v-for')) { 9211 warnOnce( 9212 'Cannot use v-for on stateful component root element because ' + 9213 'it renders multiple elements.' 9214 ); 9215 } 9216 } 9217 } 9218 9219 // tree management 9220 if (!root) { 9221 root = element; 9222 checkRootConstraints(root); 9223 } else if (!stack.length) { 9224 // allow root elements with v-if, v-else-if and v-else 9225 if (root.if && (element.elseif || element.else)) { 9226 checkRootConstraints(element); 9227 addIfCondition(root, { 9228 exp: element.elseif, 9229 block: element 9230 }); 9231 } else { 9232 warnOnce( 9233 "Component template should contain exactly one root element. " + 9234 "If you are using v-if on multiple elements, " + 9235 "use v-else-if to chain them instead." 9236 ); 9237 } 9238 } 9239 if (currentParent && !element.forbidden) { 9240 if (element.elseif || element.else) { 9241 processIfConditions(element, currentParent); 9242 } else if (element.slotScope) { // scoped slot 9243 currentParent.plain = false; 9244 var name = element.slotTarget || '"default"'; 9245 (currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element; 9246 } else { 9247 currentParent.children.push(element); 9248 element.parent = currentParent; 9249 } 9250 } 9251 if (!unary) { 9252 currentParent = element; 9253 stack.push(element); 9254 } else { 9255 closeElement(element); 9256 } 9257 }, 9258 9259 end: function end() { 9260 // remove trailing whitespace 9261 var element = stack[stack.length - 1]; 9262 var lastNode = element.children[element.children.length - 1]; 9263 if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) { 9264 element.children.pop(); 9265 } 9266 // pop stack 9267 stack.length -= 1; 9268 currentParent = stack[stack.length - 1]; 9269 closeElement(element); 9270 }, 9271 9272 chars: function chars(text) { 9273 if (!currentParent) { 9274 { 9275 if (text === template) { 9276 warnOnce( 9277 'Component template requires a root element, rather than just text.' 9278 ); 9279 } else if ((text = text.trim())) { 9280 warnOnce(
9281 ("text \"" + text + "\" outside root element will be ignored.") 9282 ); 9283 } 9284 } 9285 return 9286 } 9287 // IE textarea placeholder bug 9288 /* istanbul ignore if */ 9289 if (isIE && 9290 currentParent.tag === 'textarea' && 9291 currentParent.attrsMap.placeholder === text 9292 ) { 9293 return 9294 } 9295 var children = currentParent.children; 9296 text = inPre || text.trim() ? 9297 isTextTag(currentParent) ? text : decodeHTMLCached(text) 9298 // only preserve whitespace if its not right after a starting tag 9299 : 9300 preserveWhitespace && children.length ? ' ' : ''; 9301 if (text) { 9302 var res; 9303 if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) { 9304 children.push({ 9305 type: 2, 9306 expression: res.expression, 9307 tokens: res.tokens, 9308 text: text 9309 }); 9310 } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') { 9311 children.push({ 9312 type: 3, 9313 text: text 9314 }); 9315 } 9316 } 9317 }, 9318 comment: function comment(text) { 9319 currentParent.children.push({ 9320 type: 3, 9321 text: text, 9322 isComment: true 9323 }); 9324 } 9325 }); 9326 return root 9327 } 9328 9329 function processPre(el) { 9330 if (getAndRemoveAttr(el, 'v-pre') != null) { 9331 el.pre = true; 9332 } 9333 } 9334 9335 function processRawAttrs(el) { 9336 var l = el.attrsList.length; 9337 if (l) { 9338 var attrs = el.attrs = new Array(l); 9339 for (var i = 0; i < l; i++) { 9340 attrs[i] = { 9341 name: el.attrsList[i].name, 9342 value: JSON.stringify(el.attrsList[i].value) 9343 }; 9344 } 9345 } else if (!el.pre) { 9346 // non root node in pre blocks with no attributes 9347 el.plain = true; 9348 } 9349 } 9350 9351 function processElement(element, options) { 9352 processKey(element); 9353 9354 // determine whether this is a plain element after 9355 // removing structural attributes 9356 element.plain = !element.key && !element.attrsList.length; 9357 9358 processRef(element); 9359 processSlot(element); 9360 processComponent(element); 9361 for (var i = 0; i < transforms.length; i++) { 9362 element = transforms[i](element, options) || element; 9363 } 9364 processAttrs(element); 9365 } 9366 9367 function processKey(el) { 9368 var exp = getBindingAttr(el, 'key'); 9369 if (exp) { 9370 if ("development" !== 'production' && el.tag === 'template') { 9371 warn$2("<template> cannot be keyed. Place the key on real elements instead."); 9372 } 9373 el.key = exp; 9374 } 9375 } 9376 9377 function processRef(el) { 9378 var ref = getBindingAttr(el, 'ref'); 9379 if (ref) { 9380 el.ref = ref; 9381 el.refInFor = checkInFor(el); 9382 } 9383 } 9384 9385 function processFor(el) { 9386 var exp; 9387 if ((exp = getAndRemoveAttr(el, 'v-for'))) { 9388 var res = parseFor(exp); 9389 if (res) { 9390 extend(el, res); 9391 } else { 9392 warn$2( 9393 ("Invalid v-for expression: " + exp) 9394 ); 9395 } 9396 } 9397 } 9398 9399 9400 9401 function parseFor(exp) { 9402 var inMatch = exp.match(forAliasRE); 9403 if (!inMatch) { return } 9404 var res = {}; 9405 res.for = inMatch[2].trim(); 9406 var alias = inMatch[1].trim().replace(stripParensRE, ''); 9407 var iteratorMatch = alias.match(forIteratorRE);
9408 if (iteratorMatch) { 9409 res.alias = alias.replace(forIteratorRE, ''); 9410 res.iterator1 = iteratorMatch[1].trim(); 9411 if (iteratorMatch[2]) { 9412 res.iterator2 = iteratorMatch[2].trim(); 9413 } 9414 } else { 9415 res.alias = alias; 9416 } 9417 return res 9418 } 9419 9420 function processIf(el) { 9421 var exp = getAndRemoveAttr(el, 'v-if'); 9422 if (exp) { 9423 el.if = exp; 9424 addIfCondition(el, { 9425 exp: exp, 9426 block: el 9427 }); 9428 } else { 9429 if (getAndRemoveAttr(el, 'v-else') != null) { 9430 el.else = true; 9431 } 9432 var elseif = getAndRemoveAttr(el, 'v-else-if'); 9433 if (elseif) { 9434 el.elseif = elseif; 9435 } 9436 } 9437 } 9438 9439 function processIfConditions(el, parent) { 9440 var prev = findPrevElement(parent.children); 9441 if (prev && prev.if) { 9442 addIfCondition(prev, { 9443 exp: el.elseif, 9444 block: el 9445 }); 9446 } else { 9447 warn$2( 9448 "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " + 9449 "used on element <" + (el.tag) + "> without corresponding v-if." 9450 ); 9451 } 9452 } 9453 9454 function findPrevElement(children) { 9455 var i = children.length; 9456 while (i--) { 9457 if (children[i].type === 1) { 9458 return children[i] 9459 } else { 9460 if ("development" !== 'production' && children[i].text !== ' ') { 9461 warn$2( 9462 "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " + 9463 "will be ignored." 9464 ); 9465 } 9466 children.pop(); 9467 } 9468 } 9469 } 9470 9471 function addIfCondition(el, condition) { 9472 if (!el.ifConditions) { 9473 el.ifConditions = []; 9474 } 9475 el.ifConditions.push(condition); 9476 } 9477 9478 function processOnce(el) { 9479 var once$$1 = getAndRemoveAttr(el, 'v-once'); 9480 if (once$$1 != null) { 9481 el.once = true; 9482 } 9483 } 9484 9485 function processSlot(el) { 9486 if (el.tag === 'slot') { 9487 el.slotName = getBindingAttr(el, 'name'); 9488 if ("development" !== 'production' && el.key) { 9489 warn$2( 9490 "`key` does not work on <slot> because slots are abstract outlets " + 9491 "and can possibly expand into multiple elements. " + 9492 "Use the key on a wrapping element instead." 9493 ); 9494 } 9495 } else { 9496 var slotScope; 9497 if (el.tag === 'template') { 9498 slotScope = getAndRemoveAttr(el, 'scope'); 9499 /* istanbul ignore if */ 9500 if ("development" !== 'production' && slotScope) { 9501 warn$2( 9502 "the \"scope\" attribute for scoped slots have been deprecated and " + 9503 "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " + 9504 "can also be used on plain elements in addition to <template> to " + 9505 "denote scoped slots.", 9506 true 9507 ); 9508 } 9509 el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope'); 9510 } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) { 9511 /* istanbul ignore if */ 9512 if ("development" !== 'production' && el.attrsMap['v-for']) { 9513 warn$2( 9514 "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " + 9515 "(v-for takes higher priority). Use a wrapper <template> for the " + 9516 "scoped slot to make it clearer.", 9517 true 9518 ); 9519 } 9520 el.slotScope = slotScope; 9521 } 9522 var slotTarget = getBindingAttr(el, 'slot'); 9523 if (slotTarget) { 9524 el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget; 9525 // preserve slot as an attribute for native shadow DOM compat 9526 // only for non-scoped slots. 9527 if (el.tag !== 'template' && !el.slotScope) { 9528 addAttr(el, 'slot', slotTarget); 9529 } 9530 } 9531 } 9532 } 9533 9534 function processComponent(el) { 9535 var binding; 9536 if ((binding = getBindingAttr(el, 'is'))) { 9537 el.component = binding; 9538 } 9539 if (getAndRemoveAttr(el, 'inline-template') != null) { 9540 el.inlineTemplate = true; 9541 } 9542 } 9543 9544 function processAttrs(el) { 9545 var list = el.attrsList; 9546 var i, l, name, rawName, value, modifiers, isProp; 9547 for (i = 0, l = list.length; i < l; i++) { 9548 name = rawName = list[i].name; 9549 value = list[i].value; 9550 if (dirRE.test(name)) { 9551 // mark element as dynamic 9552 el.hasBindings = true; 9553 // modifiers 9554 modifiers = parseModifiers(name); 9555 if (modifiers) { 9556 name = name.replace(modifierRE, ''); 9557 } 9558 if (bindRE.test(name)) { // v-bind 9559 name = name.replace(bindRE, ''); 9560 value = parseFilters(value); 9561 isProp = false; 9562 if (modifiers) { 9563 if (modifiers.prop) { 9564 isProp = true; 9565 name = camelize(name); 9566 if (name === 'innerHtml') { name = 'innerHTML'; } 9567 } 9568 if (modifiers.camel) { 9569 name = camelize(name); 9570 } 9571 if (modifiers.sync) { 9572 addHandler( 9573 el, 9574 ("update:" + (camelize(name))),
9575 genAssignmentCode(value, "$event") 9576 ); 9577 } 9578 } 9579 if (isProp || (!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name))) { 9580 addProp(el, name, value); 9581 } else { 9582 addAttr(el, name, value); 9583 } 9584 } else if (onRE.test(name)) { // v-on 9585 name = name.replace(onRE, ''); 9586 addHandler(el, name, value, modifiers, false, warn$2); 9587 } else { // normal directives 9588 name = name.replace(dirRE, ''); 9589 // parse arg 9590 var argMatch = name.match(argRE); 9591 var arg = argMatch && argMatch[1]; 9592 if (arg) { 9593 name = name.slice(0, -(arg.length + 1)); 9594 } 9595 addDirective(el, name, rawName, value, arg, modifiers); 9596 if ("development" !== 'production' && name === 'model') { 9597 checkForAliasModel(el, value); 9598 } 9599 } 9600 } else { 9601 // literal attribute 9602 { 9603 var res = parseText(value, delimiters); 9604 if (res) { 9605 warn$2( 9606 name + "=\"" + value + "\": " + 9607 'Interpolation inside attributes has been removed. ' + 9608 'Use v-bind or the colon shorthand instead. For example, ' + 9609 'instead of <div id="{{ val }}">, use <div :id="val">.' 9610 ); 9611 } 9612 } 9613 addAttr(el, name, JSON.stringify(value)); 9614 // #6887 firefox doesn't update muted state if set via attribute 9615 // even immediately after element creation 9616 if (!el.component && 9617 name === 'muted' && 9618 platformMustUseProp(el.tag, el.attrsMap.type, name)) { 9619 addProp(el, name, 'true'); 9620 } 9621 } 9622 } 9623 } 9624 9625 function checkInFor(el) { 9626 var parent = el; 9627 while (parent) { 9628 if (parent.for !== undefined) { 9629 return true 9630 } 9631 parent = parent.parent; 9632 } 9633 return false 9634 } 9635 9636 function parseModifiers(name) { 9637 var match = name.match(modifierRE); 9638 if (match) { 9639 var ret = {}; 9640 match.forEach(function(m) { ret[m.slice(1)] = true; }); 9641 return ret 9642 } 9643 } 9644 9645 function makeAttrsMap(attrs) { 9646 var map = {}; 9647 for (var i = 0, l = attrs.length; i < l; i++) { 9648 if ( 9649 "development" !== 'production' && 9650 map[attrs[i].name] && !isIE && !isEdge 9651 ) { 9652 warn$2('duplicate attribute: ' + attrs[i].name); 9653 } 9654 map[attrs[i].name] = attrs[i].value; 9655 } 9656 return map 9657 } 9658 9659 // for script (e.g. type="x/template") or style, do not decode content 9660 function isTextTag(el) { 9661 return el.tag === 'script' || el.tag === 'style' 9662 } 9663 9664 function isForbiddenTag(el) { 9665 return ( 9666 el.tag === 'style' || 9667 (el.tag === 'script' && (!el.attrsMap.type || 9668 el.attrsMap.type === 'text/javascript' 9669 )) 9670 ) 9671 } 9672 9673 var ieNSBug = /^xmlns:NS\d+/; 9674 var ieNSPrefix = /^NS\d+:/; 9675 9676 /* istanbul ignore next */ 9677 function guardIESVGBug(attrs) { 9678 var res = []; 9679 for (var i = 0; i < attrs.length; i++) { 9680 var attr = attrs[i]; 9681 if (!ieNSBug.test(attr.name)) { 9682 attr.name = attr.name.replace(ieNSPrefix, ''); 9683 res.push(attr); 9684 } 9685 } 9686 return res 9687 } 9688 9689 function checkForAliasModel(el, value) { 9690 var _el = el; 9691 while (_el) { 9692 if (_el.for && _el.alias === value) { 9693 warn$2( 9694 "<" + (el.tag) + " v-model=\"" + value + "\">: " + 9695 "You are binding v-model directly to a v-for iteration alias. " + 9696 "This will not be able to modify the v-for source array because " + 9697 "writing to the alias is like modifying a function local variable. " + 9698 "Consider using an array of objects and use v-model on an object property instead." 9699 ); 9700 } 9701 _el = _el.parent; 9702 } 9703 } 9704 9705 /* */ 9706 9707 /** 9708 * Expand input[v-model] with dyanmic type bindings into v-if-else chains 9709 * Turn this: 9710 * <input v-model="data[type]" :type="type"> 9711 * into this: 9712 * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]"> 9713 * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]"> 9714 * <input v-else :type="type" v-model="data[type]"> 9715 */ 9716 9717 function preTransformNode(el, options) { 9718 if (el.tag === 'input') { 9719 var map = el.attrsMap; 9720 if (!map['v-model']) { 9721 return 9722 } 9723 9724 var typeBinding; 9725 if (map[':type'] || map['v-bind:type']) { 9726 typeBinding = getBindingAttr(el, 'type'); 9727 } 9728 if (!map.type && !typeBinding && map['v-bind']) { 9729 typeBinding = "(" + (map['v-bind']) + ").type"; 9730 } 9731 9732 if (typeBinding) { 9733 var ifCondition = getAndRemoveAttr(el, 'v-if', true); 9734 var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : ""; 9735 var hasElse = getAndRemoveAttr(el, 'v-else', true) != null; 9736 var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true); 9737 // 1. checkbox 9738 var branch0 = cloneASTElement(el); 9739 // process for on the main node 9740 processFor(branch0); 9741 addRawAttr(branch0, 'type', 'checkbox'); 9742 processElement(branch0, options); 9743 branch0.processed = true; // prevent it from double-processed 9744 branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra; 9745 addIfCondition(branch0, { 9746 exp: branch0.if, 9747 block: branch0 9748 }); 9749 // 2. add radio else-if condition 9750 var branch1 = cloneASTElement(el); 9751 getAndRemoveAttr(branch1, 'v-for', true); 9752 addRawAttr(branch1, 'type', 'radio'); 9753 processElement(branch1, options); 9754 addIfCondition(branch0, { 9755 exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra, 9756 block: branch1 9757 }); 9758 // 3. other 9759 var branch2 = cloneASTElement(el); 9760 getAndRemoveAttr(branch2, 'v-for', true); 9761 addRawAttr(branch2, ':type', typeBinding); 9762 processElement(branch2, options); 9763 addIfCondition(branch0, { 9764 exp: ifCondition, 9765 block: branch2 9766 }); 9767 9768 if (hasElse) { 9769 branch0.else = true; 9770 } else if (elseIfCondition) { 9771 branch0.elseif = elseIfCondition; 9772 } 9773 9774 return branch0 9775 } 9776 } 9777 } 9778 9779 function cloneASTElement(el) { 9780 return createASTElement(el.tag, el.attrsList.slice(), el.parent) 9781 } 9782 9783 var model$2 = { 9784 preTransformNode: preTransformNode 9785 } 9786 9787 var modules$1 = [ 9788 klass$1, 9789 style$1, 9790 model$2 9791 ] 9792 9793 /* */ 9794 9795 function text(el, dir) { 9796 if (dir.value) { 9797 addProp(el, 'textContent', ("_s(" + (dir.value) + ")")); 9798 } 9799 } 9800 9801 /* */ 9802 9803 function html(el, dir) { 9804 if (dir.value) { 9805 addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")")); 9806 } 9807 } 9808 9809 var directives$1 = { 9810 model: model, 9811 text: text, 9812 html: html 9813 } 9814 9815 /* */ 9816 9817 var baseOptions = { 9818 expectHTML: true, 9819 modules: modules$1, 9820 directives: directives$1, 9821 isPreTag: isPreTag, 9822 isUnaryTag: isUnaryTag, 9823 mustUseProp: mustUseProp, 9824 canBeLeftOpenTag: canBeLeftOpenTag, 9825 isReservedTag: isReservedTag, 9826 getTagNamespace: getTagNamespace, 9827 staticKeys: genStaticKeys(modules$1) 9828 }; 9829 9830 /* */ 9831 9832 var isStaticKey; 9833 var isPlatformReservedTag; 9834
9835 var genStaticKeysCached = cached(genStaticKeys$1); 9836 9837 /** 9838 * Goal of the optimizer: walk the generated template AST tree 9839 * and detect sub-trees that are purely static, i.e. parts of 9840 * the DOM that never needs to change. 9841 * 9842 * Once we detect these sub-trees, we can: 9843 * 9844 * 1. Hoist them into constants, so that we no longer need to 9845 * create fresh nodes for them on each re-render; 9846 * 2. Completely skip them in the patching process. 9847 */ 9848 function optimize(root, options) { 9849 if (!root) { return } 9850 isStaticKey = genStaticKeysCached(options.staticKeys || ''); 9851 isPlatformReservedTag = options.isReservedTag || no; 9852 // first pass: mark all non-static nodes. 9853 markStatic$1(root); 9854 // second pass: mark static roots. 9855 markStaticRoots(root, false); 9856 } 9857 9858 function genStaticKeys$1(keys) { 9859 return makeMap( 9860 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' + 9861 (keys ? ',' + keys : '') 9862 ) 9863 } 9864 9865 function markStatic$1(node) { 9866 node.static = isStatic(node); 9867 if (node.type === 1) { 9868 // do not make component slot content static. this avoids 9869 // 1. components not able to mutate slot nodes 9870 // 2. static slot content fails for hot-reloading 9871 if (!isPlatformReservedTag(node.tag) && 9872 node.tag !== 'slot' && 9873 node.attrsMap['inline-template'] == null 9874 ) { 9875 return 9876 } 9877 for (var i = 0, l = node.children.length; i < l; i++) { 9878 var child = node.children[i]; 9879 markStatic$1(child); 9880 if (!child.static) { 9881 node.static = false; 9882 } 9883 } 9884 if (node.ifConditions) { 9885 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) { 9886 var block = node.ifConditions[i$1].block; 9887 markStatic$1(block); 9888 if (!block.static) { 9889 node.static = false; 9890 } 9891 } 9892 } 9893 } 9894 } 9895 9896 function markStaticRoots(node, isInFor) { 9897 if (node.type === 1) { 9898 if (node.static || node.once) { 9899 node.staticInFor = isInFor; 9900 } 9901 // For a node to qualify as a static root, it should have children that 9902 // are not just static text. Otherwise the cost of hoisting out will 9903 // outweigh the benefits and it's better off to just always render it fresh. 9904 if (node.static && node.children.length && !( 9905 node.children.length === 1 && 9906 node.children[0].type === 3 9907 )) { 9908 node.staticRoot = true; 9909 return 9910 } else { 9911 node.staticRoot = false; 9912 } 9913 if (node.children) { 9914 for (var i = 0, l = node.children.length; i < l; i++) { 9915 markStaticRoots(node.children[i], isInFor || !!node.for); 9916 } 9917 } 9918 if (node.ifConditions) { 9919 for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) { 9920 markStaticRoots(node.ifConditions[i$1].block, isInFor); 9921 } 9922 } 9923 } 9924 } 9925 9926 function isStatic(node) { 9927 if (node.type === 2) { // expression 9928 return false 9929 } 9930 if (node.type === 3) { // text 9931 return true 9932 } 9933 return !!(node.pre || (!node.hasBindings && // no dynamic bindings 9934 !node.if && !node.for && // not v-if or v-for or v-else 9935 !isBuiltInTag(node.tag) && // not a built-in 9936 isPlatformReservedTag(node.tag) && // not a component 9937 !isDirectChildOfTemplateFor(node) && 9938 Object.keys(node).every(isStaticKey) 9939 )) 9940 } 9941 9942 function isDirectChildOfTemplateFor(node) { 9943 while (node.parent) { 9944 node = node.parent; 9945 if (node.tag !== 'template') { 9946 return false 9947 } 9948 if (node.for) { 9949 return true 9950 } 9951 } 9952 return false 9953 } 9954 9955 /* */ 9956 9957 var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; 9958 var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; 9959 9960 // KeyboardEvent.keyCode aliases 9961 var keyCodes = { 9962 esc: 27, 9963 tab: 9, 9964 enter: 13, 9965 space: 32, 9966 up: 38, 9967 left: 37, 9968 right: 39, 9969 down: 40, 9970 'delete': [8, 46] 9971 }; 9972 9973 // KeyboardEvent.key aliases 9974 var keyNames = { 9975 esc: 'Escape', 9976 tab: 'Tab', 9977 enter: 'Enter', 9978 space: ' ', 9979 // #7806: IE11 uses key names without `Arrow` prefix for arrow keys. 9980 up: ['Up', 'ArrowUp'], 9981 left: ['Left', 'ArrowLeft'], 9982 right: ['Right', 'ArrowRight'], 9983 down: ['Down', 'ArrowDown'], 9984 'delete': ['Backspace', 'Delete'] 9985 }; 9986 9987 // #4868: modifiers that prevent the execution of the listener 9988 // need to explicitly return null so that we can determine whether to remove 9989 // the listener for .once 9990 var genGuard = function(condition) { return ("if(" + condition + ")return null;"); }; 9991 9992 var modifierCode = { 9993 stop: '$event.stopPropagation();', 9994 prevent: '$event.preventDefault();', 9995 self: genGuard("$event.target !== $event.currentTarget"), 9996 ctrl: genGuard("!$event.ctrlKey"), 9997 shift: genGuard("!$event.shiftKey"), 9998 alt: genGuard("!$event.altKey"), 9999 meta: genGuard("!$event.metaKey"), 10000 left: genGuard("'button' in $event && $event.button !== 0"), 10001 middle: genGuard("'button' in $event && $event.button !== 1"), 10002 right: genGuard("'button' in $event && $event.button !== 2") 10003 }; 10004 10005 function genHandlers( 10006 events, 10007 isNative, 10008 warn 10009 ) { 10010 var res = isNative ? 'nativeOn:{' : 'on:{'; 10011 for (var name in events) { 10012 res += "\"" + name + "\":" + (genHandler(name, events[name])) + ","; 10013 } 10014 return res.slice(0, -1) + '}' 10015 } 10016 10017 function genHandler( 10018 name, 10019 handler 10020 ) { 10021 if (!handler) { 10022 return 'function(){}' 10023 } 10024 10025 if (Array.isArray(handler)) { 10026 return ("[" + (handler.map(function(handler) { return genHandler(name, handler); }).join(',')) + "]") 10027 } 10028 10029 var isMethodPath = simplePathRE.test(handler.value); 10030 var isFunctionExpression = fnExpRE.test(handler.value); 10031 10032 if (!handler.modifiers) { 10033 if (isMethodPath || isFunctionExpression) { 10034 return handler.value 10035 } 10036 /* istanbul ignore if */ 10037 return ("function($event){" + (handler.value) + "}") // inline statement 10038 } else { 10039 var code = ''; 10040 var genModifierCode = ''; 10041 var keys = []; 10042 for (var key in handler.modifiers) { 10043 if (modifierCode[key]) { 10044 genModifierCode += modifierCode[key]; 10045 // left/right 10046 if (keyCodes[key]) { 10047 keys.push(key); 10048 } 10049 } else if (key === 'exact') { 10050 var modifiers = (handler.modifiers); 10051 genModifierCode += genGuard( 10052 ['ctrl', 'shift', 'alt', 'meta'] 10053 .filter(function(keyModifier) { return !modifiers[keyModifier]; }) 10054 .map(function(keyModifier) { return ("$event." + keyModifier + "Key"); }) 10055 .join('||') 10056 ); 10057 } else { 10058 keys.push(key); 10059 } 10060 } 10061 if (keys.length) { 10062 code += genKeyFilter(keys); 10063 } 10064 // Make sure modifiers like prevent and stop get executed after key filtering 10065 if (genModifierCode) { 10066 code += genModifierCode; 10067 } 10068 var handlerCode = isMethodPath ? 10069 ("return " + (handler.value) + "($event)") : 10070 isFunctionExpression ? 10071 ("return (" + (handler.value) + ")($event)") : 10072 handler.value; 10073 /* istanbul ignore if */ 10074 return ("function($event){" + code + handlerCode + "}") 10075 } 10076 } 10077 10078 function genKeyFilter(keys) { 10079 return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;") 10080 } 10081 10082 function genFilterCode(key) { 10083 var keyVal = parseInt(key, 10); 10084 if (keyVal) { 10085 return ("$event.keyCode!==" + keyVal) 10086 } 10087 var keyCode = keyCodes[key]; 10088 var keyName = keyNames[key]; 10089 return ( 10090 "_k($event.keyCode," + 10091 (JSON.stringify(key)) + "," + 10092 (JSON.stringify(keyCode)) + "," + 10093 "$event.key," + 10094 "" + (JSON.stringify(keyName)) + 10095 ")" 10096 ) 10097 } 10098 10099 /* */ 10100 10101 function on(el, dir) { 10102 if ("development" !== 'production' && dir.modifiers) { 10103 warn("v-on without argument does not support modifiers."); 10104 } 10105 el.wrapListeners = function(code) { return ("_g(" + code + "," + (dir.value) + ")"); }; 10106 } 10107 10108 /* */ 10109 10110 function bind$1(el, dir) { 10111 el.wrapData = function(code) { 10112 return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")") 10113 }; 10114 } 10115 10116 /* */ 10117 10118 var baseDirectives = { 10119 on: on, 10120 bind: bind$1, 10121 cloak: noop 10122 } 10123 10124 /* */ 10125 10126 var CodegenState = function CodegenState(options) { 10127 this.options = options; 10128 this.warn = options.warn || baseWarn; 10129 this.transforms = pluckModuleFunction(options.modules, 'transformCode'); 10130 this.dataGenFns = pluckModuleFunction(options.modules, 'genData'); 10131 this.directives = extend(extend({}, baseDirectives), options.directives); 10132 var isReservedTag = options.isReservedTag || no; 10133 this.maybeComponent = function(el) { return !isReservedTag(el.tag); }; 10134 this.onceId = 0; 10135 this.staticRenderFns = []; 10136 }; 10137 10138 10139 10140 function generate( 10141 ast, 10142 options 10143 ) { 10144 var state = new CodegenState(options); 10145 var code = ast ? genElement(ast, state) : '_c("div")'; 10146 return { 10147 render: ("with(this){return " + code + "}"), 10148 staticRenderFns: state.staticRenderFns 10149 } 10150 } 10151 10152 function genElement(el, state) { 10153 if (el.staticRoot && !el.staticProcessed) { 10154 return genStatic(el, state) 10155 } else if (el.once && !el.onceProcessed) { 10156 return genOnce(el, state) 10157 } else if (el.for && !el.forProcessed) { 10158 return genFor(el, state) 10159 } else if (el.if && !el.ifProcessed) { 10160 return genIf(el, state) 10161 } else if (el.tag === 'template' && !el.slotTarget) { 10162 return genChildren(el, state) || 'void 0' 10163 } else if (el.tag === 'slot') { 10164 return genSlot(el, state) 10165 } else { 10166 // component or element 10167 var code; 10168 if (el.component) { 10169 code = genComponent(el.component, el, state); 10170 } else { 10171 var data = el.plain ? undefined : genData$2(el, state); 10172 10173 var children = el.inlineTemplate ? null : genChildren(el, state, true);
10174 code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; 10175 } 10176 // module transforms 10177 for (var i = 0; i < state.transforms.length; i++) { 10178 code = state.transforms[i](el, code); 10179 } 10180 return code 10181 } 10182 } 10183 10184 // hoist static sub-trees out 10185 function genStatic(el, state) { 10186 el.staticProcessed = true; 10187 state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}")); 10188 return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")") 10189 } 10190 10191 // v-once 10192 function genOnce(el, state) { 10193 el.onceProcessed = true; 10194 if (el.if && !el.ifProcessed) { 10195 return genIf(el, state) 10196 } else if (el.staticInFor) { 10197 var key = ''; 10198 var parent = el.parent; 10199 while (parent) { 10200 if (parent.for) { 10201 key = parent.key; 10202 break 10203 } 10204 parent = parent.parent; 10205 } 10206 if (!key) { 10207 "development" !== 'production' && state.warn( 10208 "v-once can only be used inside v-for that is keyed. " 10209 ); 10210 return genElement(el, state) 10211 } 10212 return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")") 10213 } else { 10214 return genStatic(el, state) 10215 } 10216 } 10217 10218 function genIf( 10219 el, 10220 state, 10221 altGen, 10222 altEmpty 10223 ) { 10224 el.ifProcessed = true; // avoid recursion 10225 return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty) 10226 } 10227 10228 function genIfConditions( 10229 conditions, 10230 state, 10231 altGen, 10232 altEmpty 10233 ) { 10234 if (!conditions.length) { 10235 return altEmpty || '_e()' 10236 } 10237 10238 var condition = conditions.shift(); 10239 if (condition.exp) { 10240 return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty))) 10241 } else { 10242 return ("" + (genTernaryExp(condition.block))) 10243 } 10244 10245 // v-if with v-once should generate code like (a)?_m(0):_m(1) 10246 function genTernaryExp(el) { 10247 return altGen ? 10248 altGen(el, state) : 10249 el.once ? 10250 genOnce(el, state) : 10251 genElement(el, state) 10252 } 10253 } 10254 10255 function genFor( 10256 el, 10257 state, 10258 altGen, 10259 altHelper 10260 ) { 10261 var exp = el.for; 10262 var alias = el.alias; 10263 var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; 10264 var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; 10265 10266 if ("development" !== 'production' && 10267 state.maybeComponent(el) && 10268 el.tag !== 'slot' && 10269 el.tag !== 'template' && 10270 !el.key 10271 ) { 10272 state.warn( 10273 "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " + 10274 "v-for should have explicit keys. " + 10275 "See https://vuejs.org/guide/list.html#key for more info.", 10276 true /* tip */ 10277 ); 10278 } 10279 10280 el.forProcessed = true; // avoid recursion 10281 return (altHelper || '_l') + "((" + exp + ")," + 10282 "function(" + alias + iterator1 + iterator2 + "){" + 10283 "return " + ((altGen || genElement)(el, state)) + 10284 '})' 10285 } 10286 10287 function genData$2(el, state) { 10288 var data = '{'; 10289 10290 // directives first. 10291 // directives may mutate the el's other properties before they are generated. 10292 var dirs = genDirectives(el, state); 10293 if (dirs) { data += dirs + ','; } 10294 10295 // key 10296 if (el.key) { 10297 data += "key:" + (el.key) + ","; 10298 } 10299 // ref 10300 if (el.ref) { 10301 data += "ref:" + (el.ref) + ","; 10302 } 10303 if (el.refInFor) { 10304 data += "refInFor:true,"; 10305 } 10306 // pre 10307 if (el.pre) { 10308 data += "pre:true,"; 10309 } 10310 // record original tag name for components using "is" attribute 10311 if (el.component) { 10312 data += "tag:\"" + (el.tag) + "\","; 10313 } 10314 // module data generation functions 10315 for (var i = 0; i < state.dataGenFns.length; i++) { 10316 data += state.dataGenFns[i](el); 10317 } 10318 // attributes 10319 if (el.attrs) {
10320 data += "attrs:{" + (genProps(el.attrs)) + "},"; 10321 } 10322 // DOM props 10323 if (el.props) { 10324 data += "domProps:{" + (genProps(el.props)) + "},"; 10325 } 10326 // event handlers 10327 if (el.events) { 10328 data += (genHandlers(el.events, false, state.warn)) + ","; 10329 } 10330 if (el.nativeEvents) { 10331 data += (genHandlers(el.nativeEvents, true, state.warn)) + ","; 10332 } 10333 // slot target 10334 // only for non-scoped slots 10335 if (el.slotTarget && !el.slotScope) { 10336 data += "slot:" + (el.slotTarget) + ","; 10337 } 10338 // scoped slots 10339 if (el.scopedSlots) { 10340 data += (genScopedSlots(el.scopedSlots, state)) + ","; 10341 } 10342 // component v-model 10343 if (el.model) { 10344 data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},"; 10345 } 10346 // inline-template 10347 if (el.inlineTemplate) { 10348 var inlineTemplate = genInlineTemplate(el, state); 10349 if (inlineTemplate) { 10350 data += inlineTemplate + ","; 10351 } 10352 } 10353 data = data.replace(/,$/, '') + '}'; 10354 // v-bind data wrap 10355 if (el.wrapData) { 10356 data = el.wrapData(data); 10357 } 10358 // v-on data wrap 10359 if (el.wrapListeners) { 10360 data = el.wrapListeners(data); 10361 } 10362 return data 10363 } 10364 10365 function genDirectives(el, state) { 10366 var dirs = el.directives; 10367 if (!dirs) { return } 10368 var res = 'directives:['; 10369 var hasRuntime = false; 10370 var i, l, dir, needRuntime; 10371 for (i = 0, l = dirs.length; i < l; i++) { 10372 dir = dirs[i]; 10373 needRuntime = true; 10374 var gen = state.directives[dir.name]; 10375 if (gen) { 10376 // compile-time directive that manipulates AST. 10377 // returns true if it also needs a runtime counterpart. 10378 needRuntime = !!gen(el, dir, state.warn); 10379 } 10380 if (needRuntime) { 10381 hasRuntime = true; 10382 res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},"; 10383 } 10384 } 10385 if (hasRuntime) { 10386 return res.slice(0, -1) + ']' 10387 } 10388 } 10389 10390 function genInlineTemplate(el, state) { 10391 var ast = el.children[0]; 10392 if ("development" !== 'production' && ( 10393 el.children.length !== 1 || ast.type !== 1 10394 )) { 10395 state.warn('Inline-template components must have exactly one child element.'); 10396 } 10397 if (ast.type === 1) { 10398 var inlineRenderFns = generate(ast, state.options); 10399 return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function(code) { return ("function(){" + code + "}"); }).join(',')) + "]}") 10400 } 10401 } 10402 10403 function genScopedSlots( 10404 slots, 10405 state 10406 ) { 10407 return ("scopedSlots:_u([" + (Object.keys(slots).map(function(key) { 10408 return genScopedSlot(key, slots[key], state) 10409 }).join(',')) + "])") 10410 } 10411 10412 function genScopedSlot( 10413 key, 10414 el, 10415 state 10416 ) { 10417 if (el.for && !el.forProcessed) { 10418 return genForScopedSlot(key, el, state) 10419 } 10420 var fn = "function(" + (String(el.slotScope)) + "){" + 10421 "return " + (el.tag === 'template' ? 10422 el.if ? 10423 ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined") : 10424 genChildren(el, state) || 'undefined' : 10425 genElement(el, state)) + "}"; 10426 return ("{key:" + key + ",fn:" + fn + "}") 10427 } 10428 10429 function genForScopedSlot( 10430 key, 10431 el, 10432 state 10433 ) { 10434 var exp = el.for; 10435 var alias = el.alias; 10436 var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; 10437 var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; 10438 el.forProcessed = true; // avoid recursion 10439 return "_l((" + exp + ")," + 10440 "function(" + alias + iterator1 + iterator2 + "){" + 10441 "return " + (genScopedSlot(key, el, state)) + 10442 '})' 10443 } 10444
10445 function genChildren( 10446 el, 10447 state, 10448 checkSkip, 10449 altGenElement, 10450 altGenNode 10451 ) { 10452 var children = el.children; 10453 if (children.length) { 10454 var el$1 = children[0]; 10455 // optimize single v-for 10456 if (children.length === 1 && 10457 el$1.for && 10458 el$1.tag !== 'template' && 10459 el$1.tag !== 'slot' 10460 ) { 10461 return (altGenElement || genElement)(el$1, state) 10462 } 10463 var normalizationType = checkSkip ? 10464 getNormalizationType(children, state.maybeComponent) : 10465 0; 10466 var gen = altGenNode || genNode; 10467 return ("[" + (children.map(function(c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : '')) 10468 } 10469 } 10470 10471 // determine the normalization needed for the children array. 10472 // 0: no normalization needed 10473 // 1: simple normalization needed (possible 1-level deep nested array) 10474 // 2: full normalization needed 10475 function getNormalizationType( 10476 children, 10477 maybeComponent 10478 ) { 10479 var res = 0; 10480 for (var i = 0; i < children.length; i++) { 10481 var el = children[i]; 10482 if (el.type !== 1) { 10483 continue 10484 } 10485 if (needsNormalization(el) || 10486 (el.ifConditions && el.ifConditions.some(function(c) { return needsNormalization(c.block); }))) { 10487 res = 2; 10488 break 10489 } 10490 if (maybeComponent(el) || 10491 (el.ifConditions && el.ifConditions.some(function(c) { return maybeComponent(c.block); }))) { 10492 res = 1; 10493 } 10494 } 10495 return res 10496 } 10497 10498 function needsNormalization(el) { 10499 return el.for !== undefined || el.tag === 'template' || el.tag === 'slot' 10500 } 10501 10502 function genNode(node, state) { 10503 if (node.type === 1) { 10504 return genElement(node, state) 10505 } 10506 if (node.type === 3 && node.isComment) { 10507 return genComment(node) 10508 } else { 10509 return genText(node) 10510 } 10511 } 10512 10513 function genText(text) { 10514 return ("_v(" + (text.type === 2 ? 10515 text.expression // no need for () because already wrapped in _s() 10516 : 10517 transformSpecialNewlines(JSON.stringify(text.text))) + ")") 10518 } 10519 10520 function genComment(comment) { 10521 return ("_e(" + (JSON.stringify(comment.text)) + ")") 10522 } 10523 10524 function genSlot(el, state) { 10525 var slotName = el.slotName || '"default"'; 10526 var children = genChildren(el, state); 10527 var res = "_t(" + slotName + (children ? ("," + children) : ''); 10528 var attrs = el.attrs && ("{" + (el.attrs.map(function(a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}"); 10529 var bind$$1 = el.attrsMap['v-bind']; 10530 if ((attrs || bind$$1) && !children) { 10531 res += ",null"; 10532 } 10533 if (attrs) { 10534 res += "," + attrs; 10535 } 10536 if (bind$$1) { 10537 res += (attrs ? '' : ',null') + "," + bind$$1; 10538 } 10539 return res + ')' 10540 } 10541 10542 // componentName is el.component, take it as argument to shun flow's pessimistic refinement 10543 function genComponent( 10544 componentName, 10545 el, 10546 state 10547 ) { 10548 var children = el.inlineTemplate ? null : genChildren(el, state, true); 10549 return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")") 10550 } 10551 10552 function genProps(props) { 10553 var res = ''; 10554 for (var i = 0; i < props.length; i++) { 10555 var prop = props[i]; 10556 /* istanbul ignore if */ 10557 { 10558 res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ","; 10559 } 10560 } 10561 return res.slice(0, -1) 10562 } 10563 10564 // #3895, #4268 10565 function transformSpecialNewlines(text) { 10566 return text 10567 .replace(/\u2028/g, '\\u2028') 10568 .replace(/\u2029/g, '\\u2029') 10569 } 10570 10571 /* */ 10572 10573 // these keywords should not appear inside expressions, but operators like 10574 // typeof, instanceof and in are allowed 10575 var prohibitedKeywordRE = new RegExp('\\b' + ( 10576 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' + 10577 'super,throw,while,yield,delete,export,import,return,switch,default,' + 10578 'extends,finally,continue,debugger,function,arguments' 10579 ).split(',').join('\\b|\\b') + '\\b'); 10580 10581 // these unary operators should not be used as property/method names 10582 var unaryOperatorsRE = new RegExp('\\b' + ( 10583 'delete,typeof,void' 10584 ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)'); 10585 10586 // strip strings in expressions 10587 var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g; 10588 10589 // detect problematic expressions in a template 10590 function detectErrors(ast) { 10591 var errors = []; 10592 if (ast) { 10593 checkNode(ast, errors); 10594 } 10595 return errors 10596 } 10597 10598 function checkNode(node, errors) { 10599 if (node.type === 1) { 10600 for (var name in node.attrsMap) { 10601 if (dirRE.test(name)) { 10602 var value = node.attrsMap[name]; 10603 if (value) { 10604 if (name === 'v-for') { 10605 checkFor(node, ("v-for=\"" + value + "\""), errors); 10606 } else if (onRE.test(name)) { 10607 checkEvent(value, (name + "=\"" + value + "\""), errors); 10608 } else { 10609 checkExpression(value, (name + "=\"" + value + "\""), errors); 10610 } 10611 } 10612 } 10613 } 10614 if (node.children) { 10615 for (var i = 0; i < node.children.length; i++) { 10616 checkNode(node.children[i], errors); 10617 } 10618 } 10619 } else if (node.type === 2) { 10620 checkExpression(node.expression, node.text, errors); 10621 } 10622 } 10623 10624 function checkEvent(exp, text, errors) { 10625 var stipped = exp.replace(stripStringRE, ''); 10626 var keywordMatch = stipped.match(unaryOperatorsRE); 10627 if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') { 10628 errors.push( 10629 "avoid using JavaScript unary operator as property name: " + 10630 "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()) 10631 ); 10632 } 10633 checkExpression(exp, text, errors); 10634 } 10635 10636 function checkFor(node, text, errors) { 10637 checkExpression(node.for || '', text, errors); 10638 checkIdentifier(node.alias, 'v-for alias', text, errors); 10639 checkIdentifier(node.iterator1, 'v-for iterator', text, errors); 10640 checkIdentifier(node.iterator2, 'v-for iterator', text, errors); 10641 } 10642 10643 function checkIdentifier( 10644 ident, 10645 type, 10646 text, 10647 errors 10648 ) { 10649 if (typeof ident === 'string') { 10650 try { 10651 new Function(("var " + ident + "=_")); 10652 } catch (e) { 10653 errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim()))); 10654 } 10655 } 10656 } 10657 10658 function checkExpression(exp, text, errors) { 10659 try { 10660 new Function(("return " + exp)); 10661 } catch (e) { 10662 var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE); 10663 if (keywordMatch) { 10664 errors.push( 10665 "avoid using JavaScript keyword as property name: " + 10666 "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim()) 10667 ); 10668 } else { 10669 errors.push( 10670 "invalid expression: " + (e.message) + " in\n\n" + 10671 " " + exp + "\n\n" + 10672 " Raw expression: " + (text.trim()) + "\n" 10673 ); 10674 } 10675 } 10676 } 10677 10678 /* */ 10679 10680 function createFunction(code, errors) { 10681 try { 10682 return new Function(code) 10683 } catch (err) { 10684 errors.push({ err: err, code: code }); 10685 return noop 10686 } 10687 } 10688 10689 function createCompileToFunctionFn(compile) { 10690 var cache = Object.create(null); 10691 10692 return function compileToFunctions( 10693 template, 10694 options, 10695 vm 10696 ) { 10697 options = extend({}, options); 10698 var warn$$1 = options.warn || warn; 10699 delete options.warn; 10700 10701 /* istanbul ignore if */ 10702 { 10703 // detect possible CSP restriction 10704 try { 10705 new Function('return 1'); 10706 } catch (e) { 10707 if (e.toString().match(/unsafe-eval|CSP/)) { 10708 warn$$1( 10709 'It seems you are using the standalone build of Vue.js in an ' + 10710 'environment with Content Security Policy that prohibits unsafe-eval. ' + 10711 'The template compiler cannot work in this environment. Consider ' + 10712 'relaxing the policy to allow unsafe-eval or pre-compiling your ' + 10713 'templates into render functions.' 10714 ); 10715 } 10716 } 10717 } 10718 10719 // check cache 10720 var key = options.delimiters ? 10721 String(options.delimiters) + template : 10722 template; 10723 if (cache[key]) { 10724 return cache[key] 10725 } 10726 10727 // compile 10728 var compiled = compile(template, options); 10729 10730 // check compilation errors/tips 10731 { 10732 if (compiled.errors && compiled.errors.length) { 10733 warn$$1(
10734 "Error compiling template:\n\n" + template + "\n\n" + 10735 compiled.errors.map(function(e) { return ("- " + e); }).join('\n') + '\n', 10736 vm 10737 ); 10738 } 10739 if (compiled.tips && compiled.tips.length) { 10740 compiled.tips.forEach(function(msg) { return tip(msg, vm); }); 10741 } 10742 } 10743 10744 // turn code into functions 10745 var res = {}; 10746 var fnGenErrors = []; 10747 res.render = createFunction(compiled.render, fnGenErrors); 10748 res.staticRenderFns = compiled.staticRenderFns.map(function(code) { 10749 return createFunction(code, fnGenErrors) 10750 }); 10751 10752 // check function generation errors. 10753 // this should only happen if there is a bug in the compiler itself. 10754 // mostly for codegen development use 10755 /* istanbul ignore if */ 10756 { 10757 if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) { 10758 warn$$1( 10759 "Failed to generate render function:\n\n" + 10760 fnGenErrors.map(function(ref) { 10761 var err = ref.err; 10762 var code = ref.code; 10763 10764 return ((err.toString()) + " in\n\n" + code + "\n"); 10765 }).join('\n'), 10766 vm 10767 ); 10768 } 10769 } 10770 10771 return (cache[key] = res) 10772 } 10773 } 10774 10775 /* */ 10776 10777 function createCompilerCreator(baseCompile) { 10778 return function createCompiler(baseOptions) { 10779 function compile( 10780 template, 10781 options 10782 ) { 10783 var finalOptions = Object.create(baseOptions); 10784 var errors = []; 10785 var tips = []; 10786 finalOptions.warn = function(msg, tip) { 10787 (tip ? tips : errors).push(msg); 10788 }; 10789 10790 if (options) { 10791 // merge custom modules 10792 if (options.modules) { 10793 finalOptions.modules = 10794 (baseOptions.modules || []).concat(options.modules); 10795 } 10796 // merge custom directives 10797 if (options.directives) { 10798 finalOptions.directives = extend( 10799 Object.create(baseOptions.directives || null), 10800 options.directives 10801 ); 10802 } 10803 // copy other options 10804 for (var key in options) { 10805 if (key !== 'modules' && key !== 'directives') { 10806 finalOptions[key] = options[key]; 10807 } 10808 } 10809 } 10810 10811 var compiled = baseCompile(template, finalOptions); { 10812 errors.push.apply(errors, detectErrors(compiled.ast)); 10813 } 10814 compiled.errors = errors; 10815 compiled.tips = tips; 10816 return compiled 10817 } 10818 10819 return { 10820 compile: compile, 10821 compileToFunctions: createCompileToFunctionFn(compile) 10822 } 10823 } 10824 } 10825 10826 /* */ 10827 10828 // `createCompilerCreator` allows creating compilers that use alternative 10829 // parser/optimizer/codegen, e.g the SSR optimizing compiler. 10830 // Here we just export a default compiler using the default parts. 10831 var createCompiler = createCompilerCreator(function baseCompile( 10832 template, 10833 options 10834 ) { 10835 var ast = parse(template.trim(), options); 10836 if (options.optimize !== false) { 10837 optimize(ast, options); 10838 } 10839 var code = generate(ast, options); 10840 return { 10841 ast: ast, 10842 render: code.render, 10843 staticRenderFns: code.staticRenderFns 10844 } 10845 });
10846 10847 /* */ 10848 10849 var ref$1 = createCompiler(baseOptions); 10850 var compileToFunctions = ref$1.compileToFunctions; 10851 10852 /* */ 10853 10854 // check whether current browser encodes a char inside attribute values 10855 var div; 10856 10857 function getShouldDecode(href) { 10858 div = div || document.createElement('div'); 10859 div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>"; 10860 return div.innerHTML.indexOf(' ') > 0 10861 } 10862 10863 // #3663: IE encodes newlines inside attribute values while other browsers don't 10864 var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false; 10865 // #6828: chrome encodes content in a[href] 10866 var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false; 10867 10868 /* */ 10869 10870 var idToTemplate = cached(function(id) { 10871 var el = query(id); 10872 return el && el.innerHTML 10873 }); 10874 10875 var mount = Vue.prototype.$mount; 10876 Vue.prototype.$mount = function( 10877 el, 10878 hydrating 10879 ) { 10880 el = el && query(el); 10881 10882 /* istanbul ignore if */ 10883 if (el === document.body || el === document.documentElement) { 10884 "development" !== 'production' && warn( 10885 "Do not mount Vue to <html> or <body> - mount to normal elements instead." 10886 ); 10887 return this 10888 } 10889 10890 var options = this.$options; 10891 // resolve template/el and convert to render function 10892 if (!options.render) { 10893 var template = options.template; 10894 if (template) { 10895 if (typeof template === 'string') { 10896 if (template.charAt(0) === '#') { 10897 template = idToTemplate(template); 10898 /* istanbul ignore if */ 10899 if ("development" !== 'production' && !template) { 10900 warn( 10901 ("Template element not found or is empty: " + (options.template)), 10902 this 10903 ); 10904 } 10905 } 10906 } else if (template.nodeType) { 10907 template = template.innerHTML; 10908 } else { 10909 { 10910 warn('invalid template option:' + template, this); 10911 } 10912 return this 10913 } 10914 } else if (el) { 10915 template = getOuterHTML(el); 10916 } 10917 if (template) { 10918 /* istanbul ignore if */ 10919 if ("development" !== 'production' && config.performance && mark) { 10920 mark('compile'); 10921 } 10922 10923 var ref = compileToFunctions(template, { 10924 shouldDecodeNewlines: shouldDecodeNewlines, 10925 shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref, 10926 delimiters: options.delimiters, 10927 comments: options.comments 10928 }, this); 10929 var render = ref.render; 10930 var staticRenderFns = ref.staticRenderFns; 10931 options.render = render; 10932 options.staticRenderFns = staticRenderFns; 10933 10934 /* istanbul ignore if */ 10935 if ("development" !== 'production' && config.performance && mark) { 10936 mark('compile end'); 10937 measure(("vue " + (this._name) + " compile"), 'compile', 'compile end'); 10938 } 10939 } 10940 } 10941 return mount.call(this, el, hydrating) 10942 }; 10943 10944 /** 10945 * Get outerHTML of elements, taking care 10946 * of SVG elements in IE as well. 10947 */ 10948 function getOuterHTML(el) { 10949 if (el.outerHTML) { 10950 return el.outerHTML 10951 } else { 10952 var container = document.createElement('div'); 10953 container.appendChild(el.cloneNode(true)); 10954 return container.innerHTML 10955 } 10956 } 10957 10958 Vue.compile = compileToFunctions; 10959 10960 return Vue; 10961 10962})));
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.