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