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