vue 2.6.2 → 2.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.6.2
2
+ * Vue.js v2.6.6
3
3
  * (c) 2014-2019 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -523,6 +523,7 @@ var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android'
523
523
  var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
524
524
  var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
525
525
  var isPhantomJS = UA && /phantomjs/.test(UA);
526
+ var isFF = UA && UA.match(/firefox\/(\d+)/);
526
527
 
527
528
  // Firefox has a "watch" function on Object.prototype...
528
529
  var nativeWatch = ({}).watch;
@@ -1858,7 +1859,11 @@ function globalHandleError (err, vm, info) {
1858
1859
  try {
1859
1860
  return config.errorHandler.call(null, err, vm, info)
1860
1861
  } catch (e) {
1861
- logError(e, null, 'config.errorHandler');
1862
+ // if the user intentionally throws the original error in the handler,
1863
+ // do not log it twice
1864
+ if (e !== err) {
1865
+ logError(e, null, 'config.errorHandler');
1866
+ }
1862
1867
  }
1863
1868
  }
1864
1869
  logError(err, vm, info);
@@ -2399,2450 +2404,2496 @@ function normalizeArrayChildren (children, nestedIndex) {
2399
2404
 
2400
2405
  /* */
2401
2406
 
2402
- function ensureCtor (comp, base) {
2403
- if (
2404
- comp.__esModule ||
2405
- (hasSymbol && comp[Symbol.toStringTag] === 'Module')
2406
- ) {
2407
- comp = comp.default;
2407
+ function initProvide (vm) {
2408
+ var provide = vm.$options.provide;
2409
+ if (provide) {
2410
+ vm._provided = typeof provide === 'function'
2411
+ ? provide.call(vm)
2412
+ : provide;
2408
2413
  }
2409
- return isObject(comp)
2410
- ? base.extend(comp)
2411
- : comp
2412
2414
  }
2413
2415
 
2414
- function createAsyncPlaceholder (
2415
- factory,
2416
- data,
2417
- context,
2418
- children,
2419
- tag
2420
- ) {
2421
- var node = createEmptyVNode();
2422
- node.asyncFactory = factory;
2423
- node.asyncMeta = { data: data, context: context, children: children, tag: tag };
2424
- return node
2425
- }
2426
-
2427
- function resolveAsyncComponent (
2428
- factory,
2429
- baseCtor,
2430
- context
2431
- ) {
2432
- if (isTrue(factory.error) && isDef(factory.errorComp)) {
2433
- return factory.errorComp
2434
- }
2435
-
2436
- if (isDef(factory.resolved)) {
2437
- return factory.resolved
2438
- }
2439
-
2440
- if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
2441
- return factory.loadingComp
2442
- }
2443
-
2444
- if (isDef(factory.contexts)) {
2445
- // already pending
2446
- factory.contexts.push(context);
2447
- } else {
2448
- var contexts = factory.contexts = [context];
2449
- var sync = true;
2450
-
2451
- var forceRender = function (renderCompleted) {
2452
- for (var i = 0, l = contexts.length; i < l; i++) {
2453
- contexts[i].$forceUpdate();
2454
- }
2455
-
2456
- if (renderCompleted) {
2457
- contexts.length = 0;
2458
- }
2459
- };
2460
-
2461
- var resolve = once(function (res) {
2462
- // cache resolved
2463
- factory.resolved = ensureCtor(res, baseCtor);
2464
- // invoke callbacks only if this is not a synchronous resolve
2465
- // (async resolves are shimmed as synchronous during SSR)
2466
- if (!sync) {
2467
- forceRender(true);
2416
+ function initInjections (vm) {
2417
+ var result = resolveInject(vm.$options.inject, vm);
2418
+ if (result) {
2419
+ toggleObserving(false);
2420
+ Object.keys(result).forEach(function (key) {
2421
+ /* istanbul ignore else */
2422
+ if (process.env.NODE_ENV !== 'production') {
2423
+ defineReactive$$1(vm, key, result[key], function () {
2424
+ warn(
2425
+ "Avoid mutating an injected value directly since the changes will be " +
2426
+ "overwritten whenever the provided component re-renders. " +
2427
+ "injection being mutated: \"" + key + "\"",
2428
+ vm
2429
+ );
2430
+ });
2468
2431
  } else {
2469
- contexts.length = 0;
2470
- }
2471
- });
2472
-
2473
- var reject = once(function (reason) {
2474
- process.env.NODE_ENV !== 'production' && warn(
2475
- "Failed to resolve async component: " + (String(factory)) +
2476
- (reason ? ("\nReason: " + reason) : '')
2477
- );
2478
- if (isDef(factory.errorComp)) {
2479
- factory.error = true;
2480
- forceRender(true);
2432
+ defineReactive$$1(vm, key, result[key]);
2481
2433
  }
2482
2434
  });
2435
+ toggleObserving(true);
2436
+ }
2437
+ }
2483
2438
 
2484
- var res = factory(resolve, reject);
2485
-
2486
- if (isObject(res)) {
2487
- if (isPromise(res)) {
2488
- // () => Promise
2489
- if (isUndef(factory.resolved)) {
2490
- res.then(resolve, reject);
2491
- }
2492
- } else if (isPromise(res.component)) {
2493
- res.component.then(resolve, reject);
2494
-
2495
- if (isDef(res.error)) {
2496
- factory.errorComp = ensureCtor(res.error, baseCtor);
2497
- }
2439
+ function resolveInject (inject, vm) {
2440
+ if (inject) {
2441
+ // inject is :any because flow is not smart enough to figure out cached
2442
+ var result = Object.create(null);
2443
+ var keys = hasSymbol
2444
+ ? Reflect.ownKeys(inject)
2445
+ : Object.keys(inject);
2498
2446
 
2499
- if (isDef(res.loading)) {
2500
- factory.loadingComp = ensureCtor(res.loading, baseCtor);
2501
- if (res.delay === 0) {
2502
- factory.loading = true;
2503
- } else {
2504
- setTimeout(function () {
2505
- if (isUndef(factory.resolved) && isUndef(factory.error)) {
2506
- factory.loading = true;
2507
- forceRender(false);
2508
- }
2509
- }, res.delay || 200);
2510
- }
2447
+ for (var i = 0; i < keys.length; i++) {
2448
+ var key = keys[i];
2449
+ // #6574 in case the inject object is observed...
2450
+ if (key === '__ob__') { continue }
2451
+ var provideKey = inject[key].from;
2452
+ var source = vm;
2453
+ while (source) {
2454
+ if (source._provided && hasOwn(source._provided, provideKey)) {
2455
+ result[key] = source._provided[provideKey];
2456
+ break
2511
2457
  }
2512
-
2513
- if (isDef(res.timeout)) {
2514
- setTimeout(function () {
2515
- if (isUndef(factory.resolved)) {
2516
- reject(
2517
- process.env.NODE_ENV !== 'production'
2518
- ? ("timeout (" + (res.timeout) + "ms)")
2519
- : null
2520
- );
2521
- }
2522
- }, res.timeout);
2458
+ source = source.$parent;
2459
+ }
2460
+ if (!source) {
2461
+ if ('default' in inject[key]) {
2462
+ var provideDefault = inject[key].default;
2463
+ result[key] = typeof provideDefault === 'function'
2464
+ ? provideDefault.call(vm)
2465
+ : provideDefault;
2466
+ } else if (process.env.NODE_ENV !== 'production') {
2467
+ warn(("Injection \"" + key + "\" not found"), vm);
2523
2468
  }
2524
2469
  }
2525
2470
  }
2526
-
2527
- sync = false;
2528
- // return in case resolved synchronously
2529
- return factory.loading
2530
- ? factory.loadingComp
2531
- : factory.resolved
2471
+ return result
2532
2472
  }
2533
2473
  }
2534
2474
 
2535
2475
  /* */
2536
2476
 
2537
- function isAsyncPlaceholder (node) {
2538
- return node.isComment && node.asyncFactory
2539
- }
2540
2477
 
2541
- /* */
2542
2478
 
2543
- function getFirstComponentChild (children) {
2544
- if (Array.isArray(children)) {
2545
- for (var i = 0; i < children.length; i++) {
2546
- var c = children[i];
2547
- if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
2548
- return c
2479
+ /**
2480
+ * Runtime helper for resolving raw children VNodes into a slot object.
2481
+ */
2482
+ function resolveSlots (
2483
+ children,
2484
+ context
2485
+ ) {
2486
+ if (!children || !children.length) {
2487
+ return {}
2488
+ }
2489
+ var slots = {};
2490
+ for (var i = 0, l = children.length; i < l; i++) {
2491
+ var child = children[i];
2492
+ var data = child.data;
2493
+ // remove slot attribute if the node is resolved as a Vue slot node
2494
+ if (data && data.attrs && data.attrs.slot) {
2495
+ delete data.attrs.slot;
2496
+ }
2497
+ // named slots should only be respected if the vnode was rendered in the
2498
+ // same context.
2499
+ if ((child.context === context || child.fnContext === context) &&
2500
+ data && data.slot != null
2501
+ ) {
2502
+ var name = data.slot;
2503
+ var slot = (slots[name] || (slots[name] = []));
2504
+ if (child.tag === 'template') {
2505
+ slot.push.apply(slot, child.children || []);
2506
+ } else {
2507
+ slot.push(child);
2549
2508
  }
2509
+ } else {
2510
+ (slots.default || (slots.default = [])).push(child);
2511
+ }
2512
+ }
2513
+ // ignore slots that contains only whitespace
2514
+ for (var name$1 in slots) {
2515
+ if (slots[name$1].every(isWhitespace)) {
2516
+ delete slots[name$1];
2550
2517
  }
2551
2518
  }
2519
+ return slots
2552
2520
  }
2553
2521
 
2554
- /* */
2522
+ function isWhitespace (node) {
2523
+ return (node.isComment && !node.asyncFactory) || node.text === ' '
2524
+ }
2555
2525
 
2556
2526
  /* */
2557
2527
 
2558
- function initEvents (vm) {
2559
- vm._events = Object.create(null);
2560
- vm._hasHookEvent = false;
2561
- // init parent attached events
2562
- var listeners = vm.$options._parentListeners;
2563
- if (listeners) {
2564
- updateComponentListeners(vm, listeners);
2528
+ function normalizeScopedSlots (
2529
+ slots,
2530
+ normalSlots,
2531
+ prevSlots
2532
+ ) {
2533
+ var res;
2534
+ if (!slots) {
2535
+ res = {};
2536
+ } else if (slots._normalized) {
2537
+ // fast path 1: child component re-render only, parent did not change
2538
+ return slots._normalized
2539
+ } else if (
2540
+ slots.$stable &&
2541
+ prevSlots &&
2542
+ prevSlots !== emptyObject &&
2543
+ Object.keys(normalSlots).length === 0
2544
+ ) {
2545
+ // fast path 2: stable scoped slots w/ no normal slots to proxy,
2546
+ // only need to normalize once
2547
+ return prevSlots
2548
+ } else {
2549
+ res = {};
2550
+ for (var key in slots) {
2551
+ if (slots[key] && key[0] !== '$') {
2552
+ res[key] = normalizeScopedSlot(normalSlots, key, slots[key]);
2553
+ }
2554
+ }
2555
+ }
2556
+ // expose normal slots on scopedSlots
2557
+ for (var key$1 in normalSlots) {
2558
+ if (!(key$1 in res)) {
2559
+ res[key$1] = proxyNormalSlot(normalSlots, key$1);
2560
+ }
2561
+ }
2562
+ // avoriaz seems to mock a non-extensible $scopedSlots object
2563
+ // and when that is passed down this would cause an error
2564
+ if (slots && Object.isExtensible(slots)) {
2565
+ (slots)._normalized = res;
2565
2566
  }
2567
+ def(res, '$stable', slots ? !!slots.$stable : true);
2568
+ return res
2566
2569
  }
2567
2570
 
2568
- var target;
2571
+ function normalizeScopedSlot(normalSlots, key, fn) {
2572
+ var normalized = function () {
2573
+ var res = arguments.length ? fn.apply(null, arguments) : fn({});
2574
+ res = res && typeof res === 'object' && !Array.isArray(res)
2575
+ ? [res] // single vnode
2576
+ : normalizeChildren(res);
2577
+ return res && res.length === 0
2578
+ ? undefined
2579
+ : res
2580
+ };
2581
+ // this is a slot using the new v-slot syntax without scope. although it is
2582
+ // compiled as a scoped slot, render fn users would expect it to be present
2583
+ // on this.$slots because the usage is semantically a normal slot.
2584
+ if (fn.proxy) {
2585
+ Object.defineProperty(normalSlots, key, {
2586
+ get: normalized,
2587
+ enumerable: true,
2588
+ configurable: true
2589
+ });
2590
+ }
2591
+ return normalized
2592
+ }
2569
2593
 
2570
- function add (event, fn) {
2571
- target.$on(event, fn);
2572
- }
2573
-
2574
- function remove$1 (event, fn) {
2575
- target.$off(event, fn);
2594
+ function proxyNormalSlot(slots, key) {
2595
+ return function () { return slots[key]; }
2576
2596
  }
2577
2597
 
2578
- function createOnceHandler (event, fn) {
2579
- var _target = target;
2580
- return function onceHandler () {
2581
- var res = fn.apply(null, arguments);
2582
- if (res !== null) {
2583
- _target.$off(event, onceHandler);
2584
- }
2585
- }
2586
- }
2598
+ /* */
2587
2599
 
2588
- function updateComponentListeners (
2589
- vm,
2590
- listeners,
2591
- oldListeners
2600
+ /**
2601
+ * Runtime helper for rendering v-for lists.
2602
+ */
2603
+ function renderList (
2604
+ val,
2605
+ render
2592
2606
  ) {
2593
- target = vm;
2594
- updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
2595
- target = undefined;
2596
- }
2597
-
2598
- function eventsMixin (Vue) {
2599
- var hookRE = /^hook:/;
2600
- Vue.prototype.$on = function (event, fn) {
2601
- var vm = this;
2602
- if (Array.isArray(event)) {
2603
- for (var i = 0, l = event.length; i < l; i++) {
2604
- vm.$on(event[i], fn);
2605
- }
2606
- } else {
2607
- (vm._events[event] || (vm._events[event] = [])).push(fn);
2608
- // optimize hook:event cost by using a boolean flag marked at registration
2609
- // instead of a hash lookup
2610
- if (hookRE.test(event)) {
2611
- vm._hasHookEvent = true;
2612
- }
2613
- }
2614
- return vm
2615
- };
2616
-
2617
- Vue.prototype.$once = function (event, fn) {
2618
- var vm = this;
2619
- function on () {
2620
- vm.$off(event, on);
2621
- fn.apply(vm, arguments);
2622
- }
2623
- on.fn = fn;
2624
- vm.$on(event, on);
2625
- return vm
2626
- };
2627
-
2628
- Vue.prototype.$off = function (event, fn) {
2629
- var vm = this;
2630
- // all
2631
- if (!arguments.length) {
2632
- vm._events = Object.create(null);
2633
- return vm
2634
- }
2635
- // array of events
2636
- if (Array.isArray(event)) {
2637
- for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
2638
- vm.$off(event[i$1], fn);
2639
- }
2640
- return vm
2641
- }
2642
- // specific event
2643
- var cbs = vm._events[event];
2644
- if (!cbs) {
2645
- return vm
2646
- }
2647
- if (!fn) {
2648
- vm._events[event] = null;
2649
- return vm
2607
+ var ret, i, l, keys, key;
2608
+ if (Array.isArray(val) || typeof val === 'string') {
2609
+ ret = new Array(val.length);
2610
+ for (i = 0, l = val.length; i < l; i++) {
2611
+ ret[i] = render(val[i], i);
2650
2612
  }
2651
- // specific handler
2652
- var cb;
2653
- var i = cbs.length;
2654
- while (i--) {
2655
- cb = cbs[i];
2656
- if (cb === fn || cb.fn === fn) {
2657
- cbs.splice(i, 1);
2658
- break
2659
- }
2613
+ } else if (typeof val === 'number') {
2614
+ ret = new Array(val);
2615
+ for (i = 0; i < val; i++) {
2616
+ ret[i] = render(i + 1, i);
2660
2617
  }
2661
- return vm
2662
- };
2663
-
2664
- Vue.prototype.$emit = function (event) {
2665
- var vm = this;
2666
- if (process.env.NODE_ENV !== 'production') {
2667
- var lowerCaseEvent = event.toLowerCase();
2668
- if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
2669
- tip(
2670
- "Event \"" + lowerCaseEvent + "\" is emitted in component " +
2671
- (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
2672
- "Note that HTML attributes are case-insensitive and you cannot use " +
2673
- "v-on to listen to camelCase events when using in-DOM templates. " +
2674
- "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
2675
- );
2618
+ } else if (isObject(val)) {
2619
+ if (hasSymbol && val[Symbol.iterator]) {
2620
+ ret = [];
2621
+ var iterator = val[Symbol.iterator]();
2622
+ var result = iterator.next();
2623
+ while (!result.done) {
2624
+ ret.push(render(result.value, ret.length));
2625
+ result = iterator.next();
2676
2626
  }
2677
- }
2678
- var cbs = vm._events[event];
2679
- if (cbs) {
2680
- cbs = cbs.length > 1 ? toArray(cbs) : cbs;
2681
- var args = toArray(arguments, 1);
2682
- var info = "event handler for \"" + event + "\"";
2683
- for (var i = 0, l = cbs.length; i < l; i++) {
2684
- invokeWithErrorHandling(cbs[i], vm, args, vm, info);
2627
+ } else {
2628
+ keys = Object.keys(val);
2629
+ ret = new Array(keys.length);
2630
+ for (i = 0, l = keys.length; i < l; i++) {
2631
+ key = keys[i];
2632
+ ret[i] = render(val[key], key, i);
2685
2633
  }
2686
2634
  }
2687
- return vm
2688
- };
2635
+ }
2636
+ if (!isDef(ret)) {
2637
+ ret = [];
2638
+ }
2639
+ (ret)._isVList = true;
2640
+ return ret
2689
2641
  }
2690
2642
 
2691
2643
  /* */
2692
2644
 
2693
-
2694
-
2695
2645
  /**
2696
- * Runtime helper for resolving raw children VNodes into a slot object.
2646
+ * Runtime helper for rendering <slot>
2697
2647
  */
2698
- function resolveSlots (
2699
- children,
2700
- context
2648
+ function renderSlot (
2649
+ name,
2650
+ fallback,
2651
+ props,
2652
+ bindObject
2701
2653
  ) {
2702
- if (!children || !children.length) {
2703
- return {}
2704
- }
2705
- var slots = {};
2706
- for (var i = 0, l = children.length; i < l; i++) {
2707
- var child = children[i];
2708
- var data = child.data;
2709
- // remove slot attribute if the node is resolved as a Vue slot node
2710
- if (data && data.attrs && data.attrs.slot) {
2711
- delete data.attrs.slot;
2712
- }
2713
- // named slots should only be respected if the vnode was rendered in the
2714
- // same context.
2715
- if ((child.context === context || child.fnContext === context) &&
2716
- data && data.slot != null
2717
- ) {
2718
- var name = data.slot;
2719
- var slot = (slots[name] || (slots[name] = []));
2720
- if (child.tag === 'template') {
2721
- slot.push.apply(slot, child.children || []);
2722
- } else {
2723
- slot.push(child);
2654
+ var scopedSlotFn = this.$scopedSlots[name];
2655
+ var nodes;
2656
+ if (scopedSlotFn) { // scoped slot
2657
+ props = props || {};
2658
+ if (bindObject) {
2659
+ if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) {
2660
+ warn(
2661
+ 'slot v-bind without argument expects an Object',
2662
+ this
2663
+ );
2724
2664
  }
2725
- } else {
2726
- (slots.default || (slots.default = [])).push(child);
2665
+ props = extend(extend({}, bindObject), props);
2727
2666
  }
2667
+ nodes = scopedSlotFn(props) || fallback;
2668
+ } else {
2669
+ nodes = this.$slots[name] || fallback;
2728
2670
  }
2729
- // ignore slots that contains only whitespace
2730
- for (var name$1 in slots) {
2731
- if (slots[name$1].every(isWhitespace)) {
2732
- delete slots[name$1];
2733
- }
2671
+
2672
+ var target = props && props.slot;
2673
+ if (target) {
2674
+ return this.$createElement('template', { slot: target }, nodes)
2675
+ } else {
2676
+ return nodes
2734
2677
  }
2735
- return slots
2736
2678
  }
2737
2679
 
2738
- function isWhitespace (node) {
2739
- return (node.isComment && !node.asyncFactory) || node.text === ' '
2740
- }
2680
+ /* */
2741
2681
 
2742
- function resolveScopedSlots (
2743
- fns, // see flow/vnode
2744
- hasDynamicKeys,
2745
- res
2746
- ) {
2747
- res = res || { $stable: !hasDynamicKeys };
2748
- for (var i = 0; i < fns.length; i++) {
2749
- var slot = fns[i];
2750
- if (Array.isArray(slot)) {
2751
- resolveScopedSlots(slot, hasDynamicKeys, res);
2752
- } else if (slot) {
2753
- res[slot.key] = slot.fn;
2754
- }
2755
- }
2756
- return res
2682
+ /**
2683
+ * Runtime helper for resolving filters
2684
+ */
2685
+ function resolveFilter (id) {
2686
+ return resolveAsset(this.$options, 'filters', id, true) || identity
2757
2687
  }
2758
2688
 
2759
2689
  /* */
2760
2690
 
2761
- var activeInstance = null;
2762
- var isUpdatingChildComponent = false;
2763
-
2764
- function setActiveInstance(vm) {
2765
- var prevActiveInstance = activeInstance;
2766
- activeInstance = vm;
2767
- return function () {
2768
- activeInstance = prevActiveInstance;
2691
+ function isKeyNotMatch (expect, actual) {
2692
+ if (Array.isArray(expect)) {
2693
+ return expect.indexOf(actual) === -1
2694
+ } else {
2695
+ return expect !== actual
2769
2696
  }
2770
2697
  }
2771
2698
 
2772
- function initLifecycle (vm) {
2773
- var options = vm.$options;
2774
-
2775
- // locate first non-abstract parent
2776
- var parent = options.parent;
2777
- if (parent && !options.abstract) {
2778
- while (parent.$options.abstract && parent.$parent) {
2779
- parent = parent.$parent;
2780
- }
2781
- parent.$children.push(vm);
2699
+ /**
2700
+ * Runtime helper for checking keyCodes from config.
2701
+ * exposed as Vue.prototype._k
2702
+ * passing in eventKeyName as last argument separately for backwards compat
2703
+ */
2704
+ function checkKeyCodes (
2705
+ eventKeyCode,
2706
+ key,
2707
+ builtInKeyCode,
2708
+ eventKeyName,
2709
+ builtInKeyName
2710
+ ) {
2711
+ var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
2712
+ if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
2713
+ return isKeyNotMatch(builtInKeyName, eventKeyName)
2714
+ } else if (mappedKeyCode) {
2715
+ return isKeyNotMatch(mappedKeyCode, eventKeyCode)
2716
+ } else if (eventKeyName) {
2717
+ return hyphenate(eventKeyName) !== key
2782
2718
  }
2719
+ }
2783
2720
 
2784
- vm.$parent = parent;
2785
- vm.$root = parent ? parent.$root : vm;
2721
+ /* */
2786
2722
 
2787
- vm.$children = [];
2788
- vm.$refs = {};
2723
+ /**
2724
+ * Runtime helper for merging v-bind="object" into a VNode's data.
2725
+ */
2726
+ function bindObjectProps (
2727
+ data,
2728
+ tag,
2729
+ value,
2730
+ asProp,
2731
+ isSync
2732
+ ) {
2733
+ if (value) {
2734
+ if (!isObject(value)) {
2735
+ process.env.NODE_ENV !== 'production' && warn(
2736
+ 'v-bind without argument expects an Object or Array value',
2737
+ this
2738
+ );
2739
+ } else {
2740
+ if (Array.isArray(value)) {
2741
+ value = toObject(value);
2742
+ }
2743
+ var hash;
2744
+ var loop = function ( key ) {
2745
+ if (
2746
+ key === 'class' ||
2747
+ key === 'style' ||
2748
+ isReservedAttribute(key)
2749
+ ) {
2750
+ hash = data;
2751
+ } else {
2752
+ var type = data.attrs && data.attrs.type;
2753
+ hash = asProp || config.mustUseProp(tag, type, key)
2754
+ ? data.domProps || (data.domProps = {})
2755
+ : data.attrs || (data.attrs = {});
2756
+ }
2757
+ var camelizedKey = camelize(key);
2758
+ if (!(key in hash) && !(camelizedKey in hash)) {
2759
+ hash[key] = value[key];
2789
2760
 
2790
- vm._watcher = null;
2791
- vm._inactive = null;
2792
- vm._directInactive = false;
2793
- vm._isMounted = false;
2794
- vm._isDestroyed = false;
2795
- vm._isBeingDestroyed = false;
2796
- }
2761
+ if (isSync) {
2762
+ var on = data.on || (data.on = {});
2763
+ on[("update:" + camelizedKey)] = function ($event) {
2764
+ value[key] = $event;
2765
+ };
2766
+ }
2767
+ }
2768
+ };
2797
2769
 
2798
- function lifecycleMixin (Vue) {
2799
- Vue.prototype._update = function (vnode, hydrating) {
2800
- var vm = this;
2801
- var prevEl = vm.$el;
2802
- var prevVnode = vm._vnode;
2803
- var restoreActiveInstance = setActiveInstance(vm);
2804
- vm._vnode = vnode;
2805
- // Vue.prototype.__patch__ is injected in entry points
2806
- // based on the rendering backend used.
2807
- if (!prevVnode) {
2808
- // initial render
2809
- vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
2810
- } else {
2811
- // updates
2812
- vm.$el = vm.__patch__(prevVnode, vnode);
2813
- }
2814
- restoreActiveInstance();
2815
- // update __vue__ reference
2816
- if (prevEl) {
2817
- prevEl.__vue__ = null;
2818
- }
2819
- if (vm.$el) {
2820
- vm.$el.__vue__ = vm;
2821
- }
2822
- // if parent is an HOC, update its $el as well
2823
- if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
2824
- vm.$parent.$el = vm.$el;
2770
+ for (var key in value) loop( key );
2825
2771
  }
2826
- // updated hook is called by the scheduler to ensure that children are
2827
- // updated in a parent's updated hook.
2828
- };
2772
+ }
2773
+ return data
2774
+ }
2829
2775
 
2830
- Vue.prototype.$forceUpdate = function () {
2831
- var vm = this;
2832
- if (vm._watcher) {
2833
- vm._watcher.update();
2834
- }
2835
- };
2776
+ /* */
2836
2777
 
2837
- Vue.prototype.$destroy = function () {
2838
- var vm = this;
2839
- if (vm._isBeingDestroyed) {
2840
- return
2841
- }
2842
- callHook(vm, 'beforeDestroy');
2843
- vm._isBeingDestroyed = true;
2844
- // remove self from parent
2845
- var parent = vm.$parent;
2846
- if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
2847
- remove(parent.$children, vm);
2848
- }
2849
- // teardown watchers
2850
- if (vm._watcher) {
2851
- vm._watcher.teardown();
2852
- }
2853
- var i = vm._watchers.length;
2854
- while (i--) {
2855
- vm._watchers[i].teardown();
2856
- }
2857
- // remove reference from data ob
2858
- // frozen object may not have observer.
2859
- if (vm._data.__ob__) {
2860
- vm._data.__ob__.vmCount--;
2861
- }
2862
- // call the last hook...
2863
- vm._isDestroyed = true;
2864
- // invoke destroy hooks on current rendered tree
2865
- vm.__patch__(vm._vnode, null);
2866
- // fire destroyed hook
2867
- callHook(vm, 'destroyed');
2868
- // turn off all instance listeners.
2869
- vm.$off();
2870
- // remove __vue__ reference
2871
- if (vm.$el) {
2872
- vm.$el.__vue__ = null;
2873
- }
2874
- // release circular reference (#6759)
2875
- if (vm.$vnode) {
2876
- vm.$vnode.parent = null;
2877
- }
2878
- };
2778
+ /**
2779
+ * Runtime helper for rendering static trees.
2780
+ */
2781
+ function renderStatic (
2782
+ index,
2783
+ isInFor
2784
+ ) {
2785
+ var cached = this._staticTrees || (this._staticTrees = []);
2786
+ var tree = cached[index];
2787
+ // if has already-rendered static tree and not inside v-for,
2788
+ // we can reuse the same tree.
2789
+ if (tree && !isInFor) {
2790
+ return tree
2791
+ }
2792
+ // otherwise, render a fresh tree.
2793
+ tree = cached[index] = this.$options.staticRenderFns[index].call(
2794
+ this._renderProxy,
2795
+ null,
2796
+ this // for render fns generated for functional component templates
2797
+ );
2798
+ markStatic(tree, ("__static__" + index), false);
2799
+ return tree
2879
2800
  }
2880
2801
 
2881
- function mountComponent (
2882
- vm,
2883
- el,
2884
- hydrating
2802
+ /**
2803
+ * Runtime helper for v-once.
2804
+ * Effectively it means marking the node as static with a unique key.
2805
+ */
2806
+ function markOnce (
2807
+ tree,
2808
+ index,
2809
+ key
2885
2810
  ) {
2886
- vm.$el = el;
2887
- if (!vm.$options.render) {
2888
- vm.$options.render = createEmptyVNode;
2889
- if (process.env.NODE_ENV !== 'production') {
2890
- /* istanbul ignore if */
2891
- if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
2892
- vm.$options.el || el) {
2893
- warn(
2894
- 'You are using the runtime-only build of Vue where the template ' +
2895
- 'compiler is not available. Either pre-compile the templates into ' +
2896
- 'render functions, or use the compiler-included build.',
2897
- vm
2898
- );
2899
- } else {
2900
- warn(
2901
- 'Failed to mount component: template or render function not defined.',
2902
- vm
2903
- );
2811
+ markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
2812
+ return tree
2813
+ }
2814
+
2815
+ function markStatic (
2816
+ tree,
2817
+ key,
2818
+ isOnce
2819
+ ) {
2820
+ if (Array.isArray(tree)) {
2821
+ for (var i = 0; i < tree.length; i++) {
2822
+ if (tree[i] && typeof tree[i] !== 'string') {
2823
+ markStaticNode(tree[i], (key + "_" + i), isOnce);
2904
2824
  }
2905
2825
  }
2826
+ } else {
2827
+ markStaticNode(tree, key, isOnce);
2906
2828
  }
2907
- callHook(vm, 'beforeMount');
2829
+ }
2908
2830
 
2909
- var updateComponent;
2910
- /* istanbul ignore if */
2911
- if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
2912
- updateComponent = function () {
2913
- var name = vm._name;
2914
- var id = vm._uid;
2915
- var startTag = "vue-perf-start:" + id;
2916
- var endTag = "vue-perf-end:" + id;
2831
+ function markStaticNode (node, key, isOnce) {
2832
+ node.isStatic = true;
2833
+ node.key = key;
2834
+ node.isOnce = isOnce;
2835
+ }
2917
2836
 
2918
- mark(startTag);
2919
- var vnode = vm._render();
2920
- mark(endTag);
2921
- measure(("vue " + name + " render"), startTag, endTag);
2837
+ /* */
2922
2838
 
2923
- mark(startTag);
2924
- vm._update(vnode, hydrating);
2925
- mark(endTag);
2926
- measure(("vue " + name + " patch"), startTag, endTag);
2927
- };
2928
- } else {
2929
- updateComponent = function () {
2930
- vm._update(vm._render(), hydrating);
2931
- };
2839
+ function bindObjectListeners (data, value) {
2840
+ if (value) {
2841
+ if (!isPlainObject(value)) {
2842
+ process.env.NODE_ENV !== 'production' && warn(
2843
+ 'v-on without argument expects an Object value',
2844
+ this
2845
+ );
2846
+ } else {
2847
+ var on = data.on = data.on ? extend({}, data.on) : {};
2848
+ for (var key in value) {
2849
+ var existing = on[key];
2850
+ var ours = value[key];
2851
+ on[key] = existing ? [].concat(existing, ours) : ours;
2852
+ }
2853
+ }
2932
2854
  }
2855
+ return data
2856
+ }
2933
2857
 
2934
- // we set this to vm._watcher inside the watcher's constructor
2935
- // since the watcher's initial patch may call $forceUpdate (e.g. inside child
2936
- // component's mounted hook), which relies on vm._watcher being already defined
2937
- new Watcher(vm, updateComponent, noop, {
2938
- before: function before () {
2939
- if (vm._isMounted && !vm._isDestroyed) {
2940
- callHook(vm, 'beforeUpdate');
2858
+ /* */
2859
+
2860
+ function resolveScopedSlots (
2861
+ fns, // see flow/vnode
2862
+ hasDynamicKeys,
2863
+ res
2864
+ ) {
2865
+ res = res || { $stable: !hasDynamicKeys };
2866
+ for (var i = 0; i < fns.length; i++) {
2867
+ var slot = fns[i];
2868
+ if (Array.isArray(slot)) {
2869
+ resolveScopedSlots(slot, hasDynamicKeys, res);
2870
+ } else if (slot) {
2871
+ // marker for reverse proxying v-slot without scope on this.$slots
2872
+ if (slot.proxy) {
2873
+ slot.fn.proxy = true;
2941
2874
  }
2875
+ res[slot.key] = slot.fn;
2942
2876
  }
2943
- }, true /* isRenderWatcher */);
2944
- hydrating = false;
2877
+ }
2878
+ return res
2879
+ }
2945
2880
 
2946
- // manually mounted instance, call mounted on self
2947
- // mounted is called for render-created child components in its inserted hook
2948
- if (vm.$vnode == null) {
2949
- vm._isMounted = true;
2950
- callHook(vm, 'mounted');
2881
+ /* */
2882
+
2883
+ function bindDynamicKeys (baseObj, values) {
2884
+ for (var i = 0; i < values.length; i += 2) {
2885
+ var key = values[i];
2886
+ if (typeof key === 'string' && key) {
2887
+ baseObj[values[i]] = values[i + 1];
2888
+ } else if (process.env.NODE_ENV !== 'production' && key !== '' && key !== null) {
2889
+ // null is a speical value for explicitly removing a binding
2890
+ warn(
2891
+ ("Invalid value for dynamic directive argument (expected string or null): " + key),
2892
+ this
2893
+ );
2894
+ }
2951
2895
  }
2952
- return vm
2896
+ return baseObj
2953
2897
  }
2954
2898
 
2955
- function updateChildComponent (
2956
- vm,
2957
- propsData,
2958
- listeners,
2959
- parentVnode,
2960
- renderChildren
2899
+ // helper to dynamically append modifier runtime markers to event names.
2900
+ // ensure only append when value is already string, otherwise it will be cast
2901
+ // to string and cause the type check to miss.
2902
+ function prependModifier (value, symbol) {
2903
+ return typeof value === 'string' ? symbol + value : value
2904
+ }
2905
+
2906
+ /* */
2907
+
2908
+ function installRenderHelpers (target) {
2909
+ target._o = markOnce;
2910
+ target._n = toNumber;
2911
+ target._s = toString;
2912
+ target._l = renderList;
2913
+ target._t = renderSlot;
2914
+ target._q = looseEqual;
2915
+ target._i = looseIndexOf;
2916
+ target._m = renderStatic;
2917
+ target._f = resolveFilter;
2918
+ target._k = checkKeyCodes;
2919
+ target._b = bindObjectProps;
2920
+ target._v = createTextVNode;
2921
+ target._e = createEmptyVNode;
2922
+ target._u = resolveScopedSlots;
2923
+ target._g = bindObjectListeners;
2924
+ target._d = bindDynamicKeys;
2925
+ target._p = prependModifier;
2926
+ }
2927
+
2928
+ /* */
2929
+
2930
+ function FunctionalRenderContext (
2931
+ data,
2932
+ props,
2933
+ children,
2934
+ parent,
2935
+ Ctor
2961
2936
  ) {
2962
- if (process.env.NODE_ENV !== 'production') {
2963
- isUpdatingChildComponent = true;
2937
+ var this$1 = this;
2938
+
2939
+ var options = Ctor.options;
2940
+ // ensure the createElement function in functional components
2941
+ // gets a unique context - this is necessary for correct named slot check
2942
+ var contextVm;
2943
+ if (hasOwn(parent, '_uid')) {
2944
+ contextVm = Object.create(parent);
2945
+ // $flow-disable-line
2946
+ contextVm._original = parent;
2947
+ } else {
2948
+ // the context vm passed in is a functional context as well.
2949
+ // in this case we want to make sure we are able to get a hold to the
2950
+ // real context instance.
2951
+ contextVm = parent;
2952
+ // $flow-disable-line
2953
+ parent = parent._original;
2964
2954
  }
2955
+ var isCompiled = isTrue(options._compiled);
2956
+ var needNormalization = !isCompiled;
2965
2957
 
2966
- // determine whether component has slot children
2967
- // we need to do this before overwriting $options._renderChildren.
2958
+ this.data = data;
2959
+ this.props = props;
2960
+ this.children = children;
2961
+ this.parent = parent;
2962
+ this.listeners = data.on || emptyObject;
2963
+ this.injections = resolveInject(options.inject, parent);
2964
+ this.slots = function () {
2965
+ if (!this$1.$slots) {
2966
+ normalizeScopedSlots(
2967
+ data.scopedSlots,
2968
+ this$1.$slots = resolveSlots(children, parent)
2969
+ );
2970
+ }
2971
+ return this$1.$slots
2972
+ };
2968
2973
 
2969
- // check if there are dynamic scopedSlots (hand-written or compiled but with
2970
- // dynamic slot names). Static scoped slots compiled from template has the
2971
- // "$stable" marker.
2972
- var hasDynamicScopedSlot = !!(
2973
- (parentVnode.data.scopedSlots && !parentVnode.data.scopedSlots.$stable) ||
2974
- (vm.$scopedSlots !== emptyObject && !vm.$scopedSlots.$stable)
2975
- );
2976
- // Any static slot children from the parent may have changed during parent's
2977
- // update. Dynamic scoped slots may also have changed. In such cases, a forced
2978
- // update is necessary to ensure correctness.
2979
- var needsForceUpdate = !!(
2980
- renderChildren || // has new static slots
2981
- vm.$options._renderChildren || // has old static slots
2982
- hasDynamicScopedSlot
2983
- );
2974
+ Object.defineProperty(this, 'scopedSlots', ({
2975
+ enumerable: true,
2976
+ get: function get () {
2977
+ return normalizeScopedSlots(data.scopedSlots, this.slots())
2978
+ }
2979
+ }));
2984
2980
 
2985
- vm.$options._parentVnode = parentVnode;
2986
- vm.$vnode = parentVnode; // update vm's placeholder node without re-render
2981
+ // support for compiled functional template
2982
+ if (isCompiled) {
2983
+ // exposing $options for renderStatic()
2984
+ this.$options = options;
2985
+ // pre-resolve slots for renderSlot()
2986
+ this.$slots = this.slots();
2987
+ this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
2988
+ }
2987
2989
 
2988
- if (vm._vnode) { // update child tree's parent
2989
- vm._vnode.parent = parentVnode;
2990
+ if (options._scopeId) {
2991
+ this._c = function (a, b, c, d) {
2992
+ var vnode = createElement(contextVm, a, b, c, d, needNormalization);
2993
+ if (vnode && !Array.isArray(vnode)) {
2994
+ vnode.fnScopeId = options._scopeId;
2995
+ vnode.fnContext = parent;
2996
+ }
2997
+ return vnode
2998
+ };
2999
+ } else {
3000
+ this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
2990
3001
  }
2991
- vm.$options._renderChildren = renderChildren;
3002
+ }
2992
3003
 
2993
- // update $attrs and $listeners hash
2994
- // these are also reactive so they may trigger child update if the child
2995
- // used them during render
2996
- vm.$attrs = parentVnode.data.attrs || emptyObject;
2997
- vm.$listeners = listeners || emptyObject;
3004
+ installRenderHelpers(FunctionalRenderContext.prototype);
2998
3005
 
2999
- // update props
3000
- if (propsData && vm.$options.props) {
3001
- toggleObserving(false);
3002
- var props = vm._props;
3003
- var propKeys = vm.$options._propKeys || [];
3004
- for (var i = 0; i < propKeys.length; i++) {
3005
- var key = propKeys[i];
3006
- var propOptions = vm.$options.props; // wtf flow?
3007
- props[key] = validateProp(key, propOptions, propsData, vm);
3006
+ function createFunctionalComponent (
3007
+ Ctor,
3008
+ propsData,
3009
+ data,
3010
+ contextVm,
3011
+ children
3012
+ ) {
3013
+ var options = Ctor.options;
3014
+ var props = {};
3015
+ var propOptions = options.props;
3016
+ if (isDef(propOptions)) {
3017
+ for (var key in propOptions) {
3018
+ props[key] = validateProp(key, propOptions, propsData || emptyObject);
3008
3019
  }
3009
- toggleObserving(true);
3010
- // keep a copy of raw propsData
3011
- vm.$options.propsData = propsData;
3020
+ } else {
3021
+ if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
3022
+ if (isDef(data.props)) { mergeProps(props, data.props); }
3012
3023
  }
3013
3024
 
3014
- // update listeners
3015
- listeners = listeners || emptyObject;
3016
- var oldListeners = vm.$options._parentListeners;
3017
- vm.$options._parentListeners = listeners;
3018
- updateComponentListeners(vm, listeners, oldListeners);
3025
+ var renderContext = new FunctionalRenderContext(
3026
+ data,
3027
+ props,
3028
+ children,
3029
+ contextVm,
3030
+ Ctor
3031
+ );
3019
3032
 
3020
- // resolve slots + force update if has children
3021
- if (needsForceUpdate) {
3022
- vm.$slots = resolveSlots(renderChildren, parentVnode.context);
3023
- vm.$forceUpdate();
3033
+ var vnode = options.render.call(null, renderContext._c, renderContext);
3034
+
3035
+ if (vnode instanceof VNode) {
3036
+ return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
3037
+ } else if (Array.isArray(vnode)) {
3038
+ var vnodes = normalizeChildren(vnode) || [];
3039
+ var res = new Array(vnodes.length);
3040
+ for (var i = 0; i < vnodes.length; i++) {
3041
+ res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
3042
+ }
3043
+ return res
3024
3044
  }
3045
+ }
3025
3046
 
3047
+ function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
3048
+ // #7817 clone node before setting fnContext, otherwise if the node is reused
3049
+ // (e.g. it was from a cached normal slot) the fnContext causes named slots
3050
+ // that should not be matched to match.
3051
+ var clone = cloneVNode(vnode);
3052
+ clone.fnContext = contextVm;
3053
+ clone.fnOptions = options;
3026
3054
  if (process.env.NODE_ENV !== 'production') {
3027
- isUpdatingChildComponent = false;
3055
+ (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
3028
3056
  }
3057
+ if (data.slot) {
3058
+ (clone.data || (clone.data = {})).slot = data.slot;
3059
+ }
3060
+ return clone
3029
3061
  }
3030
3062
 
3031
- function isInInactiveTree (vm) {
3032
- while (vm && (vm = vm.$parent)) {
3033
- if (vm._inactive) { return true }
3063
+ function mergeProps (to, from) {
3064
+ for (var key in from) {
3065
+ to[camelize(key)] = from[key];
3034
3066
  }
3035
- return false
3036
3067
  }
3037
3068
 
3038
- function activateChildComponent (vm, direct) {
3039
- if (direct) {
3040
- vm._directInactive = false;
3041
- if (isInInactiveTree(vm)) {
3042
- return
3043
- }
3044
- } else if (vm._directInactive) {
3045
- return
3046
- }
3047
- if (vm._inactive || vm._inactive === null) {
3048
- vm._inactive = false;
3049
- for (var i = 0; i < vm.$children.length; i++) {
3050
- activateChildComponent(vm.$children[i]);
3069
+ /* */
3070
+
3071
+ /* */
3072
+
3073
+ /* */
3074
+
3075
+ /* */
3076
+
3077
+ // inline hooks to be invoked on component VNodes during patch
3078
+ var componentVNodeHooks = {
3079
+ init: function init (vnode, hydrating) {
3080
+ if (
3081
+ vnode.componentInstance &&
3082
+ !vnode.componentInstance._isDestroyed &&
3083
+ vnode.data.keepAlive
3084
+ ) {
3085
+ // kept-alive components, treat as a patch
3086
+ var mountedNode = vnode; // work around flow
3087
+ componentVNodeHooks.prepatch(mountedNode, mountedNode);
3088
+ } else {
3089
+ var child = vnode.componentInstance = createComponentInstanceForVnode(
3090
+ vnode,
3091
+ activeInstance
3092
+ );
3093
+ child.$mount(hydrating ? vnode.elm : undefined, hydrating);
3051
3094
  }
3052
- callHook(vm, 'activated');
3053
- }
3054
- }
3095
+ },
3055
3096
 
3056
- function deactivateChildComponent (vm, direct) {
3057
- if (direct) {
3058
- vm._directInactive = true;
3059
- if (isInInactiveTree(vm)) {
3060
- return
3097
+ prepatch: function prepatch (oldVnode, vnode) {
3098
+ var options = vnode.componentOptions;
3099
+ var child = vnode.componentInstance = oldVnode.componentInstance;
3100
+ updateChildComponent(
3101
+ child,
3102
+ options.propsData, // updated props
3103
+ options.listeners, // updated listeners
3104
+ vnode, // new parent vnode
3105
+ options.children // new children
3106
+ );
3107
+ },
3108
+
3109
+ insert: function insert (vnode) {
3110
+ var context = vnode.context;
3111
+ var componentInstance = vnode.componentInstance;
3112
+ if (!componentInstance._isMounted) {
3113
+ componentInstance._isMounted = true;
3114
+ callHook(componentInstance, 'mounted');
3061
3115
  }
3062
- }
3063
- if (!vm._inactive) {
3064
- vm._inactive = true;
3065
- for (var i = 0; i < vm.$children.length; i++) {
3066
- deactivateChildComponent(vm.$children[i]);
3116
+ if (vnode.data.keepAlive) {
3117
+ if (context._isMounted) {
3118
+ // vue-router#1212
3119
+ // During updates, a kept-alive component's child components may
3120
+ // change, so directly walking the tree here may call activated hooks
3121
+ // on incorrect children. Instead we push them into a queue which will
3122
+ // be processed after the whole patch process ended.
3123
+ queueActivatedComponent(componentInstance);
3124
+ } else {
3125
+ activateChildComponent(componentInstance, true /* direct */);
3126
+ }
3067
3127
  }
3068
- callHook(vm, 'deactivated');
3069
- }
3070
- }
3128
+ },
3071
3129
 
3072
- function callHook (vm, hook) {
3073
- // #7573 disable dep collection when invoking lifecycle hooks
3074
- pushTarget();
3075
- var handlers = vm.$options[hook];
3076
- var info = hook + " hook";
3077
- if (handlers) {
3078
- for (var i = 0, j = handlers.length; i < j; i++) {
3079
- invokeWithErrorHandling(handlers[i], vm, null, vm, info);
3130
+ destroy: function destroy (vnode) {
3131
+ var componentInstance = vnode.componentInstance;
3132
+ if (!componentInstance._isDestroyed) {
3133
+ if (!vnode.data.keepAlive) {
3134
+ componentInstance.$destroy();
3135
+ } else {
3136
+ deactivateChildComponent(componentInstance, true /* direct */);
3137
+ }
3080
3138
  }
3081
3139
  }
3082
- if (vm._hasHookEvent) {
3083
- vm.$emit('hook:' + hook);
3084
- }
3085
- popTarget();
3086
- }
3140
+ };
3087
3141
 
3088
- /* */
3142
+ var hooksToMerge = Object.keys(componentVNodeHooks);
3089
3143
 
3090
- var MAX_UPDATE_COUNT = 100;
3144
+ function createComponent (
3145
+ Ctor,
3146
+ data,
3147
+ context,
3148
+ children,
3149
+ tag
3150
+ ) {
3151
+ if (isUndef(Ctor)) {
3152
+ return
3153
+ }
3091
3154
 
3092
- var queue = [];
3093
- var activatedChildren = [];
3094
- var has = {};
3095
- var circular = {};
3096
- var waiting = false;
3097
- var flushing = false;
3098
- var index = 0;
3155
+ var baseCtor = context.$options._base;
3099
3156
 
3100
- /**
3101
- * Reset the scheduler's state.
3102
- */
3103
- function resetSchedulerState () {
3104
- index = queue.length = activatedChildren.length = 0;
3105
- has = {};
3106
- if (process.env.NODE_ENV !== 'production') {
3107
- circular = {};
3157
+ // plain options object: turn it into a constructor
3158
+ if (isObject(Ctor)) {
3159
+ Ctor = baseCtor.extend(Ctor);
3108
3160
  }
3109
- waiting = flushing = false;
3110
- }
3111
3161
 
3112
- // Async edge case #6566 requires saving the timestamp when event listeners are
3113
- // attached. However, calling performance.now() has a perf overhead especially
3114
- // if the page has thousands of event listeners. Instead, we take a timestamp
3115
- // every time the scheduler flushes and use that for all event listeners
3116
- // attached during that flush.
3117
- var currentFlushTimestamp = 0;
3162
+ // if at this stage it's not a constructor or an async component factory,
3163
+ // reject.
3164
+ if (typeof Ctor !== 'function') {
3165
+ if (process.env.NODE_ENV !== 'production') {
3166
+ warn(("Invalid Component definition: " + (String(Ctor))), context);
3167
+ }
3168
+ return
3169
+ }
3118
3170
 
3119
- // Async edge case fix requires storing an event listener's attach timestamp.
3120
- var getNow = Date.now;
3171
+ // async component
3172
+ var asyncFactory;
3173
+ if (isUndef(Ctor.cid)) {
3174
+ asyncFactory = Ctor;
3175
+ Ctor = resolveAsyncComponent(asyncFactory, baseCtor);
3176
+ if (Ctor === undefined) {
3177
+ // return a placeholder node for async component, which is rendered
3178
+ // as a comment node but preserves all the raw information for the node.
3179
+ // the information will be used for async server-rendering and hydration.
3180
+ return createAsyncPlaceholder(
3181
+ asyncFactory,
3182
+ data,
3183
+ context,
3184
+ children,
3185
+ tag
3186
+ )
3187
+ }
3188
+ }
3121
3189
 
3122
- // Determine what event timestamp the browser is using. Annoyingly, the
3123
- // timestamp can either be hi-res ( relative to poge load) or low-res
3124
- // (relative to UNIX epoch), so in order to compare time we have to use the
3125
- // same timestamp type when saving the flush timestamp.
3126
- if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {
3127
- // if the low-res timestamp which is bigger than the event timestamp
3128
- // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
3129
- // and we need to use the hi-res version for event listeners as well.
3130
- getNow = function () { return performance.now(); };
3131
- }
3190
+ data = data || {};
3132
3191
 
3133
- /**
3134
- * Flush both queues and run the watchers.
3135
- */
3136
- function flushSchedulerQueue () {
3137
- currentFlushTimestamp = getNow();
3138
- flushing = true;
3139
- var watcher, id;
3192
+ // resolve constructor options in case global mixins are applied after
3193
+ // component constructor creation
3194
+ resolveConstructorOptions(Ctor);
3140
3195
 
3141
- // Sort queue before flush.
3142
- // This ensures that:
3143
- // 1. Components are updated from parent to child. (because parent is always
3144
- // created before the child)
3145
- // 2. A component's user watchers are run before its render watcher (because
3146
- // user watchers are created before the render watcher)
3147
- // 3. If a component is destroyed during a parent component's watcher run,
3148
- // its watchers can be skipped.
3149
- queue.sort(function (a, b) { return a.id - b.id; });
3196
+ // transform component v-model data into props & events
3197
+ if (isDef(data.model)) {
3198
+ transformModel(Ctor.options, data);
3199
+ }
3150
3200
 
3151
- // do not cache length because more watchers might be pushed
3152
- // as we run existing watchers
3153
- for (index = 0; index < queue.length; index++) {
3154
- watcher = queue[index];
3155
- if (watcher.before) {
3156
- watcher.before();
3157
- }
3158
- id = watcher.id;
3159
- has[id] = null;
3160
- watcher.run();
3161
- // in dev build, check and stop circular updates.
3162
- if (process.env.NODE_ENV !== 'production' && has[id] != null) {
3163
- circular[id] = (circular[id] || 0) + 1;
3164
- if (circular[id] > MAX_UPDATE_COUNT) {
3165
- warn(
3166
- 'You may have an infinite update loop ' + (
3167
- watcher.user
3168
- ? ("in watcher with expression \"" + (watcher.expression) + "\"")
3169
- : "in a component render function."
3170
- ),
3171
- watcher.vm
3172
- );
3173
- break
3174
- }
3201
+ // extract props
3202
+ var propsData = extractPropsFromVNodeData(data, Ctor, tag);
3203
+
3204
+ // functional component
3205
+ if (isTrue(Ctor.options.functional)) {
3206
+ return createFunctionalComponent(Ctor, propsData, data, context, children)
3207
+ }
3208
+
3209
+ // extract listeners, since these needs to be treated as
3210
+ // child component listeners instead of DOM listeners
3211
+ var listeners = data.on;
3212
+ // replace with listeners with .native modifier
3213
+ // so it gets processed during parent component patch.
3214
+ data.on = data.nativeOn;
3215
+
3216
+ if (isTrue(Ctor.options.abstract)) {
3217
+ // abstract components do not keep anything
3218
+ // other than props & listeners & slot
3219
+
3220
+ // work around flow
3221
+ var slot = data.slot;
3222
+ data = {};
3223
+ if (slot) {
3224
+ data.slot = slot;
3175
3225
  }
3176
3226
  }
3177
3227
 
3178
- // keep copies of post queues before resetting state
3179
- var activatedQueue = activatedChildren.slice();
3180
- var updatedQueue = queue.slice();
3228
+ // install component management hooks onto the placeholder node
3229
+ installComponentHooks(data);
3181
3230
 
3182
- resetSchedulerState();
3231
+ // return a placeholder vnode
3232
+ var name = Ctor.options.name || tag;
3233
+ var vnode = new VNode(
3234
+ ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
3235
+ data, undefined, undefined, undefined, context,
3236
+ { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
3237
+ asyncFactory
3238
+ );
3183
3239
 
3184
- // call component updated and activated hooks
3185
- callActivatedHooks(activatedQueue);
3186
- callUpdatedHooks(updatedQueue);
3240
+ return vnode
3241
+ }
3187
3242
 
3188
- // devtool hook
3189
- /* istanbul ignore if */
3190
- if (devtools && config.devtools) {
3191
- devtools.emit('flush');
3243
+ function createComponentInstanceForVnode (
3244
+ vnode, // we know it's MountedComponentVNode but flow doesn't
3245
+ parent // activeInstance in lifecycle state
3246
+ ) {
3247
+ var options = {
3248
+ _isComponent: true,
3249
+ _parentVnode: vnode,
3250
+ parent: parent
3251
+ };
3252
+ // check inline-template render functions
3253
+ var inlineTemplate = vnode.data.inlineTemplate;
3254
+ if (isDef(inlineTemplate)) {
3255
+ options.render = inlineTemplate.render;
3256
+ options.staticRenderFns = inlineTemplate.staticRenderFns;
3192
3257
  }
3258
+ return new vnode.componentOptions.Ctor(options)
3193
3259
  }
3194
3260
 
3195
- function callUpdatedHooks (queue) {
3196
- var i = queue.length;
3197
- while (i--) {
3198
- var watcher = queue[i];
3199
- var vm = watcher.vm;
3200
- if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
3201
- callHook(vm, 'updated');
3261
+ function installComponentHooks (data) {
3262
+ var hooks = data.hook || (data.hook = {});
3263
+ for (var i = 0; i < hooksToMerge.length; i++) {
3264
+ var key = hooksToMerge[i];
3265
+ var existing = hooks[key];
3266
+ var toMerge = componentVNodeHooks[key];
3267
+ if (existing !== toMerge && !(existing && existing._merged)) {
3268
+ hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
3202
3269
  }
3203
3270
  }
3204
3271
  }
3205
3272
 
3206
- /**
3207
- * Queue a kept-alive component that was activated during patch.
3208
- * The queue will be processed after the entire tree has been patched.
3209
- */
3210
- function queueActivatedComponent (vm) {
3211
- // setting _inactive to false here so that a render function can
3212
- // rely on checking whether it's in an inactive tree (e.g. router-view)
3213
- vm._inactive = false;
3214
- activatedChildren.push(vm);
3215
- }
3216
-
3217
- function callActivatedHooks (queue) {
3218
- for (var i = 0; i < queue.length; i++) {
3219
- queue[i]._inactive = true;
3220
- activateChildComponent(queue[i], true /* true */);
3221
- }
3273
+ function mergeHook$1 (f1, f2) {
3274
+ var merged = function (a, b) {
3275
+ // flow complains about extra args which is why we use any
3276
+ f1(a, b);
3277
+ f2(a, b);
3278
+ };
3279
+ merged._merged = true;
3280
+ return merged
3222
3281
  }
3223
3282
 
3224
- /**
3225
- * Push a watcher into the watcher queue.
3226
- * Jobs with duplicate IDs will be skipped unless it's
3227
- * pushed when the queue is being flushed.
3228
- */
3229
- function queueWatcher (watcher) {
3230
- var id = watcher.id;
3231
- if (has[id] == null) {
3232
- has[id] = true;
3233
- if (!flushing) {
3234
- queue.push(watcher);
3235
- } else {
3236
- // if already flushing, splice the watcher based on its id
3237
- // if already past its id, it will be run next immediately.
3238
- var i = queue.length - 1;
3239
- while (i > index && queue[i].id > watcher.id) {
3240
- i--;
3241
- }
3242
- queue.splice(i + 1, 0, watcher);
3243
- }
3244
- // queue the flush
3245
- if (!waiting) {
3246
- waiting = true;
3247
-
3248
- if (process.env.NODE_ENV !== 'production' && !config.async) {
3249
- flushSchedulerQueue();
3250
- return
3251
- }
3252
- nextTick(flushSchedulerQueue);
3283
+ // transform component v-model info (value and callback) into
3284
+ // prop and event handler respectively.
3285
+ function transformModel (options, data) {
3286
+ var prop = (options.model && options.model.prop) || 'value';
3287
+ var event = (options.model && options.model.event) || 'input'
3288
+ ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
3289
+ var on = data.on || (data.on = {});
3290
+ var existing = on[event];
3291
+ var callback = data.model.callback;
3292
+ if (isDef(existing)) {
3293
+ if (
3294
+ Array.isArray(existing)
3295
+ ? existing.indexOf(callback) === -1
3296
+ : existing !== callback
3297
+ ) {
3298
+ on[event] = [callback].concat(existing);
3253
3299
  }
3300
+ } else {
3301
+ on[event] = callback;
3254
3302
  }
3255
3303
  }
3256
3304
 
3257
3305
  /* */
3258
3306
 
3307
+ var SIMPLE_NORMALIZE = 1;
3308
+ var ALWAYS_NORMALIZE = 2;
3259
3309
 
3310
+ // wrapper function for providing a more flexible interface
3311
+ // without getting yelled at by flow
3312
+ function createElement (
3313
+ context,
3314
+ tag,
3315
+ data,
3316
+ children,
3317
+ normalizationType,
3318
+ alwaysNormalize
3319
+ ) {
3320
+ if (Array.isArray(data) || isPrimitive(data)) {
3321
+ normalizationType = children;
3322
+ children = data;
3323
+ data = undefined;
3324
+ }
3325
+ if (isTrue(alwaysNormalize)) {
3326
+ normalizationType = ALWAYS_NORMALIZE;
3327
+ }
3328
+ return _createElement(context, tag, data, children, normalizationType)
3329
+ }
3260
3330
 
3261
- var uid$1 = 0;
3262
-
3263
- /**
3264
- * A watcher parses an expression, collects dependencies,
3265
- * and fires callback when the expression value changes.
3266
- * This is used for both the $watch() api and directives.
3267
- */
3268
- var Watcher = function Watcher (
3269
- vm,
3270
- expOrFn,
3271
- cb,
3272
- options,
3273
- isRenderWatcher
3331
+ function _createElement (
3332
+ context,
3333
+ tag,
3334
+ data,
3335
+ children,
3336
+ normalizationType
3274
3337
  ) {
3275
- this.vm = vm;
3276
- if (isRenderWatcher) {
3277
- vm._watcher = this;
3338
+ if (isDef(data) && isDef((data).__ob__)) {
3339
+ process.env.NODE_ENV !== 'production' && warn(
3340
+ "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
3341
+ 'Always create fresh vnode data objects in each render!',
3342
+ context
3343
+ );
3344
+ return createEmptyVNode()
3278
3345
  }
3279
- vm._watchers.push(this);
3280
- // options
3281
- if (options) {
3282
- this.deep = !!options.deep;
3283
- this.user = !!options.user;
3284
- this.lazy = !!options.lazy;
3285
- this.sync = !!options.sync;
3286
- this.before = options.before;
3346
+ // object syntax in v-bind
3347
+ if (isDef(data) && isDef(data.is)) {
3348
+ tag = data.is;
3349
+ }
3350
+ if (!tag) {
3351
+ // in case of component :is set to falsy value
3352
+ return createEmptyVNode()
3353
+ }
3354
+ // warn against non-primitive key
3355
+ if (process.env.NODE_ENV !== 'production' &&
3356
+ isDef(data) && isDef(data.key) && !isPrimitive(data.key)
3357
+ ) {
3358
+ {
3359
+ warn(
3360
+ 'Avoid using non-primitive value as key, ' +
3361
+ 'use string/number value instead.',
3362
+ context
3363
+ );
3364
+ }
3365
+ }
3366
+ // support single function children as default scoped slot
3367
+ if (Array.isArray(children) &&
3368
+ typeof children[0] === 'function'
3369
+ ) {
3370
+ data = data || {};
3371
+ data.scopedSlots = { default: children[0] };
3372
+ children.length = 0;
3373
+ }
3374
+ if (normalizationType === ALWAYS_NORMALIZE) {
3375
+ children = normalizeChildren(children);
3376
+ } else if (normalizationType === SIMPLE_NORMALIZE) {
3377
+ children = simpleNormalizeChildren(children);
3378
+ }
3379
+ var vnode, ns;
3380
+ if (typeof tag === 'string') {
3381
+ var Ctor;
3382
+ ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
3383
+ if (config.isReservedTag(tag)) {
3384
+ // platform built-in elements
3385
+ vnode = new VNode(
3386
+ config.parsePlatformTagName(tag), data, children,
3387
+ undefined, undefined, context
3388
+ );
3389
+ } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
3390
+ // component
3391
+ vnode = createComponent(Ctor, data, context, children, tag);
3392
+ } else {
3393
+ // unknown or unlisted namespaced elements
3394
+ // check at runtime because it may get assigned a namespace when its
3395
+ // parent normalizes children
3396
+ vnode = new VNode(
3397
+ tag, data, children,
3398
+ undefined, undefined, context
3399
+ );
3400
+ }
3287
3401
  } else {
3288
- this.deep = this.user = this.lazy = this.sync = false;
3402
+ // direct component options / constructor
3403
+ vnode = createComponent(tag, data, context, children);
3289
3404
  }
3290
- this.cb = cb;
3291
- this.id = ++uid$1; // uid for batching
3292
- this.active = true;
3293
- this.dirty = this.lazy; // for lazy watchers
3294
- this.deps = [];
3295
- this.newDeps = [];
3296
- this.depIds = new _Set();
3297
- this.newDepIds = new _Set();
3298
- this.expression = process.env.NODE_ENV !== 'production'
3299
- ? expOrFn.toString()
3300
- : '';
3301
- // parse expression for getter
3302
- if (typeof expOrFn === 'function') {
3303
- this.getter = expOrFn;
3405
+ if (Array.isArray(vnode)) {
3406
+ return vnode
3407
+ } else if (isDef(vnode)) {
3408
+ if (isDef(ns)) { applyNS(vnode, ns); }
3409
+ if (isDef(data)) { registerDeepBindings(data); }
3410
+ return vnode
3304
3411
  } else {
3305
- this.getter = parsePath(expOrFn);
3306
- if (!this.getter) {
3307
- this.getter = noop;
3308
- process.env.NODE_ENV !== 'production' && warn(
3309
- "Failed watching path: \"" + expOrFn + "\" " +
3310
- 'Watcher only accepts simple dot-delimited paths. ' +
3311
- 'For full control, use a function instead.',
3312
- vm
3313
- );
3314
- }
3412
+ return createEmptyVNode()
3315
3413
  }
3316
- this.value = this.lazy
3317
- ? undefined
3318
- : this.get();
3319
- };
3414
+ }
3320
3415
 
3321
- /**
3322
- * Evaluate the getter, and re-collect dependencies.
3323
- */
3324
- Watcher.prototype.get = function get () {
3325
- pushTarget(this);
3326
- var value;
3327
- var vm = this.vm;
3328
- try {
3329
- value = this.getter.call(vm, vm);
3330
- } catch (e) {
3331
- if (this.user) {
3332
- handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
3333
- } else {
3334
- throw e
3335
- }
3336
- } finally {
3337
- // "touch" every property so they are all tracked as
3338
- // dependencies for deep watching
3339
- if (this.deep) {
3340
- traverse(value);
3341
- }
3342
- popTarget();
3343
- this.cleanupDeps();
3416
+ function applyNS (vnode, ns, force) {
3417
+ vnode.ns = ns;
3418
+ if (vnode.tag === 'foreignObject') {
3419
+ // use default namespace inside foreignObject
3420
+ ns = undefined;
3421
+ force = true;
3344
3422
  }
3345
- return value
3346
- };
3347
-
3348
- /**
3349
- * Add a dependency to this directive.
3350
- */
3351
- Watcher.prototype.addDep = function addDep (dep) {
3352
- var id = dep.id;
3353
- if (!this.newDepIds.has(id)) {
3354
- this.newDepIds.add(id);
3355
- this.newDeps.push(dep);
3356
- if (!this.depIds.has(id)) {
3357
- dep.addSub(this);
3423
+ if (isDef(vnode.children)) {
3424
+ for (var i = 0, l = vnode.children.length; i < l; i++) {
3425
+ var child = vnode.children[i];
3426
+ if (isDef(child.tag) && (
3427
+ isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
3428
+ applyNS(child, ns, force);
3429
+ }
3358
3430
  }
3359
3431
  }
3360
- };
3432
+ }
3361
3433
 
3362
- /**
3363
- * Clean up for dependency collection.
3364
- */
3365
- Watcher.prototype.cleanupDeps = function cleanupDeps () {
3366
- var i = this.deps.length;
3367
- while (i--) {
3368
- var dep = this.deps[i];
3369
- if (!this.newDepIds.has(dep.id)) {
3370
- dep.removeSub(this);
3371
- }
3434
+ // ref #5318
3435
+ // necessary to ensure parent re-render when deep bindings like :style and
3436
+ // :class are used on slot nodes
3437
+ function registerDeepBindings (data) {
3438
+ if (isObject(data.style)) {
3439
+ traverse(data.style);
3372
3440
  }
3373
- var tmp = this.depIds;
3374
- this.depIds = this.newDepIds;
3375
- this.newDepIds = tmp;
3376
- this.newDepIds.clear();
3377
- tmp = this.deps;
3378
- this.deps = this.newDeps;
3379
- this.newDeps = tmp;
3380
- this.newDeps.length = 0;
3381
- };
3441
+ if (isObject(data.class)) {
3442
+ traverse(data.class);
3443
+ }
3444
+ }
3445
+
3446
+ /* */
3447
+
3448
+ function initRender (vm) {
3449
+ vm._vnode = null; // the root of the child tree
3450
+ vm._staticTrees = null; // v-once cached trees
3451
+ var options = vm.$options;
3452
+ var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
3453
+ var renderContext = parentVnode && parentVnode.context;
3454
+ vm.$slots = resolveSlots(options._renderChildren, renderContext);
3455
+ vm.$scopedSlots = emptyObject;
3456
+ // bind the createElement fn to this instance
3457
+ // so that we get proper render context inside it.
3458
+ // args order: tag, data, children, normalizationType, alwaysNormalize
3459
+ // internal version is used by render functions compiled from templates
3460
+ vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
3461
+ // normalization is always applied for the public version, used in
3462
+ // user-written render functions.
3463
+ vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
3464
+
3465
+ // $attrs & $listeners are exposed for easier HOC creation.
3466
+ // they need to be reactive so that HOCs using them are always updated
3467
+ var parentData = parentVnode && parentVnode.data;
3382
3468
 
3383
- /**
3384
- * Subscriber interface.
3385
- * Will be called when a dependency changes.
3386
- */
3387
- Watcher.prototype.update = function update () {
3388
3469
  /* istanbul ignore else */
3389
- if (this.lazy) {
3390
- this.dirty = true;
3391
- } else if (this.sync) {
3392
- this.run();
3470
+ if (process.env.NODE_ENV !== 'production') {
3471
+ defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
3472
+ !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
3473
+ }, true);
3474
+ defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
3475
+ !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
3476
+ }, true);
3393
3477
  } else {
3394
- queueWatcher(this);
3478
+ defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
3479
+ defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, null, true);
3395
3480
  }
3396
- };
3481
+ }
3397
3482
 
3398
- /**
3399
- * Scheduler job interface.
3400
- * Will be called by the scheduler.
3401
- */
3402
- Watcher.prototype.run = function run () {
3403
- if (this.active) {
3404
- var value = this.get();
3405
- if (
3406
- value !== this.value ||
3407
- // Deep watchers and watchers on Object/Arrays should fire even
3408
- // when the value is the same, because the value may
3409
- // have mutated.
3410
- isObject(value) ||
3411
- this.deep
3412
- ) {
3413
- // set new value
3414
- var oldValue = this.value;
3415
- this.value = value;
3416
- if (this.user) {
3417
- try {
3418
- this.cb.call(this.vm, value, oldValue);
3419
- } catch (e) {
3420
- handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
3421
- }
3422
- } else {
3423
- this.cb.call(this.vm, value, oldValue);
3424
- }
3425
- }
3426
- }
3427
- };
3483
+ var currentRenderingInstance = null;
3428
3484
 
3429
- /**
3430
- * Evaluate the value of the watcher.
3431
- * This only gets called for lazy watchers.
3432
- */
3433
- Watcher.prototype.evaluate = function evaluate () {
3434
- this.value = this.get();
3435
- this.dirty = false;
3436
- };
3485
+ function renderMixin (Vue) {
3486
+ // install runtime convenience helpers
3487
+ installRenderHelpers(Vue.prototype);
3437
3488
 
3438
- /**
3439
- * Depend on all deps collected by this watcher.
3440
- */
3441
- Watcher.prototype.depend = function depend () {
3442
- var i = this.deps.length;
3443
- while (i--) {
3444
- this.deps[i].depend();
3445
- }
3446
- };
3489
+ Vue.prototype.$nextTick = function (fn) {
3490
+ return nextTick(fn, this)
3491
+ };
3447
3492
 
3448
- /**
3449
- * Remove self from all dependencies' subscriber list.
3450
- */
3451
- Watcher.prototype.teardown = function teardown () {
3452
- if (this.active) {
3453
- // remove self from vm's watcher list
3454
- // this is a somewhat expensive operation so we skip it
3455
- // if the vm is being destroyed.
3456
- if (!this.vm._isBeingDestroyed) {
3457
- remove(this.vm._watchers, this);
3493
+ Vue.prototype._render = function () {
3494
+ var vm = this;
3495
+ var ref = vm.$options;
3496
+ var render = ref.render;
3497
+ var _parentVnode = ref._parentVnode;
3498
+
3499
+ if (_parentVnode) {
3500
+ vm.$scopedSlots = normalizeScopedSlots(
3501
+ _parentVnode.data.scopedSlots,
3502
+ vm.$slots,
3503
+ vm.$scopedSlots
3504
+ );
3505
+ }
3506
+
3507
+ // set parent vnode. this allows render functions to have access
3508
+ // to the data on the placeholder node.
3509
+ vm.$vnode = _parentVnode;
3510
+ // render self
3511
+ var vnode;
3512
+ try {
3513
+ // There's no need to maintain a stack becaues all render fns are called
3514
+ // separately from one another. Nested component's render fns are called
3515
+ // when parent component is patched.
3516
+ currentRenderingInstance = vm;
3517
+ vnode = render.call(vm._renderProxy, vm.$createElement);
3518
+ } catch (e) {
3519
+ handleError(e, vm, "render");
3520
+ // return error render result,
3521
+ // or previous vnode to prevent render error causing blank component
3522
+ /* istanbul ignore else */
3523
+ if (process.env.NODE_ENV !== 'production' && vm.$options.renderError) {
3524
+ try {
3525
+ vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
3526
+ } catch (e) {
3527
+ handleError(e, vm, "renderError");
3528
+ vnode = vm._vnode;
3529
+ }
3530
+ } else {
3531
+ vnode = vm._vnode;
3532
+ }
3533
+ } finally {
3534
+ currentRenderingInstance = null;
3458
3535
  }
3459
- var i = this.deps.length;
3460
- while (i--) {
3461
- this.deps[i].removeSub(this);
3536
+ // if the returned array contains only a single node, allow it
3537
+ if (Array.isArray(vnode) && vnode.length === 1) {
3538
+ vnode = vnode[0];
3462
3539
  }
3463
- this.active = false;
3464
- }
3465
- };
3540
+ // return empty vnode in case the render function errored out
3541
+ if (!(vnode instanceof VNode)) {
3542
+ if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
3543
+ warn(
3544
+ 'Multiple root nodes returned from render function. Render function ' +
3545
+ 'should return a single root node.',
3546
+ vm
3547
+ );
3548
+ }
3549
+ vnode = createEmptyVNode();
3550
+ }
3551
+ // set parent
3552
+ vnode.parent = _parentVnode;
3553
+ return vnode
3554
+ };
3555
+ }
3466
3556
 
3467
3557
  /* */
3468
3558
 
3469
- var sharedPropertyDefinition = {
3470
- enumerable: true,
3471
- configurable: true,
3472
- get: noop,
3473
- set: noop
3474
- };
3559
+ function ensureCtor (comp, base) {
3560
+ if (
3561
+ comp.__esModule ||
3562
+ (hasSymbol && comp[Symbol.toStringTag] === 'Module')
3563
+ ) {
3564
+ comp = comp.default;
3565
+ }
3566
+ return isObject(comp)
3567
+ ? base.extend(comp)
3568
+ : comp
3569
+ }
3475
3570
 
3476
- function proxy (target, sourceKey, key) {
3477
- sharedPropertyDefinition.get = function proxyGetter () {
3478
- return this[sourceKey][key]
3479
- };
3480
- sharedPropertyDefinition.set = function proxySetter (val) {
3481
- this[sourceKey][key] = val;
3482
- };
3483
- Object.defineProperty(target, key, sharedPropertyDefinition);
3571
+ function createAsyncPlaceholder (
3572
+ factory,
3573
+ data,
3574
+ context,
3575
+ children,
3576
+ tag
3577
+ ) {
3578
+ var node = createEmptyVNode();
3579
+ node.asyncFactory = factory;
3580
+ node.asyncMeta = { data: data, context: context, children: children, tag: tag };
3581
+ return node
3484
3582
  }
3485
3583
 
3486
- function initState (vm) {
3487
- vm._watchers = [];
3488
- var opts = vm.$options;
3489
- if (opts.props) { initProps(vm, opts.props); }
3490
- if (opts.methods) { initMethods(vm, opts.methods); }
3491
- if (opts.data) {
3492
- initData(vm);
3493
- } else {
3494
- observe(vm._data = {}, true /* asRootData */);
3584
+ function resolveAsyncComponent (
3585
+ factory,
3586
+ baseCtor
3587
+ ) {
3588
+ if (isTrue(factory.error) && isDef(factory.errorComp)) {
3589
+ return factory.errorComp
3495
3590
  }
3496
- if (opts.computed) { initComputed(vm, opts.computed); }
3497
- if (opts.watch && opts.watch !== nativeWatch) {
3498
- initWatch(vm, opts.watch);
3591
+
3592
+ if (isDef(factory.resolved)) {
3593
+ return factory.resolved
3499
3594
  }
3500
- }
3501
3595
 
3502
- function initProps (vm, propsOptions) {
3503
- var propsData = vm.$options.propsData || {};
3504
- var props = vm._props = {};
3505
- // cache prop keys so that future props updates can iterate using Array
3506
- // instead of dynamic object key enumeration.
3507
- var keys = vm.$options._propKeys = [];
3508
- var isRoot = !vm.$parent;
3509
- // root instance props should be converted
3510
- if (!isRoot) {
3511
- toggleObserving(false);
3596
+ if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
3597
+ return factory.loadingComp
3512
3598
  }
3513
- var loop = function ( key ) {
3514
- keys.push(key);
3515
- var value = validateProp(key, propsOptions, propsData, vm);
3516
- /* istanbul ignore else */
3517
- if (process.env.NODE_ENV !== 'production') {
3518
- var hyphenatedKey = hyphenate(key);
3519
- if (isReservedAttribute(hyphenatedKey) ||
3520
- config.isReservedAttr(hyphenatedKey)) {
3521
- warn(
3522
- ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
3523
- vm
3524
- );
3599
+
3600
+ var owner = currentRenderingInstance;
3601
+ if (isDef(factory.owners)) {
3602
+ // already pending
3603
+ factory.owners.push(owner);
3604
+ } else {
3605
+ var owners = factory.owners = [owner];
3606
+ var sync = true;
3607
+
3608
+ var forceRender = function (renderCompleted) {
3609
+ for (var i = 0, l = owners.length; i < l; i++) {
3610
+ (owners[i]).$forceUpdate();
3525
3611
  }
3526
- defineReactive$$1(props, key, value, function () {
3527
- if (!isRoot && !isUpdatingChildComponent) {
3528
- warn(
3529
- "Avoid mutating a prop directly since the value will be " +
3530
- "overwritten whenever the parent component re-renders. " +
3531
- "Instead, use a data or computed property based on the prop's " +
3532
- "value. Prop being mutated: \"" + key + "\"",
3533
- vm
3534
- );
3535
- }
3536
- });
3537
- } else {
3538
- defineReactive$$1(props, key, value);
3539
- }
3540
- // static props are already proxied on the component's prototype
3541
- // during Vue.extend(). We only need to proxy props defined at
3542
- // instantiation here.
3543
- if (!(key in vm)) {
3544
- proxy(vm, "_props", key);
3545
- }
3546
- };
3547
3612
 
3548
- for (var key in propsOptions) loop( key );
3549
- toggleObserving(true);
3550
- }
3613
+ if (renderCompleted) {
3614
+ owners.length = 0;
3615
+ }
3616
+ };
3551
3617
 
3552
- function initData (vm) {
3553
- var data = vm.$options.data;
3554
- data = vm._data = typeof data === 'function'
3555
- ? getData(data, vm)
3556
- : data || {};
3557
- if (!isPlainObject(data)) {
3558
- data = {};
3559
- process.env.NODE_ENV !== 'production' && warn(
3560
- 'data functions should return an object:\n' +
3561
- 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
3562
- vm
3563
- );
3564
- }
3565
- // proxy data on instance
3566
- var keys = Object.keys(data);
3567
- var props = vm.$options.props;
3568
- var methods = vm.$options.methods;
3569
- var i = keys.length;
3570
- while (i--) {
3571
- var key = keys[i];
3572
- if (process.env.NODE_ENV !== 'production') {
3573
- if (methods && hasOwn(methods, key)) {
3574
- warn(
3575
- ("Method \"" + key + "\" has already been defined as a data property."),
3576
- vm
3577
- );
3618
+ var resolve = once(function (res) {
3619
+ // cache resolved
3620
+ factory.resolved = ensureCtor(res, baseCtor);
3621
+ // invoke callbacks only if this is not a synchronous resolve
3622
+ // (async resolves are shimmed as synchronous during SSR)
3623
+ if (!sync) {
3624
+ forceRender(true);
3625
+ } else {
3626
+ owners.length = 0;
3578
3627
  }
3579
- }
3580
- if (props && hasOwn(props, key)) {
3628
+ });
3629
+
3630
+ var reject = once(function (reason) {
3581
3631
  process.env.NODE_ENV !== 'production' && warn(
3582
- "The data property \"" + key + "\" is already declared as a prop. " +
3583
- "Use prop default value instead.",
3584
- vm
3632
+ "Failed to resolve async component: " + (String(factory)) +
3633
+ (reason ? ("\nReason: " + reason) : '')
3585
3634
  );
3586
- } else if (!isReserved(key)) {
3587
- proxy(vm, "_data", key);
3635
+ if (isDef(factory.errorComp)) {
3636
+ factory.error = true;
3637
+ forceRender(true);
3638
+ }
3639
+ });
3640
+
3641
+ var res = factory(resolve, reject);
3642
+
3643
+ if (isObject(res)) {
3644
+ if (isPromise(res)) {
3645
+ // () => Promise
3646
+ if (isUndef(factory.resolved)) {
3647
+ res.then(resolve, reject);
3648
+ }
3649
+ } else if (isPromise(res.component)) {
3650
+ res.component.then(resolve, reject);
3651
+
3652
+ if (isDef(res.error)) {
3653
+ factory.errorComp = ensureCtor(res.error, baseCtor);
3654
+ }
3655
+
3656
+ if (isDef(res.loading)) {
3657
+ factory.loadingComp = ensureCtor(res.loading, baseCtor);
3658
+ if (res.delay === 0) {
3659
+ factory.loading = true;
3660
+ } else {
3661
+ setTimeout(function () {
3662
+ if (isUndef(factory.resolved) && isUndef(factory.error)) {
3663
+ factory.loading = true;
3664
+ forceRender(false);
3665
+ }
3666
+ }, res.delay || 200);
3667
+ }
3668
+ }
3669
+
3670
+ if (isDef(res.timeout)) {
3671
+ setTimeout(function () {
3672
+ if (isUndef(factory.resolved)) {
3673
+ reject(
3674
+ process.env.NODE_ENV !== 'production'
3675
+ ? ("timeout (" + (res.timeout) + "ms)")
3676
+ : null
3677
+ );
3678
+ }
3679
+ }, res.timeout);
3680
+ }
3681
+ }
3588
3682
  }
3589
- }
3590
- // observe data
3591
- observe(data, true /* asRootData */);
3592
- }
3593
3683
 
3594
- function getData (data, vm) {
3595
- // #7573 disable dep collection when invoking data getters
3596
- pushTarget();
3597
- try {
3598
- return data.call(vm, vm)
3599
- } catch (e) {
3600
- handleError(e, vm, "data()");
3601
- return {}
3602
- } finally {
3603
- popTarget();
3684
+ sync = false;
3685
+ // return in case resolved synchronously
3686
+ return factory.loading
3687
+ ? factory.loadingComp
3688
+ : factory.resolved
3604
3689
  }
3605
3690
  }
3606
3691
 
3607
- var computedWatcherOptions = { lazy: true };
3608
-
3609
- function initComputed (vm, computed) {
3610
- // $flow-disable-line
3611
- var watchers = vm._computedWatchers = Object.create(null);
3612
- // computed properties are just getters during SSR
3613
- var isSSR = isServerRendering();
3692
+ /* */
3614
3693
 
3615
- for (var key in computed) {
3616
- var userDef = computed[key];
3617
- var getter = typeof userDef === 'function' ? userDef : userDef.get;
3618
- if (process.env.NODE_ENV !== 'production' && getter == null) {
3619
- warn(
3620
- ("Getter is missing for computed property \"" + key + "\"."),
3621
- vm
3622
- );
3623
- }
3694
+ function isAsyncPlaceholder (node) {
3695
+ return node.isComment && node.asyncFactory
3696
+ }
3624
3697
 
3625
- if (!isSSR) {
3626
- // create internal watcher for the computed property.
3627
- watchers[key] = new Watcher(
3628
- vm,
3629
- getter || noop,
3630
- noop,
3631
- computedWatcherOptions
3632
- );
3633
- }
3698
+ /* */
3634
3699
 
3635
- // component-defined computed properties are already defined on the
3636
- // component prototype. We only need to define computed properties defined
3637
- // at instantiation here.
3638
- if (!(key in vm)) {
3639
- defineComputed(vm, key, userDef);
3640
- } else if (process.env.NODE_ENV !== 'production') {
3641
- if (key in vm.$data) {
3642
- warn(("The computed property \"" + key + "\" is already defined in data."), vm);
3643
- } else if (vm.$options.props && key in vm.$options.props) {
3644
- warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
3700
+ function getFirstComponentChild (children) {
3701
+ if (Array.isArray(children)) {
3702
+ for (var i = 0; i < children.length; i++) {
3703
+ var c = children[i];
3704
+ if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
3705
+ return c
3645
3706
  }
3646
3707
  }
3647
3708
  }
3648
3709
  }
3649
3710
 
3650
- function defineComputed (
3651
- target,
3652
- key,
3653
- userDef
3654
- ) {
3655
- var shouldCache = !isServerRendering();
3656
- if (typeof userDef === 'function') {
3657
- sharedPropertyDefinition.get = shouldCache
3658
- ? createComputedGetter(key)
3659
- : createGetterInvoker(userDef);
3660
- sharedPropertyDefinition.set = noop;
3661
- } else {
3662
- sharedPropertyDefinition.get = userDef.get
3663
- ? shouldCache && userDef.cache !== false
3664
- ? createComputedGetter(key)
3665
- : createGetterInvoker(userDef.get)
3666
- : noop;
3667
- sharedPropertyDefinition.set = userDef.set || noop;
3668
- }
3669
- if (process.env.NODE_ENV !== 'production' &&
3670
- sharedPropertyDefinition.set === noop) {
3671
- sharedPropertyDefinition.set = function () {
3672
- warn(
3673
- ("Computed property \"" + key + "\" was assigned to but it has no setter."),
3674
- this
3675
- );
3676
- };
3677
- }
3678
- Object.defineProperty(target, key, sharedPropertyDefinition);
3679
- }
3711
+ /* */
3680
3712
 
3681
- function createComputedGetter (key) {
3682
- return function computedGetter () {
3683
- var watcher = this._computedWatchers && this._computedWatchers[key];
3684
- if (watcher) {
3685
- if (watcher.dirty) {
3686
- watcher.evaluate();
3687
- }
3688
- if (Dep.target) {
3689
- watcher.depend();
3690
- }
3691
- return watcher.value
3692
- }
3713
+ /* */
3714
+
3715
+ function initEvents (vm) {
3716
+ vm._events = Object.create(null);
3717
+ vm._hasHookEvent = false;
3718
+ // init parent attached events
3719
+ var listeners = vm.$options._parentListeners;
3720
+ if (listeners) {
3721
+ updateComponentListeners(vm, listeners);
3693
3722
  }
3694
3723
  }
3695
3724
 
3696
- function createGetterInvoker(fn) {
3697
- return function computedGetter () {
3698
- return fn.call(this, this)
3699
- }
3725
+ var target;
3726
+
3727
+ function add (event, fn) {
3728
+ target.$on(event, fn);
3700
3729
  }
3701
3730
 
3702
- function initMethods (vm, methods) {
3703
- var props = vm.$options.props;
3704
- for (var key in methods) {
3705
- if (process.env.NODE_ENV !== 'production') {
3706
- if (typeof methods[key] !== 'function') {
3707
- warn(
3708
- "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
3709
- "Did you reference the function correctly?",
3710
- vm
3711
- );
3712
- }
3713
- if (props && hasOwn(props, key)) {
3714
- warn(
3715
- ("Method \"" + key + "\" has already been defined as a prop."),
3716
- vm
3717
- );
3718
- }
3719
- if ((key in vm) && isReserved(key)) {
3720
- warn(
3721
- "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
3722
- "Avoid defining component methods that start with _ or $."
3723
- );
3724
- }
3725
- }
3726
- vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
3727
- }
3731
+ function remove$1 (event, fn) {
3732
+ target.$off(event, fn);
3728
3733
  }
3729
3734
 
3730
- function initWatch (vm, watch) {
3731
- for (var key in watch) {
3732
- var handler = watch[key];
3733
- if (Array.isArray(handler)) {
3734
- for (var i = 0; i < handler.length; i++) {
3735
- createWatcher(vm, key, handler[i]);
3736
- }
3737
- } else {
3738
- createWatcher(vm, key, handler);
3735
+ function createOnceHandler (event, fn) {
3736
+ var _target = target;
3737
+ return function onceHandler () {
3738
+ var res = fn.apply(null, arguments);
3739
+ if (res !== null) {
3740
+ _target.$off(event, onceHandler);
3739
3741
  }
3740
3742
  }
3741
3743
  }
3742
3744
 
3743
- function createWatcher (
3745
+ function updateComponentListeners (
3744
3746
  vm,
3745
- expOrFn,
3746
- handler,
3747
- options
3747
+ listeners,
3748
+ oldListeners
3748
3749
  ) {
3749
- if (isPlainObject(handler)) {
3750
- options = handler;
3751
- handler = handler.handler;
3752
- }
3753
- if (typeof handler === 'string') {
3754
- handler = vm[handler];
3755
- }
3756
- return vm.$watch(expOrFn, handler, options)
3750
+ target = vm;
3751
+ updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
3752
+ target = undefined;
3757
3753
  }
3758
3754
 
3759
- function stateMixin (Vue) {
3760
- // flow somehow has problems with directly declared definition object
3761
- // when using Object.defineProperty, so we have to procedurally build up
3762
- // the object here.
3763
- var dataDef = {};
3764
- dataDef.get = function () { return this._data };
3765
- var propsDef = {};
3766
- propsDef.get = function () { return this._props };
3767
- if (process.env.NODE_ENV !== 'production') {
3768
- dataDef.set = function () {
3769
- warn(
3770
- 'Avoid replacing instance root $data. ' +
3771
- 'Use nested data properties instead.',
3772
- this
3773
- );
3774
- };
3775
- propsDef.set = function () {
3776
- warn("$props is readonly.", this);
3777
- };
3778
- }
3779
- Object.defineProperty(Vue.prototype, '$data', dataDef);
3780
- Object.defineProperty(Vue.prototype, '$props', propsDef);
3755
+ function eventsMixin (Vue) {
3756
+ var hookRE = /^hook:/;
3757
+ Vue.prototype.$on = function (event, fn) {
3758
+ var vm = this;
3759
+ if (Array.isArray(event)) {
3760
+ for (var i = 0, l = event.length; i < l; i++) {
3761
+ vm.$on(event[i], fn);
3762
+ }
3763
+ } else {
3764
+ (vm._events[event] || (vm._events[event] = [])).push(fn);
3765
+ // optimize hook:event cost by using a boolean flag marked at registration
3766
+ // instead of a hash lookup
3767
+ if (hookRE.test(event)) {
3768
+ vm._hasHookEvent = true;
3769
+ }
3770
+ }
3771
+ return vm
3772
+ };
3781
3773
 
3782
- Vue.prototype.$set = set;
3783
- Vue.prototype.$delete = del;
3774
+ Vue.prototype.$once = function (event, fn) {
3775
+ var vm = this;
3776
+ function on () {
3777
+ vm.$off(event, on);
3778
+ fn.apply(vm, arguments);
3779
+ }
3780
+ on.fn = fn;
3781
+ vm.$on(event, on);
3782
+ return vm
3783
+ };
3784
+
3785
+ Vue.prototype.$off = function (event, fn) {
3786
+ var vm = this;
3787
+ // all
3788
+ if (!arguments.length) {
3789
+ vm._events = Object.create(null);
3790
+ return vm
3791
+ }
3792
+ // array of events
3793
+ if (Array.isArray(event)) {
3794
+ for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
3795
+ vm.$off(event[i$1], fn);
3796
+ }
3797
+ return vm
3798
+ }
3799
+ // specific event
3800
+ var cbs = vm._events[event];
3801
+ if (!cbs) {
3802
+ return vm
3803
+ }
3804
+ if (!fn) {
3805
+ vm._events[event] = null;
3806
+ return vm
3807
+ }
3808
+ // specific handler
3809
+ var cb;
3810
+ var i = cbs.length;
3811
+ while (i--) {
3812
+ cb = cbs[i];
3813
+ if (cb === fn || cb.fn === fn) {
3814
+ cbs.splice(i, 1);
3815
+ break
3816
+ }
3817
+ }
3818
+ return vm
3819
+ };
3784
3820
 
3785
- Vue.prototype.$watch = function (
3786
- expOrFn,
3787
- cb,
3788
- options
3789
- ) {
3821
+ Vue.prototype.$emit = function (event) {
3790
3822
  var vm = this;
3791
- if (isPlainObject(cb)) {
3792
- return createWatcher(vm, expOrFn, cb, options)
3793
- }
3794
- options = options || {};
3795
- options.user = true;
3796
- var watcher = new Watcher(vm, expOrFn, cb, options);
3797
- if (options.immediate) {
3798
- try {
3799
- cb.call(vm, watcher.value);
3800
- } catch (error) {
3801
- handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
3823
+ if (process.env.NODE_ENV !== 'production') {
3824
+ var lowerCaseEvent = event.toLowerCase();
3825
+ if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
3826
+ tip(
3827
+ "Event \"" + lowerCaseEvent + "\" is emitted in component " +
3828
+ (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
3829
+ "Note that HTML attributes are case-insensitive and you cannot use " +
3830
+ "v-on to listen to camelCase events when using in-DOM templates. " +
3831
+ "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
3832
+ );
3802
3833
  }
3803
3834
  }
3804
- return function unwatchFn () {
3805
- watcher.teardown();
3835
+ var cbs = vm._events[event];
3836
+ if (cbs) {
3837
+ cbs = cbs.length > 1 ? toArray(cbs) : cbs;
3838
+ var args = toArray(arguments, 1);
3839
+ var info = "event handler for \"" + event + "\"";
3840
+ for (var i = 0, l = cbs.length; i < l; i++) {
3841
+ invokeWithErrorHandling(cbs[i], vm, args, vm, info);
3842
+ }
3806
3843
  }
3844
+ return vm
3807
3845
  };
3808
3846
  }
3809
3847
 
3810
3848
  /* */
3811
3849
 
3812
- function initProvide (vm) {
3813
- var provide = vm.$options.provide;
3814
- if (provide) {
3815
- vm._provided = typeof provide === 'function'
3816
- ? provide.call(vm)
3817
- : provide;
3818
- }
3819
- }
3850
+ var activeInstance = null;
3851
+ var isUpdatingChildComponent = false;
3820
3852
 
3821
- function initInjections (vm) {
3822
- var result = resolveInject(vm.$options.inject, vm);
3823
- if (result) {
3824
- toggleObserving(false);
3825
- Object.keys(result).forEach(function (key) {
3826
- /* istanbul ignore else */
3827
- if (process.env.NODE_ENV !== 'production') {
3828
- defineReactive$$1(vm, key, result[key], function () {
3829
- warn(
3830
- "Avoid mutating an injected value directly since the changes will be " +
3831
- "overwritten whenever the provided component re-renders. " +
3832
- "injection being mutated: \"" + key + "\"",
3833
- vm
3834
- );
3835
- });
3836
- } else {
3837
- defineReactive$$1(vm, key, result[key]);
3838
- }
3839
- });
3840
- toggleObserving(true);
3853
+ function setActiveInstance(vm) {
3854
+ var prevActiveInstance = activeInstance;
3855
+ activeInstance = vm;
3856
+ return function () {
3857
+ activeInstance = prevActiveInstance;
3841
3858
  }
3842
3859
  }
3843
3860
 
3844
- function resolveInject (inject, vm) {
3845
- if (inject) {
3846
- // inject is :any because flow is not smart enough to figure out cached
3847
- var result = Object.create(null);
3848
- var keys = hasSymbol
3849
- ? Reflect.ownKeys(inject)
3850
- : Object.keys(inject);
3861
+ function initLifecycle (vm) {
3862
+ var options = vm.$options;
3851
3863
 
3852
- for (var i = 0; i < keys.length; i++) {
3853
- var key = keys[i];
3854
- // #6574 in case the inject object is observed...
3855
- if (key === '__ob__') { continue }
3856
- var provideKey = inject[key].from;
3857
- var source = vm;
3858
- while (source) {
3859
- if (source._provided && hasOwn(source._provided, provideKey)) {
3860
- result[key] = source._provided[provideKey];
3861
- break
3862
- }
3863
- source = source.$parent;
3864
- }
3865
- if (!source) {
3866
- if ('default' in inject[key]) {
3867
- var provideDefault = inject[key].default;
3868
- result[key] = typeof provideDefault === 'function'
3869
- ? provideDefault.call(vm)
3870
- : provideDefault;
3871
- } else if (process.env.NODE_ENV !== 'production') {
3872
- warn(("Injection \"" + key + "\" not found"), vm);
3873
- }
3874
- }
3864
+ // locate first non-abstract parent
3865
+ var parent = options.parent;
3866
+ if (parent && !options.abstract) {
3867
+ while (parent.$options.abstract && parent.$parent) {
3868
+ parent = parent.$parent;
3875
3869
  }
3876
- return result
3870
+ parent.$children.push(vm);
3877
3871
  }
3878
- }
3879
-
3880
- /* */
3881
3872
 
3882
- function normalizeScopedSlots (
3883
- slots,
3884
- normalSlots
3885
- ) {
3886
- var res;
3887
- if (!slots) {
3888
- res = {};
3889
- } else if (slots._normalized) {
3890
- return slots
3891
- } else {
3892
- res = {};
3893
- for (var key in slots) {
3894
- if (slots[key] && key[0] !== '$') {
3895
- res[key] = normalizeScopedSlot(normalSlots, key, slots[key]);
3896
- }
3897
- }
3898
- }
3899
- // expose normal slots on scopedSlots
3900
- for (var key$1 in normalSlots) {
3901
- if (!(key$1 in res)) {
3902
- res[key$1] = proxyNormalSlot(normalSlots, key$1);
3903
- }
3904
- }
3905
- res._normalized = true;
3906
- res.$stable = slots ? slots.$stable : true;
3907
- return res
3908
- }
3873
+ vm.$parent = parent;
3874
+ vm.$root = parent ? parent.$root : vm;
3909
3875
 
3910
- function normalizeScopedSlot(normalSlots, key, fn) {
3911
- var normalized = function (scope) {
3912
- if ( scope === void 0 ) scope = {};
3876
+ vm.$children = [];
3877
+ vm.$refs = {};
3913
3878
 
3914
- var res = fn(scope);
3915
- return res && typeof res === 'object' && !Array.isArray(res)
3916
- ? [res] // single vnode
3917
- : normalizeChildren(res)
3918
- };
3919
- // proxy scoped slots on normal $slots
3920
- if (!hasOwn(normalSlots, key)) {
3921
- Object.defineProperty(normalSlots, key, {
3922
- get: normalized
3923
- });
3924
- }
3925
- return normalized
3879
+ vm._watcher = null;
3880
+ vm._inactive = null;
3881
+ vm._directInactive = false;
3882
+ vm._isMounted = false;
3883
+ vm._isDestroyed = false;
3884
+ vm._isBeingDestroyed = false;
3926
3885
  }
3927
3886
 
3928
- function proxyNormalSlot(slots, key) {
3929
- return function () { return slots[key]; }
3930
- }
3887
+ function lifecycleMixin (Vue) {
3888
+ Vue.prototype._update = function (vnode, hydrating) {
3889
+ var vm = this;
3890
+ var prevEl = vm.$el;
3891
+ var prevVnode = vm._vnode;
3892
+ var restoreActiveInstance = setActiveInstance(vm);
3893
+ vm._vnode = vnode;
3894
+ // Vue.prototype.__patch__ is injected in entry points
3895
+ // based on the rendering backend used.
3896
+ if (!prevVnode) {
3897
+ // initial render
3898
+ vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
3899
+ } else {
3900
+ // updates
3901
+ vm.$el = vm.__patch__(prevVnode, vnode);
3902
+ }
3903
+ restoreActiveInstance();
3904
+ // update __vue__ reference
3905
+ if (prevEl) {
3906
+ prevEl.__vue__ = null;
3907
+ }
3908
+ if (vm.$el) {
3909
+ vm.$el.__vue__ = vm;
3910
+ }
3911
+ // if parent is an HOC, update its $el as well
3912
+ if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
3913
+ vm.$parent.$el = vm.$el;
3914
+ }
3915
+ // updated hook is called by the scheduler to ensure that children are
3916
+ // updated in a parent's updated hook.
3917
+ };
3931
3918
 
3932
- /* */
3919
+ Vue.prototype.$forceUpdate = function () {
3920
+ var vm = this;
3921
+ if (vm._watcher) {
3922
+ vm._watcher.update();
3923
+ }
3924
+ };
3933
3925
 
3934
- /**
3935
- * Runtime helper for rendering v-for lists.
3936
- */
3937
- function renderList (
3938
- val,
3939
- render
3940
- ) {
3941
- var ret, i, l, keys, key;
3942
- if (Array.isArray(val) || typeof val === 'string') {
3943
- ret = new Array(val.length);
3944
- for (i = 0, l = val.length; i < l; i++) {
3945
- ret[i] = render(val[i], i);
3926
+ Vue.prototype.$destroy = function () {
3927
+ var vm = this;
3928
+ if (vm._isBeingDestroyed) {
3929
+ return
3946
3930
  }
3947
- } else if (typeof val === 'number') {
3948
- ret = new Array(val);
3949
- for (i = 0; i < val; i++) {
3950
- ret[i] = render(i + 1, i);
3931
+ callHook(vm, 'beforeDestroy');
3932
+ vm._isBeingDestroyed = true;
3933
+ // remove self from parent
3934
+ var parent = vm.$parent;
3935
+ if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
3936
+ remove(parent.$children, vm);
3951
3937
  }
3952
- } else if (isObject(val)) {
3953
- if (hasSymbol && val[Symbol.iterator]) {
3954
- ret = [];
3955
- var iterator = val[Symbol.iterator]();
3956
- var result = iterator.next();
3957
- while (!result.done) {
3958
- ret.push(render(result.value, ret.length));
3959
- result = iterator.next();
3960
- }
3961
- } else {
3962
- keys = Object.keys(val);
3963
- ret = new Array(keys.length);
3964
- for (i = 0, l = keys.length; i < l; i++) {
3965
- key = keys[i];
3966
- ret[i] = render(val[key], key, i);
3967
- }
3938
+ // teardown watchers
3939
+ if (vm._watcher) {
3940
+ vm._watcher.teardown();
3941
+ }
3942
+ var i = vm._watchers.length;
3943
+ while (i--) {
3944
+ vm._watchers[i].teardown();
3945
+ }
3946
+ // remove reference from data ob
3947
+ // frozen object may not have observer.
3948
+ if (vm._data.__ob__) {
3949
+ vm._data.__ob__.vmCount--;
3950
+ }
3951
+ // call the last hook...
3952
+ vm._isDestroyed = true;
3953
+ // invoke destroy hooks on current rendered tree
3954
+ vm.__patch__(vm._vnode, null);
3955
+ // fire destroyed hook
3956
+ callHook(vm, 'destroyed');
3957
+ // turn off all instance listeners.
3958
+ vm.$off();
3959
+ // remove __vue__ reference
3960
+ if (vm.$el) {
3961
+ vm.$el.__vue__ = null;
3968
3962
  }
3969
- }
3970
- if (!isDef(ret)) {
3971
- ret = [];
3972
- }
3973
- (ret)._isVList = true;
3974
- return ret
3963
+ // release circular reference (#6759)
3964
+ if (vm.$vnode) {
3965
+ vm.$vnode.parent = null;
3966
+ }
3967
+ };
3975
3968
  }
3976
3969
 
3977
- /* */
3978
-
3979
- /**
3980
- * Runtime helper for rendering <slot>
3981
- */
3982
- function renderSlot (
3983
- name,
3984
- fallback,
3985
- props,
3986
- bindObject
3970
+ function mountComponent (
3971
+ vm,
3972
+ el,
3973
+ hydrating
3987
3974
  ) {
3988
- var scopedSlotFn = this.$scopedSlots[name];
3989
- var nodes;
3990
- if (scopedSlotFn) { // scoped slot
3991
- props = props || {};
3992
- if (bindObject) {
3993
- if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) {
3975
+ vm.$el = el;
3976
+ if (!vm.$options.render) {
3977
+ vm.$options.render = createEmptyVNode;
3978
+ if (process.env.NODE_ENV !== 'production') {
3979
+ /* istanbul ignore if */
3980
+ if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
3981
+ vm.$options.el || el) {
3994
3982
  warn(
3995
- 'slot v-bind without argument expects an Object',
3996
- this
3983
+ 'You are using the runtime-only build of Vue where the template ' +
3984
+ 'compiler is not available. Either pre-compile the templates into ' +
3985
+ 'render functions, or use the compiler-included build.',
3986
+ vm
3987
+ );
3988
+ } else {
3989
+ warn(
3990
+ 'Failed to mount component: template or render function not defined.',
3991
+ vm
3997
3992
  );
3998
3993
  }
3999
- props = extend(extend({}, bindObject), props);
4000
3994
  }
4001
- nodes = scopedSlotFn(props) || fallback;
4002
- } else {
4003
- nodes = this.$slots[name] || fallback;
4004
3995
  }
3996
+ callHook(vm, 'beforeMount');
4005
3997
 
4006
- var target = props && props.slot;
4007
- if (target) {
4008
- return this.$createElement('template', { slot: target }, nodes)
4009
- } else {
4010
- return nodes
4011
- }
4012
- }
3998
+ var updateComponent;
3999
+ /* istanbul ignore if */
4000
+ if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
4001
+ updateComponent = function () {
4002
+ var name = vm._name;
4003
+ var id = vm._uid;
4004
+ var startTag = "vue-perf-start:" + id;
4005
+ var endTag = "vue-perf-end:" + id;
4013
4006
 
4014
- /* */
4007
+ mark(startTag);
4008
+ var vnode = vm._render();
4009
+ mark(endTag);
4010
+ measure(("vue " + name + " render"), startTag, endTag);
4015
4011
 
4016
- /**
4017
- * Runtime helper for resolving filters
4018
- */
4019
- function resolveFilter (id) {
4020
- return resolveAsset(this.$options, 'filters', id, true) || identity
4021
- }
4012
+ mark(startTag);
4013
+ vm._update(vnode, hydrating);
4014
+ mark(endTag);
4015
+ measure(("vue " + name + " patch"), startTag, endTag);
4016
+ };
4017
+ } else {
4018
+ updateComponent = function () {
4019
+ vm._update(vm._render(), hydrating);
4020
+ };
4021
+ }
4022
4022
 
4023
- /* */
4023
+ // we set this to vm._watcher inside the watcher's constructor
4024
+ // since the watcher's initial patch may call $forceUpdate (e.g. inside child
4025
+ // component's mounted hook), which relies on vm._watcher being already defined
4026
+ new Watcher(vm, updateComponent, noop, {
4027
+ before: function before () {
4028
+ if (vm._isMounted && !vm._isDestroyed) {
4029
+ callHook(vm, 'beforeUpdate');
4030
+ }
4031
+ }
4032
+ }, true /* isRenderWatcher */);
4033
+ hydrating = false;
4024
4034
 
4025
- function isKeyNotMatch (expect, actual) {
4026
- if (Array.isArray(expect)) {
4027
- return expect.indexOf(actual) === -1
4028
- } else {
4029
- return expect !== actual
4035
+ // manually mounted instance, call mounted on self
4036
+ // mounted is called for render-created child components in its inserted hook
4037
+ if (vm.$vnode == null) {
4038
+ vm._isMounted = true;
4039
+ callHook(vm, 'mounted');
4030
4040
  }
4041
+ return vm
4031
4042
  }
4032
4043
 
4033
- /**
4034
- * Runtime helper for checking keyCodes from config.
4035
- * exposed as Vue.prototype._k
4036
- * passing in eventKeyName as last argument separately for backwards compat
4037
- */
4038
- function checkKeyCodes (
4039
- eventKeyCode,
4040
- key,
4041
- builtInKeyCode,
4042
- eventKeyName,
4043
- builtInKeyName
4044
+ function updateChildComponent (
4045
+ vm,
4046
+ propsData,
4047
+ listeners,
4048
+ parentVnode,
4049
+ renderChildren
4044
4050
  ) {
4045
- var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
4046
- if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
4047
- return isKeyNotMatch(builtInKeyName, eventKeyName)
4048
- } else if (mappedKeyCode) {
4049
- return isKeyNotMatch(mappedKeyCode, eventKeyCode)
4050
- } else if (eventKeyName) {
4051
- return hyphenate(eventKeyName) !== key
4051
+ if (process.env.NODE_ENV !== 'production') {
4052
+ isUpdatingChildComponent = true;
4052
4053
  }
4053
- }
4054
-
4055
- /* */
4056
4054
 
4057
- /**
4058
- * Runtime helper for merging v-bind="object" into a VNode's data.
4059
- */
4060
- function bindObjectProps (
4061
- data,
4062
- tag,
4063
- value,
4064
- asProp,
4065
- isSync
4066
- ) {
4067
- if (value) {
4068
- if (!isObject(value)) {
4069
- process.env.NODE_ENV !== 'production' && warn(
4070
- 'v-bind without argument expects an Object or Array value',
4071
- this
4072
- );
4073
- } else {
4074
- if (Array.isArray(value)) {
4075
- value = toObject(value);
4076
- }
4077
- var hash;
4078
- var loop = function ( key ) {
4079
- if (
4080
- key === 'class' ||
4081
- key === 'style' ||
4082
- isReservedAttribute(key)
4083
- ) {
4084
- hash = data;
4085
- } else {
4086
- var type = data.attrs && data.attrs.type;
4087
- hash = asProp || config.mustUseProp(tag, type, key)
4088
- ? data.domProps || (data.domProps = {})
4089
- : data.attrs || (data.attrs = {});
4090
- }
4091
- var camelizedKey = camelize(key);
4092
- if (!(key in hash) && !(camelizedKey in hash)) {
4093
- hash[key] = value[key];
4055
+ // determine whether component has slot children
4056
+ // we need to do this before overwriting $options._renderChildren.
4094
4057
 
4095
- if (isSync) {
4096
- var on = data.on || (data.on = {});
4097
- on[("update:" + camelizedKey)] = function ($event) {
4098
- value[key] = $event;
4099
- };
4100
- }
4101
- }
4102
- };
4058
+ // check if there are dynamic scopedSlots (hand-written or compiled but with
4059
+ // dynamic slot names). Static scoped slots compiled from template has the
4060
+ // "$stable" marker.
4061
+ var hasDynamicScopedSlot = !!(
4062
+ (parentVnode.data.scopedSlots && !parentVnode.data.scopedSlots.$stable) ||
4063
+ (vm.$scopedSlots !== emptyObject && !vm.$scopedSlots.$stable)
4064
+ );
4103
4065
 
4104
- for (var key in value) loop( key );
4105
- }
4106
- }
4107
- return data
4108
- }
4066
+ // Any static slot children from the parent may have changed during parent's
4067
+ // update. Dynamic scoped slots may also have changed. In such cases, a forced
4068
+ // update is necessary to ensure correctness.
4069
+ var needsForceUpdate = !!(
4070
+ renderChildren || // has new static slots
4071
+ vm.$options._renderChildren || // has old static slots
4072
+ hasDynamicScopedSlot
4073
+ );
4109
4074
 
4110
- /* */
4075
+ vm.$options._parentVnode = parentVnode;
4076
+ vm.$vnode = parentVnode; // update vm's placeholder node without re-render
4111
4077
 
4112
- /**
4113
- * Runtime helper for rendering static trees.
4114
- */
4115
- function renderStatic (
4116
- index,
4117
- isInFor
4118
- ) {
4119
- var cached = this._staticTrees || (this._staticTrees = []);
4120
- var tree = cached[index];
4121
- // if has already-rendered static tree and not inside v-for,
4122
- // we can reuse the same tree.
4123
- if (tree && !isInFor) {
4124
- return tree
4078
+ if (vm._vnode) { // update child tree's parent
4079
+ vm._vnode.parent = parentVnode;
4125
4080
  }
4126
- // otherwise, render a fresh tree.
4127
- tree = cached[index] = this.$options.staticRenderFns[index].call(
4128
- this._renderProxy,
4129
- null,
4130
- this // for render fns generated for functional component templates
4131
- );
4132
- markStatic(tree, ("__static__" + index), false);
4133
- return tree
4134
- }
4135
-
4136
- /**
4137
- * Runtime helper for v-once.
4138
- * Effectively it means marking the node as static with a unique key.
4139
- */
4140
- function markOnce (
4141
- tree,
4142
- index,
4143
- key
4144
- ) {
4145
- markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
4146
- return tree
4147
- }
4081
+ vm.$options._renderChildren = renderChildren;
4148
4082
 
4149
- function markStatic (
4150
- tree,
4151
- key,
4152
- isOnce
4153
- ) {
4154
- if (Array.isArray(tree)) {
4155
- for (var i = 0; i < tree.length; i++) {
4156
- if (tree[i] && typeof tree[i] !== 'string') {
4157
- markStaticNode(tree[i], (key + "_" + i), isOnce);
4158
- }
4083
+ // update $attrs and $listeners hash
4084
+ // these are also reactive so they may trigger child update if the child
4085
+ // used them during render
4086
+ vm.$attrs = parentVnode.data.attrs || emptyObject;
4087
+ vm.$listeners = listeners || emptyObject;
4088
+
4089
+ // update props
4090
+ if (propsData && vm.$options.props) {
4091
+ toggleObserving(false);
4092
+ var props = vm._props;
4093
+ var propKeys = vm.$options._propKeys || [];
4094
+ for (var i = 0; i < propKeys.length; i++) {
4095
+ var key = propKeys[i];
4096
+ var propOptions = vm.$options.props; // wtf flow?
4097
+ props[key] = validateProp(key, propOptions, propsData, vm);
4159
4098
  }
4160
- } else {
4161
- markStaticNode(tree, key, isOnce);
4099
+ toggleObserving(true);
4100
+ // keep a copy of raw propsData
4101
+ vm.$options.propsData = propsData;
4162
4102
  }
4163
- }
4164
4103
 
4165
- function markStaticNode (node, key, isOnce) {
4166
- node.isStatic = true;
4167
- node.key = key;
4168
- node.isOnce = isOnce;
4104
+ // update listeners
4105
+ listeners = listeners || emptyObject;
4106
+ var oldListeners = vm.$options._parentListeners;
4107
+ vm.$options._parentListeners = listeners;
4108
+ updateComponentListeners(vm, listeners, oldListeners);
4109
+
4110
+ // resolve slots + force update if has children
4111
+ if (needsForceUpdate) {
4112
+ vm.$slots = resolveSlots(renderChildren, parentVnode.context);
4113
+ vm.$forceUpdate();
4114
+ }
4115
+
4116
+ if (process.env.NODE_ENV !== 'production') {
4117
+ isUpdatingChildComponent = false;
4118
+ }
4169
4119
  }
4170
4120
 
4171
- /* */
4121
+ function isInInactiveTree (vm) {
4122
+ while (vm && (vm = vm.$parent)) {
4123
+ if (vm._inactive) { return true }
4124
+ }
4125
+ return false
4126
+ }
4172
4127
 
4173
- function bindObjectListeners (data, value) {
4174
- if (value) {
4175
- if (!isPlainObject(value)) {
4176
- process.env.NODE_ENV !== 'production' && warn(
4177
- 'v-on without argument expects an Object value',
4178
- this
4179
- );
4180
- } else {
4181
- var on = data.on = data.on ? extend({}, data.on) : {};
4182
- for (var key in value) {
4183
- var existing = on[key];
4184
- var ours = value[key];
4185
- on[key] = existing ? [].concat(existing, ours) : ours;
4186
- }
4128
+ function activateChildComponent (vm, direct) {
4129
+ if (direct) {
4130
+ vm._directInactive = false;
4131
+ if (isInInactiveTree(vm)) {
4132
+ return
4187
4133
  }
4134
+ } else if (vm._directInactive) {
4135
+ return
4136
+ }
4137
+ if (vm._inactive || vm._inactive === null) {
4138
+ vm._inactive = false;
4139
+ for (var i = 0; i < vm.$children.length; i++) {
4140
+ activateChildComponent(vm.$children[i]);
4141
+ }
4142
+ callHook(vm, 'activated');
4188
4143
  }
4189
- return data
4190
4144
  }
4191
4145
 
4192
- /* */
4193
-
4194
- function bindDynamicKeys (baseObj, values) {
4195
- for (var i = 0; i < values.length; i += 2) {
4196
- var key = values[i];
4197
- if (typeof key === 'string' && key) {
4198
- baseObj[values[i]] = values[i + 1];
4199
- } else if (process.env.NODE_ENV !== 'production' && key !== '' && key !== null) {
4200
- // null is a speical value for explicitly removing a binding
4201
- warn(
4202
- ("Invalid value for dynamic directive argument (expected string or null): " + key),
4203
- this
4204
- );
4146
+ function deactivateChildComponent (vm, direct) {
4147
+ if (direct) {
4148
+ vm._directInactive = true;
4149
+ if (isInInactiveTree(vm)) {
4150
+ return
4205
4151
  }
4206
4152
  }
4207
- return baseObj
4153
+ if (!vm._inactive) {
4154
+ vm._inactive = true;
4155
+ for (var i = 0; i < vm.$children.length; i++) {
4156
+ deactivateChildComponent(vm.$children[i]);
4157
+ }
4158
+ callHook(vm, 'deactivated');
4159
+ }
4208
4160
  }
4209
4161
 
4210
- // helper to dynamically append modifier runtime markers to event names.
4211
- // ensure only append when value is already string, otherwise it will be cast
4212
- // to string and cause the type check to miss.
4213
- function prependModifier (value, symbol) {
4214
- return typeof value === 'string' ? symbol + value : value
4162
+ function callHook (vm, hook) {
4163
+ // #7573 disable dep collection when invoking lifecycle hooks
4164
+ pushTarget();
4165
+ var handlers = vm.$options[hook];
4166
+ var info = hook + " hook";
4167
+ if (handlers) {
4168
+ for (var i = 0, j = handlers.length; i < j; i++) {
4169
+ invokeWithErrorHandling(handlers[i], vm, null, vm, info);
4170
+ }
4171
+ }
4172
+ if (vm._hasHookEvent) {
4173
+ vm.$emit('hook:' + hook);
4174
+ }
4175
+ popTarget();
4215
4176
  }
4216
4177
 
4217
4178
  /* */
4218
4179
 
4219
- function installRenderHelpers (target) {
4220
- target._o = markOnce;
4221
- target._n = toNumber;
4222
- target._s = toString;
4223
- target._l = renderList;
4224
- target._t = renderSlot;
4225
- target._q = looseEqual;
4226
- target._i = looseIndexOf;
4227
- target._m = renderStatic;
4228
- target._f = resolveFilter;
4229
- target._k = checkKeyCodes;
4230
- target._b = bindObjectProps;
4231
- target._v = createTextVNode;
4232
- target._e = createEmptyVNode;
4233
- target._u = resolveScopedSlots;
4234
- target._g = bindObjectListeners;
4235
- target._d = bindDynamicKeys;
4236
- target._p = prependModifier;
4237
- }
4180
+ var MAX_UPDATE_COUNT = 100;
4238
4181
 
4239
- /* */
4182
+ var queue = [];
4183
+ var activatedChildren = [];
4184
+ var has = {};
4185
+ var circular = {};
4186
+ var waiting = false;
4187
+ var flushing = false;
4188
+ var index = 0;
4240
4189
 
4241
- function FunctionalRenderContext (
4242
- data,
4243
- props,
4244
- children,
4245
- parent,
4246
- Ctor
4247
- ) {
4248
- var options = Ctor.options;
4249
- // ensure the createElement function in functional components
4250
- // gets a unique context - this is necessary for correct named slot check
4251
- var contextVm;
4252
- if (hasOwn(parent, '_uid')) {
4253
- contextVm = Object.create(parent);
4254
- // $flow-disable-line
4255
- contextVm._original = parent;
4256
- } else {
4257
- // the context vm passed in is a functional context as well.
4258
- // in this case we want to make sure we are able to get a hold to the
4259
- // real context instance.
4260
- contextVm = parent;
4261
- // $flow-disable-line
4262
- parent = parent._original;
4190
+ /**
4191
+ * Reset the scheduler's state.
4192
+ */
4193
+ function resetSchedulerState () {
4194
+ index = queue.length = activatedChildren.length = 0;
4195
+ has = {};
4196
+ if (process.env.NODE_ENV !== 'production') {
4197
+ circular = {};
4263
4198
  }
4264
- var isCompiled = isTrue(options._compiled);
4265
- var needNormalization = !isCompiled;
4199
+ waiting = flushing = false;
4200
+ }
4266
4201
 
4267
- this.data = data;
4268
- this.props = props;
4269
- this.children = children;
4270
- this.parent = parent;
4271
- this.listeners = data.on || emptyObject;
4272
- this.injections = resolveInject(options.inject, parent);
4273
- this.slots = function () { return resolveSlots(children, parent); };
4202
+ // Async edge case #6566 requires saving the timestamp when event listeners are
4203
+ // attached. However, calling performance.now() has a perf overhead especially
4204
+ // if the page has thousands of event listeners. Instead, we take a timestamp
4205
+ // every time the scheduler flushes and use that for all event listeners
4206
+ // attached during that flush.
4207
+ var currentFlushTimestamp = 0;
4274
4208
 
4275
- Object.defineProperty(this, 'scopedSlots', ({
4276
- enumerable: true,
4277
- get: function get () {
4278
- return normalizeScopedSlots(data.scopedSlots, this.slots())
4279
- }
4280
- }));
4209
+ // Async edge case fix requires storing an event listener's attach timestamp.
4210
+ var getNow = Date.now;
4281
4211
 
4282
- // support for compiled functional template
4283
- if (isCompiled) {
4284
- // exposing $options for renderStatic()
4285
- this.$options = options;
4286
- // pre-resolve slots for renderSlot()
4287
- this.$slots = this.slots();
4288
- this.$scopedSlots = normalizeScopedSlots(data.scopedSlots, this.$slots);
4289
- }
4212
+ // Determine what event timestamp the browser is using. Annoyingly, the
4213
+ // timestamp can either be hi-res (relative to page load) or low-res
4214
+ // (relative to UNIX epoch), so in order to compare time we have to use the
4215
+ // same timestamp type when saving the flush timestamp.
4216
+ if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {
4217
+ // if the low-res timestamp which is bigger than the event timestamp
4218
+ // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
4219
+ // and we need to use the hi-res version for event listeners as well.
4220
+ getNow = function () { return performance.now(); };
4221
+ }
4290
4222
 
4291
- if (options._scopeId) {
4292
- this._c = function (a, b, c, d) {
4293
- var vnode = createElement(contextVm, a, b, c, d, needNormalization);
4294
- if (vnode && !Array.isArray(vnode)) {
4295
- vnode.fnScopeId = options._scopeId;
4296
- vnode.fnContext = parent;
4223
+ /**
4224
+ * Flush both queues and run the watchers.
4225
+ */
4226
+ function flushSchedulerQueue () {
4227
+ currentFlushTimestamp = getNow();
4228
+ flushing = true;
4229
+ var watcher, id;
4230
+
4231
+ // Sort queue before flush.
4232
+ // This ensures that:
4233
+ // 1. Components are updated from parent to child. (because parent is always
4234
+ // created before the child)
4235
+ // 2. A component's user watchers are run before its render watcher (because
4236
+ // user watchers are created before the render watcher)
4237
+ // 3. If a component is destroyed during a parent component's watcher run,
4238
+ // its watchers can be skipped.
4239
+ queue.sort(function (a, b) { return a.id - b.id; });
4240
+
4241
+ // do not cache length because more watchers might be pushed
4242
+ // as we run existing watchers
4243
+ for (index = 0; index < queue.length; index++) {
4244
+ watcher = queue[index];
4245
+ if (watcher.before) {
4246
+ watcher.before();
4247
+ }
4248
+ id = watcher.id;
4249
+ has[id] = null;
4250
+ watcher.run();
4251
+ // in dev build, check and stop circular updates.
4252
+ if (process.env.NODE_ENV !== 'production' && has[id] != null) {
4253
+ circular[id] = (circular[id] || 0) + 1;
4254
+ if (circular[id] > MAX_UPDATE_COUNT) {
4255
+ warn(
4256
+ 'You may have an infinite update loop ' + (
4257
+ watcher.user
4258
+ ? ("in watcher with expression \"" + (watcher.expression) + "\"")
4259
+ : "in a component render function."
4260
+ ),
4261
+ watcher.vm
4262
+ );
4263
+ break
4297
4264
  }
4298
- return vnode
4299
- };
4300
- } else {
4301
- this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
4265
+ }
4302
4266
  }
4303
- }
4304
4267
 
4305
- installRenderHelpers(FunctionalRenderContext.prototype);
4268
+ // keep copies of post queues before resetting state
4269
+ var activatedQueue = activatedChildren.slice();
4270
+ var updatedQueue = queue.slice();
4306
4271
 
4307
- function createFunctionalComponent (
4308
- Ctor,
4309
- propsData,
4310
- data,
4311
- contextVm,
4312
- children
4313
- ) {
4314
- var options = Ctor.options;
4315
- var props = {};
4316
- var propOptions = options.props;
4317
- if (isDef(propOptions)) {
4318
- for (var key in propOptions) {
4319
- props[key] = validateProp(key, propOptions, propsData || emptyObject);
4320
- }
4321
- } else {
4322
- if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
4323
- if (isDef(data.props)) { mergeProps(props, data.props); }
4324
- }
4272
+ resetSchedulerState();
4325
4273
 
4326
- var renderContext = new FunctionalRenderContext(
4327
- data,
4328
- props,
4329
- children,
4330
- contextVm,
4331
- Ctor
4332
- );
4274
+ // call component updated and activated hooks
4275
+ callActivatedHooks(activatedQueue);
4276
+ callUpdatedHooks(updatedQueue);
4333
4277
 
4334
- var vnode = options.render.call(null, renderContext._c, renderContext);
4278
+ // devtool hook
4279
+ /* istanbul ignore if */
4280
+ if (devtools && config.devtools) {
4281
+ devtools.emit('flush');
4282
+ }
4283
+ }
4335
4284
 
4336
- if (vnode instanceof VNode) {
4337
- return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
4338
- } else if (Array.isArray(vnode)) {
4339
- var vnodes = normalizeChildren(vnode) || [];
4340
- var res = new Array(vnodes.length);
4341
- for (var i = 0; i < vnodes.length; i++) {
4342
- res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
4285
+ function callUpdatedHooks (queue) {
4286
+ var i = queue.length;
4287
+ while (i--) {
4288
+ var watcher = queue[i];
4289
+ var vm = watcher.vm;
4290
+ if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
4291
+ callHook(vm, 'updated');
4343
4292
  }
4344
- return res
4345
4293
  }
4346
4294
  }
4347
4295
 
4348
- function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
4349
- // #7817 clone node before setting fnContext, otherwise if the node is reused
4350
- // (e.g. it was from a cached normal slot) the fnContext causes named slots
4351
- // that should not be matched to match.
4352
- var clone = cloneVNode(vnode);
4353
- clone.fnContext = contextVm;
4354
- clone.fnOptions = options;
4355
- if (process.env.NODE_ENV !== 'production') {
4356
- (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
4357
- }
4358
- if (data.slot) {
4359
- (clone.data || (clone.data = {})).slot = data.slot;
4296
+ /**
4297
+ * Queue a kept-alive component that was activated during patch.
4298
+ * The queue will be processed after the entire tree has been patched.
4299
+ */
4300
+ function queueActivatedComponent (vm) {
4301
+ // setting _inactive to false here so that a render function can
4302
+ // rely on checking whether it's in an inactive tree (e.g. router-view)
4303
+ vm._inactive = false;
4304
+ activatedChildren.push(vm);
4305
+ }
4306
+
4307
+ function callActivatedHooks (queue) {
4308
+ for (var i = 0; i < queue.length; i++) {
4309
+ queue[i]._inactive = true;
4310
+ activateChildComponent(queue[i], true /* true */);
4360
4311
  }
4361
- return clone
4362
4312
  }
4363
4313
 
4364
- function mergeProps (to, from) {
4365
- for (var key in from) {
4366
- to[camelize(key)] = from[key];
4314
+ /**
4315
+ * Push a watcher into the watcher queue.
4316
+ * Jobs with duplicate IDs will be skipped unless it's
4317
+ * pushed when the queue is being flushed.
4318
+ */
4319
+ function queueWatcher (watcher) {
4320
+ var id = watcher.id;
4321
+ if (has[id] == null) {
4322
+ has[id] = true;
4323
+ if (!flushing) {
4324
+ queue.push(watcher);
4325
+ } else {
4326
+ // if already flushing, splice the watcher based on its id
4327
+ // if already past its id, it will be run next immediately.
4328
+ var i = queue.length - 1;
4329
+ while (i > index && queue[i].id > watcher.id) {
4330
+ i--;
4331
+ }
4332
+ queue.splice(i + 1, 0, watcher);
4333
+ }
4334
+ // queue the flush
4335
+ if (!waiting) {
4336
+ waiting = true;
4337
+
4338
+ if (process.env.NODE_ENV !== 'production' && !config.async) {
4339
+ flushSchedulerQueue();
4340
+ return
4341
+ }
4342
+ nextTick(flushSchedulerQueue);
4343
+ }
4367
4344
  }
4368
4345
  }
4369
4346
 
4370
4347
  /* */
4371
4348
 
4372
- /* */
4373
4349
 
4374
- /* */
4375
4350
 
4376
- /* */
4351
+ var uid$2 = 0;
4377
4352
 
4378
- // inline hooks to be invoked on component VNodes during patch
4379
- var componentVNodeHooks = {
4380
- init: function init (vnode, hydrating) {
4381
- if (
4382
- vnode.componentInstance &&
4383
- !vnode.componentInstance._isDestroyed &&
4384
- vnode.data.keepAlive
4385
- ) {
4386
- // kept-alive components, treat as a patch
4387
- var mountedNode = vnode; // work around flow
4388
- componentVNodeHooks.prepatch(mountedNode, mountedNode);
4389
- } else {
4390
- var child = vnode.componentInstance = createComponentInstanceForVnode(
4391
- vnode,
4392
- activeInstance
4353
+ /**
4354
+ * A watcher parses an expression, collects dependencies,
4355
+ * and fires callback when the expression value changes.
4356
+ * This is used for both the $watch() api and directives.
4357
+ */
4358
+ var Watcher = function Watcher (
4359
+ vm,
4360
+ expOrFn,
4361
+ cb,
4362
+ options,
4363
+ isRenderWatcher
4364
+ ) {
4365
+ this.vm = vm;
4366
+ if (isRenderWatcher) {
4367
+ vm._watcher = this;
4368
+ }
4369
+ vm._watchers.push(this);
4370
+ // options
4371
+ if (options) {
4372
+ this.deep = !!options.deep;
4373
+ this.user = !!options.user;
4374
+ this.lazy = !!options.lazy;
4375
+ this.sync = !!options.sync;
4376
+ this.before = options.before;
4377
+ } else {
4378
+ this.deep = this.user = this.lazy = this.sync = false;
4379
+ }
4380
+ this.cb = cb;
4381
+ this.id = ++uid$2; // uid for batching
4382
+ this.active = true;
4383
+ this.dirty = this.lazy; // for lazy watchers
4384
+ this.deps = [];
4385
+ this.newDeps = [];
4386
+ this.depIds = new _Set();
4387
+ this.newDepIds = new _Set();
4388
+ this.expression = process.env.NODE_ENV !== 'production'
4389
+ ? expOrFn.toString()
4390
+ : '';
4391
+ // parse expression for getter
4392
+ if (typeof expOrFn === 'function') {
4393
+ this.getter = expOrFn;
4394
+ } else {
4395
+ this.getter = parsePath(expOrFn);
4396
+ if (!this.getter) {
4397
+ this.getter = noop;
4398
+ process.env.NODE_ENV !== 'production' && warn(
4399
+ "Failed watching path: \"" + expOrFn + "\" " +
4400
+ 'Watcher only accepts simple dot-delimited paths. ' +
4401
+ 'For full control, use a function instead.',
4402
+ vm
4393
4403
  );
4394
- child.$mount(hydrating ? vnode.elm : undefined, hydrating);
4395
4404
  }
4396
- },
4397
-
4398
- prepatch: function prepatch (oldVnode, vnode) {
4399
- var options = vnode.componentOptions;
4400
- var child = vnode.componentInstance = oldVnode.componentInstance;
4401
- updateChildComponent(
4402
- child,
4403
- options.propsData, // updated props
4404
- options.listeners, // updated listeners
4405
- vnode, // new parent vnode
4406
- options.children // new children
4407
- );
4408
- },
4405
+ }
4406
+ this.value = this.lazy
4407
+ ? undefined
4408
+ : this.get();
4409
+ };
4409
4410
 
4410
- insert: function insert (vnode) {
4411
- var context = vnode.context;
4412
- var componentInstance = vnode.componentInstance;
4413
- if (!componentInstance._isMounted) {
4414
- componentInstance._isMounted = true;
4415
- callHook(componentInstance, 'mounted');
4416
- }
4417
- if (vnode.data.keepAlive) {
4418
- if (context._isMounted) {
4419
- // vue-router#1212
4420
- // During updates, a kept-alive component's child components may
4421
- // change, so directly walking the tree here may call activated hooks
4422
- // on incorrect children. Instead we push them into a queue which will
4423
- // be processed after the whole patch process ended.
4424
- queueActivatedComponent(componentInstance);
4425
- } else {
4426
- activateChildComponent(componentInstance, true /* direct */);
4427
- }
4411
+ /**
4412
+ * Evaluate the getter, and re-collect dependencies.
4413
+ */
4414
+ Watcher.prototype.get = function get () {
4415
+ pushTarget(this);
4416
+ var value;
4417
+ var vm = this.vm;
4418
+ try {
4419
+ value = this.getter.call(vm, vm);
4420
+ } catch (e) {
4421
+ if (this.user) {
4422
+ handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
4423
+ } else {
4424
+ throw e
4428
4425
  }
4429
- },
4430
-
4431
- destroy: function destroy (vnode) {
4432
- var componentInstance = vnode.componentInstance;
4433
- if (!componentInstance._isDestroyed) {
4434
- if (!vnode.data.keepAlive) {
4435
- componentInstance.$destroy();
4436
- } else {
4437
- deactivateChildComponent(componentInstance, true /* direct */);
4438
- }
4426
+ } finally {
4427
+ // "touch" every property so they are all tracked as
4428
+ // dependencies for deep watching
4429
+ if (this.deep) {
4430
+ traverse(value);
4439
4431
  }
4432
+ popTarget();
4433
+ this.cleanupDeps();
4440
4434
  }
4435
+ return value
4441
4436
  };
4442
4437
 
4443
- var hooksToMerge = Object.keys(componentVNodeHooks);
4444
-
4445
- function createComponent (
4446
- Ctor,
4447
- data,
4448
- context,
4449
- children,
4450
- tag
4451
- ) {
4452
- if (isUndef(Ctor)) {
4453
- return
4454
- }
4455
-
4456
- var baseCtor = context.$options._base;
4457
-
4458
- // plain options object: turn it into a constructor
4459
- if (isObject(Ctor)) {
4460
- Ctor = baseCtor.extend(Ctor);
4461
- }
4462
-
4463
- // if at this stage it's not a constructor or an async component factory,
4464
- // reject.
4465
- if (typeof Ctor !== 'function') {
4466
- if (process.env.NODE_ENV !== 'production') {
4467
- warn(("Invalid Component definition: " + (String(Ctor))), context);
4438
+ /**
4439
+ * Add a dependency to this directive.
4440
+ */
4441
+ Watcher.prototype.addDep = function addDep (dep) {
4442
+ var id = dep.id;
4443
+ if (!this.newDepIds.has(id)) {
4444
+ this.newDepIds.add(id);
4445
+ this.newDeps.push(dep);
4446
+ if (!this.depIds.has(id)) {
4447
+ dep.addSub(this);
4468
4448
  }
4469
- return
4470
4449
  }
4450
+ };
4471
4451
 
4472
- // async component
4473
- var asyncFactory;
4474
- if (isUndef(Ctor.cid)) {
4475
- asyncFactory = Ctor;
4476
- Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context);
4477
- if (Ctor === undefined) {
4478
- // return a placeholder node for async component, which is rendered
4479
- // as a comment node but preserves all the raw information for the node.
4480
- // the information will be used for async server-rendering and hydration.
4481
- return createAsyncPlaceholder(
4482
- asyncFactory,
4483
- data,
4484
- context,
4485
- children,
4486
- tag
4487
- )
4452
+ /**
4453
+ * Clean up for dependency collection.
4454
+ */
4455
+ Watcher.prototype.cleanupDeps = function cleanupDeps () {
4456
+ var i = this.deps.length;
4457
+ while (i--) {
4458
+ var dep = this.deps[i];
4459
+ if (!this.newDepIds.has(dep.id)) {
4460
+ dep.removeSub(this);
4488
4461
  }
4489
4462
  }
4463
+ var tmp = this.depIds;
4464
+ this.depIds = this.newDepIds;
4465
+ this.newDepIds = tmp;
4466
+ this.newDepIds.clear();
4467
+ tmp = this.deps;
4468
+ this.deps = this.newDeps;
4469
+ this.newDeps = tmp;
4470
+ this.newDeps.length = 0;
4471
+ };
4490
4472
 
4491
- data = data || {};
4492
-
4493
- // resolve constructor options in case global mixins are applied after
4494
- // component constructor creation
4495
- resolveConstructorOptions(Ctor);
4496
-
4497
- // transform component v-model data into props & events
4498
- if (isDef(data.model)) {
4499
- transformModel(Ctor.options, data);
4500
- }
4501
-
4502
- // extract props
4503
- var propsData = extractPropsFromVNodeData(data, Ctor, tag);
4504
-
4505
- // functional component
4506
- if (isTrue(Ctor.options.functional)) {
4507
- return createFunctionalComponent(Ctor, propsData, data, context, children)
4473
+ /**
4474
+ * Subscriber interface.
4475
+ * Will be called when a dependency changes.
4476
+ */
4477
+ Watcher.prototype.update = function update () {
4478
+ /* istanbul ignore else */
4479
+ if (this.lazy) {
4480
+ this.dirty = true;
4481
+ } else if (this.sync) {
4482
+ this.run();
4483
+ } else {
4484
+ queueWatcher(this);
4508
4485
  }
4486
+ };
4509
4487
 
4510
- // extract listeners, since these needs to be treated as
4511
- // child component listeners instead of DOM listeners
4512
- var listeners = data.on;
4513
- // replace with listeners with .native modifier
4514
- // so it gets processed during parent component patch.
4515
- data.on = data.nativeOn;
4516
-
4517
- if (isTrue(Ctor.options.abstract)) {
4518
- // abstract components do not keep anything
4519
- // other than props & listeners & slot
4520
-
4521
- // work around flow
4522
- var slot = data.slot;
4523
- data = {};
4524
- if (slot) {
4525
- data.slot = slot;
4488
+ /**
4489
+ * Scheduler job interface.
4490
+ * Will be called by the scheduler.
4491
+ */
4492
+ Watcher.prototype.run = function run () {
4493
+ if (this.active) {
4494
+ var value = this.get();
4495
+ if (
4496
+ value !== this.value ||
4497
+ // Deep watchers and watchers on Object/Arrays should fire even
4498
+ // when the value is the same, because the value may
4499
+ // have mutated.
4500
+ isObject(value) ||
4501
+ this.deep
4502
+ ) {
4503
+ // set new value
4504
+ var oldValue = this.value;
4505
+ this.value = value;
4506
+ if (this.user) {
4507
+ try {
4508
+ this.cb.call(this.vm, value, oldValue);
4509
+ } catch (e) {
4510
+ handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
4511
+ }
4512
+ } else {
4513
+ this.cb.call(this.vm, value, oldValue);
4514
+ }
4526
4515
  }
4527
4516
  }
4517
+ };
4528
4518
 
4529
- // install component management hooks onto the placeholder node
4530
- installComponentHooks(data);
4531
-
4532
- // return a placeholder vnode
4533
- var name = Ctor.options.name || tag;
4534
- var vnode = new VNode(
4535
- ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
4536
- data, undefined, undefined, undefined, context,
4537
- { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
4538
- asyncFactory
4539
- );
4540
-
4541
- return vnode
4542
- }
4543
-
4544
- function createComponentInstanceForVnode (
4545
- vnode, // we know it's MountedComponentVNode but flow doesn't
4546
- parent // activeInstance in lifecycle state
4547
- ) {
4548
- var options = {
4549
- _isComponent: true,
4550
- _parentVnode: vnode,
4551
- parent: parent
4552
- };
4553
- // check inline-template render functions
4554
- var inlineTemplate = vnode.data.inlineTemplate;
4555
- if (isDef(inlineTemplate)) {
4556
- options.render = inlineTemplate.render;
4557
- options.staticRenderFns = inlineTemplate.staticRenderFns;
4558
- }
4559
- return new vnode.componentOptions.Ctor(options)
4560
- }
4519
+ /**
4520
+ * Evaluate the value of the watcher.
4521
+ * This only gets called for lazy watchers.
4522
+ */
4523
+ Watcher.prototype.evaluate = function evaluate () {
4524
+ this.value = this.get();
4525
+ this.dirty = false;
4526
+ };
4561
4527
 
4562
- function installComponentHooks (data) {
4563
- var hooks = data.hook || (data.hook = {});
4564
- for (var i = 0; i < hooksToMerge.length; i++) {
4565
- var key = hooksToMerge[i];
4566
- var existing = hooks[key];
4567
- var toMerge = componentVNodeHooks[key];
4568
- if (existing !== toMerge && !(existing && existing._merged)) {
4569
- hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
4570
- }
4528
+ /**
4529
+ * Depend on all deps collected by this watcher.
4530
+ */
4531
+ Watcher.prototype.depend = function depend () {
4532
+ var i = this.deps.length;
4533
+ while (i--) {
4534
+ this.deps[i].depend();
4571
4535
  }
4572
- }
4573
-
4574
- function mergeHook$1 (f1, f2) {
4575
- var merged = function (a, b) {
4576
- // flow complains about extra args which is why we use any
4577
- f1(a, b);
4578
- f2(a, b);
4579
- };
4580
- merged._merged = true;
4581
- return merged
4582
- }
4536
+ };
4583
4537
 
4584
- // transform component v-model info (value and callback) into
4585
- // prop and event handler respectively.
4586
- function transformModel (options, data) {
4587
- var prop = (options.model && options.model.prop) || 'value';
4588
- var event = (options.model && options.model.event) || 'input'
4589
- ;(data.attrs || (data.attrs = {}))[prop] = data.model.value;
4590
- var on = data.on || (data.on = {});
4591
- var existing = on[event];
4592
- var callback = data.model.callback;
4593
- if (isDef(existing)) {
4594
- if (
4595
- Array.isArray(existing)
4596
- ? existing.indexOf(callback) === -1
4597
- : existing !== callback
4598
- ) {
4599
- on[event] = [callback].concat(existing);
4538
+ /**
4539
+ * Remove self from all dependencies' subscriber list.
4540
+ */
4541
+ Watcher.prototype.teardown = function teardown () {
4542
+ if (this.active) {
4543
+ // remove self from vm's watcher list
4544
+ // this is a somewhat expensive operation so we skip it
4545
+ // if the vm is being destroyed.
4546
+ if (!this.vm._isBeingDestroyed) {
4547
+ remove(this.vm._watchers, this);
4600
4548
  }
4601
- } else {
4602
- on[event] = callback;
4549
+ var i = this.deps.length;
4550
+ while (i--) {
4551
+ this.deps[i].removeSub(this);
4552
+ }
4553
+ this.active = false;
4603
4554
  }
4604
- }
4555
+ };
4605
4556
 
4606
4557
  /* */
4607
4558
 
4608
- var SIMPLE_NORMALIZE = 1;
4609
- var ALWAYS_NORMALIZE = 2;
4559
+ var sharedPropertyDefinition = {
4560
+ enumerable: true,
4561
+ configurable: true,
4562
+ get: noop,
4563
+ set: noop
4564
+ };
4610
4565
 
4611
- // wrapper function for providing a more flexible interface
4612
- // without getting yelled at by flow
4613
- function createElement (
4614
- context,
4615
- tag,
4616
- data,
4617
- children,
4618
- normalizationType,
4619
- alwaysNormalize
4620
- ) {
4621
- if (Array.isArray(data) || isPrimitive(data)) {
4622
- normalizationType = children;
4623
- children = data;
4624
- data = undefined;
4566
+ function proxy (target, sourceKey, key) {
4567
+ sharedPropertyDefinition.get = function proxyGetter () {
4568
+ return this[sourceKey][key]
4569
+ };
4570
+ sharedPropertyDefinition.set = function proxySetter (val) {
4571
+ this[sourceKey][key] = val;
4572
+ };
4573
+ Object.defineProperty(target, key, sharedPropertyDefinition);
4574
+ }
4575
+
4576
+ function initState (vm) {
4577
+ vm._watchers = [];
4578
+ var opts = vm.$options;
4579
+ if (opts.props) { initProps(vm, opts.props); }
4580
+ if (opts.methods) { initMethods(vm, opts.methods); }
4581
+ if (opts.data) {
4582
+ initData(vm);
4583
+ } else {
4584
+ observe(vm._data = {}, true /* asRootData */);
4625
4585
  }
4626
- if (isTrue(alwaysNormalize)) {
4627
- normalizationType = ALWAYS_NORMALIZE;
4586
+ if (opts.computed) { initComputed(vm, opts.computed); }
4587
+ if (opts.watch && opts.watch !== nativeWatch) {
4588
+ initWatch(vm, opts.watch);
4628
4589
  }
4629
- return _createElement(context, tag, data, children, normalizationType)
4630
4590
  }
4631
4591
 
4632
- function _createElement (
4633
- context,
4634
- tag,
4635
- data,
4636
- children,
4637
- normalizationType
4638
- ) {
4639
- if (isDef(data) && isDef((data).__ob__)) {
4592
+ function initProps (vm, propsOptions) {
4593
+ var propsData = vm.$options.propsData || {};
4594
+ var props = vm._props = {};
4595
+ // cache prop keys so that future props updates can iterate using Array
4596
+ // instead of dynamic object key enumeration.
4597
+ var keys = vm.$options._propKeys = [];
4598
+ var isRoot = !vm.$parent;
4599
+ // root instance props should be converted
4600
+ if (!isRoot) {
4601
+ toggleObserving(false);
4602
+ }
4603
+ var loop = function ( key ) {
4604
+ keys.push(key);
4605
+ var value = validateProp(key, propsOptions, propsData, vm);
4606
+ /* istanbul ignore else */
4607
+ if (process.env.NODE_ENV !== 'production') {
4608
+ var hyphenatedKey = hyphenate(key);
4609
+ if (isReservedAttribute(hyphenatedKey) ||
4610
+ config.isReservedAttr(hyphenatedKey)) {
4611
+ warn(
4612
+ ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
4613
+ vm
4614
+ );
4615
+ }
4616
+ defineReactive$$1(props, key, value, function () {
4617
+ if (!isRoot && !isUpdatingChildComponent) {
4618
+ warn(
4619
+ "Avoid mutating a prop directly since the value will be " +
4620
+ "overwritten whenever the parent component re-renders. " +
4621
+ "Instead, use a data or computed property based on the prop's " +
4622
+ "value. Prop being mutated: \"" + key + "\"",
4623
+ vm
4624
+ );
4625
+ }
4626
+ });
4627
+ } else {
4628
+ defineReactive$$1(props, key, value);
4629
+ }
4630
+ // static props are already proxied on the component's prototype
4631
+ // during Vue.extend(). We only need to proxy props defined at
4632
+ // instantiation here.
4633
+ if (!(key in vm)) {
4634
+ proxy(vm, "_props", key);
4635
+ }
4636
+ };
4637
+
4638
+ for (var key in propsOptions) loop( key );
4639
+ toggleObserving(true);
4640
+ }
4641
+
4642
+ function initData (vm) {
4643
+ var data = vm.$options.data;
4644
+ data = vm._data = typeof data === 'function'
4645
+ ? getData(data, vm)
4646
+ : data || {};
4647
+ if (!isPlainObject(data)) {
4648
+ data = {};
4640
4649
  process.env.NODE_ENV !== 'production' && warn(
4641
- "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
4642
- 'Always create fresh vnode data objects in each render!',
4643
- context
4650
+ 'data functions should return an object:\n' +
4651
+ 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
4652
+ vm
4644
4653
  );
4645
- return createEmptyVNode()
4646
- }
4647
- // object syntax in v-bind
4648
- if (isDef(data) && isDef(data.is)) {
4649
- tag = data.is;
4650
- }
4651
- if (!tag) {
4652
- // in case of component :is set to falsy value
4653
- return createEmptyVNode()
4654
4654
  }
4655
- // warn against non-primitive key
4656
- if (process.env.NODE_ENV !== 'production' &&
4657
- isDef(data) && isDef(data.key) && !isPrimitive(data.key)
4658
- ) {
4659
- {
4660
- warn(
4661
- 'Avoid using non-primitive value as key, ' +
4662
- 'use string/number value instead.',
4663
- context
4655
+ // proxy data on instance
4656
+ var keys = Object.keys(data);
4657
+ var props = vm.$options.props;
4658
+ var methods = vm.$options.methods;
4659
+ var i = keys.length;
4660
+ while (i--) {
4661
+ var key = keys[i];
4662
+ if (process.env.NODE_ENV !== 'production') {
4663
+ if (methods && hasOwn(methods, key)) {
4664
+ warn(
4665
+ ("Method \"" + key + "\" has already been defined as a data property."),
4666
+ vm
4667
+ );
4668
+ }
4669
+ }
4670
+ if (props && hasOwn(props, key)) {
4671
+ process.env.NODE_ENV !== 'production' && warn(
4672
+ "The data property \"" + key + "\" is already declared as a prop. " +
4673
+ "Use prop default value instead.",
4674
+ vm
4664
4675
  );
4676
+ } else if (!isReserved(key)) {
4677
+ proxy(vm, "_data", key);
4665
4678
  }
4666
4679
  }
4667
- // support single function children as default scoped slot
4668
- if (Array.isArray(children) &&
4669
- typeof children[0] === 'function'
4670
- ) {
4671
- data = data || {};
4672
- data.scopedSlots = { default: children[0] };
4673
- children.length = 0;
4674
- }
4675
- if (normalizationType === ALWAYS_NORMALIZE) {
4676
- children = normalizeChildren(children);
4677
- } else if (normalizationType === SIMPLE_NORMALIZE) {
4678
- children = simpleNormalizeChildren(children);
4680
+ // observe data
4681
+ observe(data, true /* asRootData */);
4682
+ }
4683
+
4684
+ function getData (data, vm) {
4685
+ // #7573 disable dep collection when invoking data getters
4686
+ pushTarget();
4687
+ try {
4688
+ return data.call(vm, vm)
4689
+ } catch (e) {
4690
+ handleError(e, vm, "data()");
4691
+ return {}
4692
+ } finally {
4693
+ popTarget();
4679
4694
  }
4680
- var vnode, ns;
4681
- if (typeof tag === 'string') {
4682
- var Ctor;
4683
- ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
4684
- if (config.isReservedTag(tag)) {
4685
- // platform built-in elements
4686
- vnode = new VNode(
4687
- config.parsePlatformTagName(tag), data, children,
4688
- undefined, undefined, context
4695
+ }
4696
+
4697
+ var computedWatcherOptions = { lazy: true };
4698
+
4699
+ function initComputed (vm, computed) {
4700
+ // $flow-disable-line
4701
+ var watchers = vm._computedWatchers = Object.create(null);
4702
+ // computed properties are just getters during SSR
4703
+ var isSSR = isServerRendering();
4704
+
4705
+ for (var key in computed) {
4706
+ var userDef = computed[key];
4707
+ var getter = typeof userDef === 'function' ? userDef : userDef.get;
4708
+ if (process.env.NODE_ENV !== 'production' && getter == null) {
4709
+ warn(
4710
+ ("Getter is missing for computed property \"" + key + "\"."),
4711
+ vm
4689
4712
  );
4690
- } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
4691
- // component
4692
- vnode = createComponent(Ctor, data, context, children, tag);
4693
- } else {
4694
- // unknown or unlisted namespaced elements
4695
- // check at runtime because it may get assigned a namespace when its
4696
- // parent normalizes children
4697
- vnode = new VNode(
4698
- tag, data, children,
4699
- undefined, undefined, context
4713
+ }
4714
+
4715
+ if (!isSSR) {
4716
+ // create internal watcher for the computed property.
4717
+ watchers[key] = new Watcher(
4718
+ vm,
4719
+ getter || noop,
4720
+ noop,
4721
+ computedWatcherOptions
4700
4722
  );
4701
4723
  }
4702
- } else {
4703
- // direct component options / constructor
4704
- vnode = createComponent(tag, data, context, children);
4724
+
4725
+ // component-defined computed properties are already defined on the
4726
+ // component prototype. We only need to define computed properties defined
4727
+ // at instantiation here.
4728
+ if (!(key in vm)) {
4729
+ defineComputed(vm, key, userDef);
4730
+ } else if (process.env.NODE_ENV !== 'production') {
4731
+ if (key in vm.$data) {
4732
+ warn(("The computed property \"" + key + "\" is already defined in data."), vm);
4733
+ } else if (vm.$options.props && key in vm.$options.props) {
4734
+ warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
4735
+ }
4736
+ }
4705
4737
  }
4706
- if (Array.isArray(vnode)) {
4707
- return vnode
4708
- } else if (isDef(vnode)) {
4709
- if (isDef(ns)) { applyNS(vnode, ns); }
4710
- if (isDef(data)) { registerDeepBindings(data); }
4711
- return vnode
4738
+ }
4739
+
4740
+ function defineComputed (
4741
+ target,
4742
+ key,
4743
+ userDef
4744
+ ) {
4745
+ var shouldCache = !isServerRendering();
4746
+ if (typeof userDef === 'function') {
4747
+ sharedPropertyDefinition.get = shouldCache
4748
+ ? createComputedGetter(key)
4749
+ : createGetterInvoker(userDef);
4750
+ sharedPropertyDefinition.set = noop;
4712
4751
  } else {
4713
- return createEmptyVNode()
4752
+ sharedPropertyDefinition.get = userDef.get
4753
+ ? shouldCache && userDef.cache !== false
4754
+ ? createComputedGetter(key)
4755
+ : createGetterInvoker(userDef.get)
4756
+ : noop;
4757
+ sharedPropertyDefinition.set = userDef.set || noop;
4758
+ }
4759
+ if (process.env.NODE_ENV !== 'production' &&
4760
+ sharedPropertyDefinition.set === noop) {
4761
+ sharedPropertyDefinition.set = function () {
4762
+ warn(
4763
+ ("Computed property \"" + key + "\" was assigned to but it has no setter."),
4764
+ this
4765
+ );
4766
+ };
4714
4767
  }
4768
+ Object.defineProperty(target, key, sharedPropertyDefinition);
4715
4769
  }
4716
4770
 
4717
- function applyNS (vnode, ns, force) {
4718
- vnode.ns = ns;
4719
- if (vnode.tag === 'foreignObject') {
4720
- // use default namespace inside foreignObject
4721
- ns = undefined;
4722
- force = true;
4723
- }
4724
- if (isDef(vnode.children)) {
4725
- for (var i = 0, l = vnode.children.length; i < l; i++) {
4726
- var child = vnode.children[i];
4727
- if (isDef(child.tag) && (
4728
- isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
4729
- applyNS(child, ns, force);
4771
+ function createComputedGetter (key) {
4772
+ return function computedGetter () {
4773
+ var watcher = this._computedWatchers && this._computedWatchers[key];
4774
+ if (watcher) {
4775
+ if (watcher.dirty) {
4776
+ watcher.evaluate();
4777
+ }
4778
+ if (Dep.target) {
4779
+ watcher.depend();
4730
4780
  }
4781
+ return watcher.value
4731
4782
  }
4732
4783
  }
4733
4784
  }
4734
4785
 
4735
- // ref #5318
4736
- // necessary to ensure parent re-render when deep bindings like :style and
4737
- // :class are used on slot nodes
4738
- function registerDeepBindings (data) {
4739
- if (isObject(data.style)) {
4740
- traverse(data.style);
4741
- }
4742
- if (isObject(data.class)) {
4743
- traverse(data.class);
4786
+ function createGetterInvoker(fn) {
4787
+ return function computedGetter () {
4788
+ return fn.call(this, this)
4744
4789
  }
4745
4790
  }
4746
4791
 
4747
- /* */
4748
-
4749
- function initRender (vm) {
4750
- vm._vnode = null; // the root of the child tree
4751
- vm._staticTrees = null; // v-once cached trees
4752
- var options = vm.$options;
4753
- var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
4754
- var renderContext = parentVnode && parentVnode.context;
4755
- vm.$slots = resolveSlots(options._renderChildren, renderContext);
4756
- vm.$scopedSlots = emptyObject;
4757
- // bind the createElement fn to this instance
4758
- // so that we get proper render context inside it.
4759
- // args order: tag, data, children, normalizationType, alwaysNormalize
4760
- // internal version is used by render functions compiled from templates
4761
- vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
4762
- // normalization is always applied for the public version, used in
4763
- // user-written render functions.
4764
- vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
4792
+ function initMethods (vm, methods) {
4793
+ var props = vm.$options.props;
4794
+ for (var key in methods) {
4795
+ if (process.env.NODE_ENV !== 'production') {
4796
+ if (typeof methods[key] !== 'function') {
4797
+ warn(
4798
+ "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
4799
+ "Did you reference the function correctly?",
4800
+ vm
4801
+ );
4802
+ }
4803
+ if (props && hasOwn(props, key)) {
4804
+ warn(
4805
+ ("Method \"" + key + "\" has already been defined as a prop."),
4806
+ vm
4807
+ );
4808
+ }
4809
+ if ((key in vm) && isReserved(key)) {
4810
+ warn(
4811
+ "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
4812
+ "Avoid defining component methods that start with _ or $."
4813
+ );
4814
+ }
4815
+ }
4816
+ vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
4817
+ }
4818
+ }
4765
4819
 
4766
- // $attrs & $listeners are exposed for easier HOC creation.
4767
- // they need to be reactive so that HOCs using them are always updated
4768
- var parentData = parentVnode && parentVnode.data;
4820
+ function initWatch (vm, watch) {
4821
+ for (var key in watch) {
4822
+ var handler = watch[key];
4823
+ if (Array.isArray(handler)) {
4824
+ for (var i = 0; i < handler.length; i++) {
4825
+ createWatcher(vm, key, handler[i]);
4826
+ }
4827
+ } else {
4828
+ createWatcher(vm, key, handler);
4829
+ }
4830
+ }
4831
+ }
4769
4832
 
4770
- /* istanbul ignore else */
4771
- if (process.env.NODE_ENV !== 'production') {
4772
- defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
4773
- !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
4774
- }, true);
4775
- defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
4776
- !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
4777
- }, true);
4778
- } else {
4779
- defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, null, true);
4780
- defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, null, true);
4833
+ function createWatcher (
4834
+ vm,
4835
+ expOrFn,
4836
+ handler,
4837
+ options
4838
+ ) {
4839
+ if (isPlainObject(handler)) {
4840
+ options = handler;
4841
+ handler = handler.handler;
4842
+ }
4843
+ if (typeof handler === 'string') {
4844
+ handler = vm[handler];
4781
4845
  }
4846
+ return vm.$watch(expOrFn, handler, options)
4782
4847
  }
4783
4848
 
4784
- function renderMixin (Vue) {
4785
- // install runtime convenience helpers
4786
- installRenderHelpers(Vue.prototype);
4849
+ function stateMixin (Vue) {
4850
+ // flow somehow has problems with directly declared definition object
4851
+ // when using Object.defineProperty, so we have to procedurally build up
4852
+ // the object here.
4853
+ var dataDef = {};
4854
+ dataDef.get = function () { return this._data };
4855
+ var propsDef = {};
4856
+ propsDef.get = function () { return this._props };
4857
+ if (process.env.NODE_ENV !== 'production') {
4858
+ dataDef.set = function () {
4859
+ warn(
4860
+ 'Avoid replacing instance root $data. ' +
4861
+ 'Use nested data properties instead.',
4862
+ this
4863
+ );
4864
+ };
4865
+ propsDef.set = function () {
4866
+ warn("$props is readonly.", this);
4867
+ };
4868
+ }
4869
+ Object.defineProperty(Vue.prototype, '$data', dataDef);
4870
+ Object.defineProperty(Vue.prototype, '$props', propsDef);
4787
4871
 
4788
- Vue.prototype.$nextTick = function (fn) {
4789
- return nextTick(fn, this)
4790
- };
4872
+ Vue.prototype.$set = set;
4873
+ Vue.prototype.$delete = del;
4791
4874
 
4792
- Vue.prototype._render = function () {
4875
+ Vue.prototype.$watch = function (
4876
+ expOrFn,
4877
+ cb,
4878
+ options
4879
+ ) {
4793
4880
  var vm = this;
4794
- var ref = vm.$options;
4795
- var render = ref.render;
4796
- var _parentVnode = ref._parentVnode;
4797
-
4798
- if (_parentVnode) {
4799
- vm.$scopedSlots = normalizeScopedSlots(
4800
- _parentVnode.data.scopedSlots,
4801
- vm.$slots
4802
- );
4881
+ if (isPlainObject(cb)) {
4882
+ return createWatcher(vm, expOrFn, cb, options)
4803
4883
  }
4804
-
4805
- // set parent vnode. this allows render functions to have access
4806
- // to the data on the placeholder node.
4807
- vm.$vnode = _parentVnode;
4808
- // render self
4809
- var vnode;
4810
- try {
4811
- vnode = render.call(vm._renderProxy, vm.$createElement);
4812
- } catch (e) {
4813
- handleError(e, vm, "render");
4814
- // return error render result,
4815
- // or previous vnode to prevent render error causing blank component
4816
- /* istanbul ignore else */
4817
- if (process.env.NODE_ENV !== 'production' && vm.$options.renderError) {
4818
- try {
4819
- vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
4820
- } catch (e) {
4821
- handleError(e, vm, "renderError");
4822
- vnode = vm._vnode;
4823
- }
4824
- } else {
4825
- vnode = vm._vnode;
4884
+ options = options || {};
4885
+ options.user = true;
4886
+ var watcher = new Watcher(vm, expOrFn, cb, options);
4887
+ if (options.immediate) {
4888
+ try {
4889
+ cb.call(vm, watcher.value);
4890
+ } catch (error) {
4891
+ handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
4826
4892
  }
4827
4893
  }
4828
- // if the returned array contains only a single node, allow it
4829
- if (Array.isArray(vnode) && vnode.length === 1) {
4830
- vnode = vnode[0];
4831
- }
4832
- // return empty vnode in case the render function errored out
4833
- if (!(vnode instanceof VNode)) {
4834
- if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
4835
- warn(
4836
- 'Multiple root nodes returned from render function. Render function ' +
4837
- 'should return a single root node.',
4838
- vm
4839
- );
4840
- }
4841
- vnode = createEmptyVNode();
4894
+ return function unwatchFn () {
4895
+ watcher.teardown();
4842
4896
  }
4843
- // set parent
4844
- vnode.parent = _parentVnode;
4845
- return vnode
4846
4897
  };
4847
4898
  }
4848
4899
 
@@ -5339,7 +5390,7 @@ Object.defineProperty(Vue, 'FunctionalRenderContext', {
5339
5390
  value: FunctionalRenderContext
5340
5391
  });
5341
5392
 
5342
- Vue.version = '2.6.2';
5393
+ Vue.version = '2.6.6';
5343
5394
 
5344
5395
  /* */
5345
5396
 
@@ -6766,6 +6817,11 @@ function createOnceHandler$1 (event, handler, capture) {
6766
6817
  }
6767
6818
  }
6768
6819
 
6820
+ // #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
6821
+ // implementation and does not fire microtasks in between event propagation, so
6822
+ // safe to exclude.
6823
+ var useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53);
6824
+
6769
6825
  function add$1 (
6770
6826
  name,
6771
6827
  handler,
@@ -6778,11 +6834,24 @@ function add$1 (
6778
6834
  // the solution is simple: we save the timestamp when a handler is attached,
6779
6835
  // and the handler would only fire if the event passed to it was fired
6780
6836
  // AFTER it was attached.
6781
- if (isUsingMicroTask) {
6837
+ if (useMicrotaskFix) {
6782
6838
  var attachedTimestamp = currentFlushTimestamp;
6783
6839
  var original = handler;
6784
6840
  handler = original._wrapper = function (e) {
6785
- if (e.timeStamp >= attachedTimestamp) {
6841
+ if (
6842
+ // no bubbling, should always fire.
6843
+ // this is just a safety net in case event.timeStamp is unreliable in
6844
+ // certain weird environments...
6845
+ e.target === e.currentTarget ||
6846
+ // event is fired after handler attachment
6847
+ e.timeStamp >= attachedTimestamp ||
6848
+ // #9462 bail for iOS 9 bug: event.timeStamp is 0 after history.pushState
6849
+ e.timeStamp === 0 ||
6850
+ // #9448 bail if event is fired in another document in a multi-page
6851
+ // electron/nw.js app, since event.timeStamp will be using a different
6852
+ // starting reference
6853
+ e.target.ownerDocument !== document
6854
+ ) {
6786
6855
  return original.apply(this, arguments)
6787
6856
  }
6788
6857
  };