vue 2.7.7 → 2.7.10

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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/dist/vue.common.dev.js +105 -49
  3. package/dist/vue.common.prod.js +3 -3
  4. package/dist/vue.esm.browser.js +103 -48
  5. package/dist/vue.esm.browser.min.js +3 -3
  6. package/dist/vue.esm.js +104 -48
  7. package/dist/vue.js +106 -49
  8. package/dist/vue.min.js +3 -3
  9. package/dist/vue.runtime.common.dev.js +81 -42
  10. package/dist/vue.runtime.common.prod.js +3 -3
  11. package/dist/vue.runtime.esm.js +80 -41
  12. package/dist/vue.runtime.js +82 -42
  13. package/dist/vue.runtime.min.js +3 -3
  14. package/package.json +2 -2
  15. package/packages/compiler-sfc/dist/compiler-sfc.js +55 -26
  16. package/packages/compiler-sfc/package.json +2 -3
  17. package/packages/compiler-sfc/src/compileTemplate.ts +1 -2
  18. package/packages/compiler-sfc/src/parseComponent.ts +2 -2
  19. package/packages/compiler-sfc/src/rewriteDefault.ts +6 -1
  20. package/packages/compiler-sfc/src/templateCompilerModules/utils.ts +8 -3
  21. package/packages/compiler-sfc/test/rewriteDefault.spec.ts +245 -0
  22. package/src/compiler/codegen/index.ts +28 -8
  23. package/src/core/instance/init.ts +1 -0
  24. package/src/core/instance/lifecycle.ts +27 -12
  25. package/src/core/instance/proxy.ts +2 -2
  26. package/src/core/instance/state.ts +1 -1
  27. package/src/core/observer/index.ts +1 -1
  28. package/src/core/observer/watcher.ts +12 -5
  29. package/src/core/vdom/modules/directives.ts +9 -1
  30. package/src/core/vdom/vnode.ts +1 -0
  31. package/src/types/component.ts +1 -0
  32. package/src/v3/apiLifecycle.ts +16 -1
  33. package/src/v3/apiSetup.ts +38 -17
  34. package/src/v3/apiWatch.ts +1 -4
  35. package/src/v3/index.ts +1 -1
  36. package/src/v3/reactivity/effectScope.ts +5 -1
  37. package/types/index.d.ts +2 -2
  38. package/types/options.d.ts +24 -9
  39. package/types/v3-component-options.d.ts +3 -0
  40. package/types/v3-component-public-instance.d.ts +2 -4
  41. package/types/v3-define-component.d.ts +34 -34
  42. package/types/v3-generated.d.ts +11 -2
  43. package/types/v3-manual-apis.d.ts +2 -2
  44. package/types/v3-setup-context.d.ts +4 -0
  45. package/types/vue.d.ts +108 -31
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.7.7
2
+ * Vue.js v2.7.10
3
3
  * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -920,7 +920,7 @@ function defineReactive(obj, key, val, customSetter, shallow, mock) {
920
920
  // #7981: for accessor properties without setter
921
921
  return;
922
922
  }
923
- else if (isRef(value) && !isRef(newVal)) {
923
+ else if (!shallow && isRef(value) && !isRef(newVal)) {
924
924
  value.value = newVal;
925
925
  return;
926
926
  }
@@ -1523,8 +1523,7 @@ function doWatch(source, cb, _a) {
1523
1523
  var oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
1524
1524
  // overwrite default run
1525
1525
  watcher.run = function () {
1526
- if (!watcher.active &&
1527
- !(flush === 'pre' && instance && instance._isBeingDestroyed)) {
1526
+ if (!watcher.active) {
1528
1527
  return;
1529
1528
  }
1530
1529
  if (cb) {
@@ -2453,7 +2452,19 @@ function createSetupContext(vm) {
2453
2452
  var exposeCalled = false;
2454
2453
  return {
2455
2454
  get attrs() {
2456
- return initAttrsProxy(vm);
2455
+ if (!vm._attrsProxy) {
2456
+ var proxy = (vm._attrsProxy = {});
2457
+ def(proxy, '_v_attr_proxy', true);
2458
+ syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
2459
+ }
2460
+ return vm._attrsProxy;
2461
+ },
2462
+ get listeners() {
2463
+ if (!vm._listenersProxy) {
2464
+ var proxy = (vm._listenersProxy = {});
2465
+ syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
2466
+ }
2467
+ return vm._listenersProxy;
2457
2468
  },
2458
2469
  get slots() {
2459
2470
  return initSlotsProxy(vm);
@@ -2474,20 +2485,12 @@ function createSetupContext(vm) {
2474
2485
  }
2475
2486
  };
2476
2487
  }
2477
- function initAttrsProxy(vm) {
2478
- if (!vm._attrsProxy) {
2479
- var proxy = (vm._attrsProxy = {});
2480
- def(proxy, '_v_attr_proxy', true);
2481
- syncSetupAttrs(proxy, vm.$attrs, emptyObject, vm);
2482
- }
2483
- return vm._attrsProxy;
2484
- }
2485
- function syncSetupAttrs(to, from, prev, instance) {
2488
+ function syncSetupProxy(to, from, prev, instance, type) {
2486
2489
  var changed = false;
2487
2490
  for (var key in from) {
2488
2491
  if (!(key in to)) {
2489
2492
  changed = true;
2490
- defineProxyAttr(to, key, instance);
2493
+ defineProxyAttr(to, key, instance, type);
2491
2494
  }
2492
2495
  else if (from[key] !== prev[key]) {
2493
2496
  changed = true;
@@ -2501,12 +2504,12 @@ function syncSetupAttrs(to, from, prev, instance) {
2501
2504
  }
2502
2505
  return changed;
2503
2506
  }
2504
- function defineProxyAttr(proxy, key, instance) {
2507
+ function defineProxyAttr(proxy, key, instance, type) {
2505
2508
  Object.defineProperty(proxy, key, {
2506
2509
  enumerable: true,
2507
2510
  configurable: true,
2508
2511
  get: function () {
2509
- return instance.$attrs[key];
2512
+ return instance[type][key];
2510
2513
  }
2511
2514
  });
2512
2515
  }
@@ -2527,17 +2530,27 @@ function syncSetupSlots(to, from) {
2527
2530
  }
2528
2531
  }
2529
2532
  /**
2530
- * @internal use manual type def
2533
+ * @internal use manual type def because public setup context type relies on
2534
+ * legacy VNode types
2531
2535
  */
2532
2536
  function useSlots() {
2533
2537
  return getContext().slots;
2534
2538
  }
2535
2539
  /**
2536
- * @internal use manual type def
2540
+ * @internal use manual type def because public setup context type relies on
2541
+ * legacy VNode types
2537
2542
  */
2538
2543
  function useAttrs() {
2539
2544
  return getContext().attrs;
2540
2545
  }
2546
+ /**
2547
+ * Vue 2 only
2548
+ * @internal use manual type def because public setup context type relies on
2549
+ * legacy VNode types
2550
+ */
2551
+ function useListeners() {
2552
+ return getContext().listeners;
2553
+ }
2541
2554
  function getContext() {
2542
2555
  if (process.env.NODE_ENV !== 'production' && !currentInstance) {
2543
2556
  warn("useContext() called without active instance.");
@@ -3266,17 +3279,21 @@ var onBeforeUpdate = createLifeCycle('beforeUpdate');
3266
3279
  var onUpdated = createLifeCycle('updated');
3267
3280
  var onBeforeUnmount = createLifeCycle('beforeDestroy');
3268
3281
  var onUnmounted = createLifeCycle('destroyed');
3269
- var onErrorCaptured = createLifeCycle('errorCaptured');
3270
3282
  var onActivated = createLifeCycle('activated');
3271
3283
  var onDeactivated = createLifeCycle('deactivated');
3272
3284
  var onServerPrefetch = createLifeCycle('serverPrefetch');
3273
3285
  var onRenderTracked = createLifeCycle('renderTracked');
3274
- var onRenderTriggered = createLifeCycle('renderTriggered');
3286
+ var onRenderTriggered = createLifeCycle('renderTriggered');
3287
+ var injectErrorCapturedHook = createLifeCycle('errorCaptured');
3288
+ function onErrorCaptured(hook, target) {
3289
+ if (target === void 0) { target = currentInstance; }
3290
+ injectErrorCapturedHook(hook, target);
3291
+ }
3275
3292
 
3276
3293
  /**
3277
3294
  * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
3278
3295
  */
3279
- var version = '2.7.7';
3296
+ var version = '2.7.10';
3280
3297
  /**
3281
3298
  * @internal type is manually declared in <root>/types/v3-define-component.d.ts
3282
3299
  */
@@ -3335,11 +3352,16 @@ var uid$1 = 0;
3335
3352
  */
3336
3353
  var Watcher = /** @class */ (function () {
3337
3354
  function Watcher(vm, expOrFn, cb, options, isRenderWatcher) {
3338
- recordEffectScope(this, activeEffectScope || (vm ? vm._scope : undefined));
3339
- if ((this.vm = vm)) {
3340
- if (isRenderWatcher) {
3341
- vm._watcher = this;
3342
- }
3355
+ recordEffectScope(this,
3356
+ // if the active effect scope is manually created (not a component scope),
3357
+ // prioritize it
3358
+ activeEffectScope && !activeEffectScope._vm
3359
+ ? activeEffectScope
3360
+ : vm
3361
+ ? vm._scope
3362
+ : undefined);
3363
+ if ((this.vm = vm) && isRenderWatcher) {
3364
+ vm._watcher = this;
3343
3365
  }
3344
3366
  // options
3345
3367
  if (options) {
@@ -3724,8 +3746,13 @@ function lifecycleMixin(Vue) {
3724
3746
  vm.$el.__vue__ = vm;
3725
3747
  }
3726
3748
  // if parent is an HOC, update its $el as well
3727
- if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
3728
- vm.$parent.$el = vm.$el;
3749
+ var wrapper = vm;
3750
+ while (wrapper &&
3751
+ wrapper.$vnode &&
3752
+ wrapper.$parent &&
3753
+ wrapper.$vnode === wrapper.$parent._vnode) {
3754
+ wrapper.$parent.$el = wrapper.$el;
3755
+ wrapper = wrapper.$parent;
3729
3756
  }
3730
3757
  // updated hook is called by the scheduler to ensure that children are
3731
3758
  // updated in a parent's updated hook.
@@ -3884,12 +3911,19 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
3884
3911
  if (vm._attrsProxy) {
3885
3912
  // force update if attrs are accessed and has changed since it may be
3886
3913
  // passed to a child component.
3887
- if (syncSetupAttrs(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm)) {
3914
+ if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
3888
3915
  needsForceUpdate = true;
3889
3916
  }
3890
3917
  }
3891
3918
  vm.$attrs = attrs;
3892
- vm.$listeners = listeners || emptyObject;
3919
+ // update listeners
3920
+ listeners = listeners || emptyObject;
3921
+ var prevListeners = vm.$options._parentListeners;
3922
+ if (vm._listenersProxy) {
3923
+ syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
3924
+ }
3925
+ vm.$listeners = vm.$options._parentListeners = listeners;
3926
+ updateComponentListeners(vm, listeners, prevListeners);
3893
3927
  // update props
3894
3928
  if (propsData && vm.$options.props) {
3895
3929
  toggleObserving(false);
@@ -3904,11 +3938,6 @@ function updateChildComponent(vm, propsData, listeners, parentVnode, renderChild
3904
3938
  // keep a copy of raw propsData
3905
3939
  vm.$options.propsData = propsData;
3906
3940
  }
3907
- // update listeners
3908
- listeners = listeners || emptyObject;
3909
- var oldListeners = vm.$options._parentListeners;
3910
- vm.$options._parentListeners = listeners;
3911
- updateComponentListeners(vm, listeners, oldListeners);
3912
3941
  // resolve slots + force update if has children
3913
3942
  if (needsForceUpdate) {
3914
3943
  vm.$slots = resolveSlots(renderChildren, parentVnode.context);
@@ -5204,13 +5233,13 @@ if (process.env.NODE_ENV !== 'production') {
5204
5233
  'referenced during render. Make sure that this property is reactive, ' +
5205
5234
  'either in the data option, or for class-based components, by ' +
5206
5235
  'initializing the property. ' +
5207
- 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
5236
+ 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
5208
5237
  };
5209
5238
  var warnReservedPrefix_1 = function (target, key) {
5210
5239
  warn("Property \"".concat(key, "\" must be accessed with \"$data.").concat(key, "\" because ") +
5211
5240
  'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
5212
5241
  'prevent conflicts with Vue internals. ' +
5213
- 'See: https://vuejs.org/v2/api/#data', target);
5242
+ 'See: https://v2.vuejs.org/v2/api/#data', target);
5214
5243
  };
5215
5244
  var hasProxy_1 = typeof Proxy !== 'undefined' && isNative(Proxy);
5216
5245
  if (hasProxy_1) {
@@ -5356,7 +5385,7 @@ function initData(vm) {
5356
5385
  data = {};
5357
5386
  process.env.NODE_ENV !== 'production' &&
5358
5387
  warn('data functions should return an object:\n' +
5359
- 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
5388
+ 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
5360
5389
  }
5361
5390
  // proxy data on instance
5362
5391
  var keys = Object.keys(data);
@@ -5589,6 +5618,7 @@ function initMixin$1(Vue) {
5589
5618
  vm.__v_skip = true;
5590
5619
  // effect scope
5591
5620
  vm._scope = new EffectScope(true /* detached */);
5621
+ vm._scope._vm = true;
5592
5622
  // merge options
5593
5623
  if (options && options._isComponent) {
5594
5624
  // optimize internal component instantiation
@@ -7166,7 +7196,16 @@ function normalizeDirectives(dirs, vm) {
7166
7196
  }
7167
7197
  res[getRawDirName(dir)] = dir;
7168
7198
  if (vm._setupState && vm._setupState.__sfc) {
7169
- dir.def = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
7199
+ var setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
7200
+ if (typeof setupDef === 'function') {
7201
+ dir.def = {
7202
+ bind: setupDef,
7203
+ update: setupDef,
7204
+ };
7205
+ }
7206
+ else {
7207
+ dir.def = setupDef;
7208
+ }
7170
7209
  }
7171
7210
  dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
7172
7211
  }
@@ -8713,4 +8752,4 @@ if (inBrowser) {
8713
8752
  }, 0);
8714
8753
  }
8715
8754
 
8716
- export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };
8755
+ export { EffectScope, computed, customRef, Vue as default, defineAsyncComponent, defineComponent, del, effectScope, getCurrentInstance, getCurrentScope, h, inject, isProxy, isReactive, isReadonly, isRef, isShallow, markRaw, mergeDefaults, nextTick, onActivated, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onDeactivated, onErrorCaptured, onMounted, onRenderTracked, onRenderTriggered, onScopeDispose, onServerPrefetch, onUnmounted, onUpdated, provide, proxyRefs, reactive, readonly, ref$1 as ref, set, shallowReactive, shallowReadonly, shallowRef, toRaw, toRef, toRefs, triggerRef, unref, useAttrs, useCssModule, useCssVars, useListeners, useSlots, version, watch, watchEffect, watchPostEffect, watchSyncEffect };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.7.7
2
+ * Vue.js v2.7.10
3
3
  * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -920,7 +920,7 @@
920
920
  // #7981: for accessor properties without setter
921
921
  return;
922
922
  }
923
- else if (isRef(value) && !isRef(newVal)) {
923
+ else if (!shallow && isRef(value) && !isRef(newVal)) {
924
924
  value.value = newVal;
925
925
  return;
926
926
  }
@@ -1498,8 +1498,7 @@
1498
1498
  var oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
1499
1499
  // overwrite default run
1500
1500
  watcher.run = function () {
1501
- if (!watcher.active &&
1502
- !(flush === 'pre' && instance && instance._isBeingDestroyed)) {
1501
+ if (!watcher.active) {
1503
1502
  return;
1504
1503
  }
1505
1504
  if (cb) {
@@ -2426,7 +2425,19 @@
2426
2425
  var exposeCalled = false;
2427
2426
  return {
2428
2427
  get attrs() {
2429
- return initAttrsProxy(vm);
2428
+ if (!vm._attrsProxy) {
2429
+ var proxy = (vm._attrsProxy = {});
2430
+ def(proxy, '_v_attr_proxy', true);
2431
+ syncSetupProxy(proxy, vm.$attrs, emptyObject, vm, '$attrs');
2432
+ }
2433
+ return vm._attrsProxy;
2434
+ },
2435
+ get listeners() {
2436
+ if (!vm._listenersProxy) {
2437
+ var proxy = (vm._listenersProxy = {});
2438
+ syncSetupProxy(proxy, vm.$listeners, emptyObject, vm, '$listeners');
2439
+ }
2440
+ return vm._listenersProxy;
2430
2441
  },
2431
2442
  get slots() {
2432
2443
  return initSlotsProxy(vm);
@@ -2447,20 +2458,12 @@
2447
2458
  }
2448
2459
  };
2449
2460
  }
2450
- function initAttrsProxy(vm) {
2451
- if (!vm._attrsProxy) {
2452
- var proxy = (vm._attrsProxy = {});
2453
- def(proxy, '_v_attr_proxy', true);
2454
- syncSetupAttrs(proxy, vm.$attrs, emptyObject, vm);
2455
- }
2456
- return vm._attrsProxy;
2457
- }
2458
- function syncSetupAttrs(to, from, prev, instance) {
2461
+ function syncSetupProxy(to, from, prev, instance, type) {
2459
2462
  var changed = false;
2460
2463
  for (var key in from) {
2461
2464
  if (!(key in to)) {
2462
2465
  changed = true;
2463
- defineProxyAttr(to, key, instance);
2466
+ defineProxyAttr(to, key, instance, type);
2464
2467
  }
2465
2468
  else if (from[key] !== prev[key]) {
2466
2469
  changed = true;
@@ -2474,12 +2477,12 @@
2474
2477
  }
2475
2478
  return changed;
2476
2479
  }
2477
- function defineProxyAttr(proxy, key, instance) {
2480
+ function defineProxyAttr(proxy, key, instance, type) {
2478
2481
  Object.defineProperty(proxy, key, {
2479
2482
  enumerable: true,
2480
2483
  configurable: true,
2481
2484
  get: function () {
2482
- return instance.$attrs[key];
2485
+ return instance[type][key];
2483
2486
  }
2484
2487
  });
2485
2488
  }
@@ -2500,17 +2503,27 @@
2500
2503
  }
2501
2504
  }
2502
2505
  /**
2503
- * @internal use manual type def
2506
+ * @internal use manual type def because public setup context type relies on
2507
+ * legacy VNode types
2504
2508
  */
2505
2509
  function useSlots() {
2506
2510
  return getContext().slots;
2507
2511
  }
2508
2512
  /**
2509
- * @internal use manual type def
2513
+ * @internal use manual type def because public setup context type relies on
2514
+ * legacy VNode types
2510
2515
  */
2511
2516
  function useAttrs() {
2512
2517
  return getContext().attrs;
2513
2518
  }
2519
+ /**
2520
+ * Vue 2 only
2521
+ * @internal use manual type def because public setup context type relies on
2522
+ * legacy VNode types
2523
+ */
2524
+ function useListeners() {
2525
+ return getContext().listeners;
2526
+ }
2514
2527
  function getContext() {
2515
2528
  if (!currentInstance) {
2516
2529
  warn("useContext() called without active instance.");
@@ -3221,17 +3234,21 @@
3221
3234
  var onUpdated = createLifeCycle('updated');
3222
3235
  var onBeforeUnmount = createLifeCycle('beforeDestroy');
3223
3236
  var onUnmounted = createLifeCycle('destroyed');
3224
- var onErrorCaptured = createLifeCycle('errorCaptured');
3225
3237
  var onActivated = createLifeCycle('activated');
3226
3238
  var onDeactivated = createLifeCycle('deactivated');
3227
3239
  var onServerPrefetch = createLifeCycle('serverPrefetch');
3228
3240
  var onRenderTracked = createLifeCycle('renderTracked');
3229
- var onRenderTriggered = createLifeCycle('renderTriggered');
3241
+ var onRenderTriggered = createLifeCycle('renderTriggered');
3242
+ var injectErrorCapturedHook = createLifeCycle('errorCaptured');
3243
+ function onErrorCaptured(hook, target) {
3244
+ if (target === void 0) { target = currentInstance; }
3245
+ injectErrorCapturedHook(hook, target);
3246
+ }
3230
3247
 
3231
3248
  /**
3232
3249
  * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
3233
3250
  */
3234
- var version = '2.7.7';
3251
+ var version = '2.7.10';
3235
3252
  /**
3236
3253
  * @internal type is manually declared in <root>/types/v3-define-component.d.ts
3237
3254
  */
@@ -3277,6 +3294,7 @@
3277
3294
  getCurrentInstance: getCurrentInstance,
3278
3295
  useSlots: useSlots,
3279
3296
  useAttrs: useAttrs,
3297
+ useListeners: useListeners,
3280
3298
  mergeDefaults: mergeDefaults,
3281
3299
  nextTick: nextTick,
3282
3300
  set: set,
@@ -3290,12 +3308,12 @@
3290
3308
  onUpdated: onUpdated,
3291
3309
  onBeforeUnmount: onBeforeUnmount,
3292
3310
  onUnmounted: onUnmounted,
3293
- onErrorCaptured: onErrorCaptured,
3294
3311
  onActivated: onActivated,
3295
3312
  onDeactivated: onDeactivated,
3296
3313
  onServerPrefetch: onServerPrefetch,
3297
3314
  onRenderTracked: onRenderTracked,
3298
- onRenderTriggered: onRenderTriggered
3315
+ onRenderTriggered: onRenderTriggered,
3316
+ onErrorCaptured: onErrorCaptured
3299
3317
  });
3300
3318
 
3301
3319
  var seenObjects = new _Set();
@@ -3349,11 +3367,16 @@
3349
3367
  */
3350
3368
  var Watcher = /** @class */ (function () {
3351
3369
  function Watcher(vm, expOrFn, cb, options, isRenderWatcher) {
3352
- recordEffectScope(this, activeEffectScope || (vm ? vm._scope : undefined));
3353
- if ((this.vm = vm)) {
3354
- if (isRenderWatcher) {
3355
- vm._watcher = this;
3356
- }
3370
+ recordEffectScope(this,
3371
+ // if the active effect scope is manually created (not a component scope),
3372
+ // prioritize it
3373
+ activeEffectScope && !activeEffectScope._vm
3374
+ ? activeEffectScope
3375
+ : vm
3376
+ ? vm._scope
3377
+ : undefined);
3378
+ if ((this.vm = vm) && isRenderWatcher) {
3379
+ vm._watcher = this;
3357
3380
  }
3358
3381
  // options
3359
3382
  if (options) {
@@ -3737,8 +3760,13 @@
3737
3760
  vm.$el.__vue__ = vm;
3738
3761
  }
3739
3762
  // if parent is an HOC, update its $el as well
3740
- if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
3741
- vm.$parent.$el = vm.$el;
3763
+ var wrapper = vm;
3764
+ while (wrapper &&
3765
+ wrapper.$vnode &&
3766
+ wrapper.$parent &&
3767
+ wrapper.$vnode === wrapper.$parent._vnode) {
3768
+ wrapper.$parent.$el = wrapper.$el;
3769
+ wrapper = wrapper.$parent;
3742
3770
  }
3743
3771
  // updated hook is called by the scheduler to ensure that children are
3744
3772
  // updated in a parent's updated hook.
@@ -3897,12 +3925,19 @@
3897
3925
  if (vm._attrsProxy) {
3898
3926
  // force update if attrs are accessed and has changed since it may be
3899
3927
  // passed to a child component.
3900
- if (syncSetupAttrs(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm)) {
3928
+ if (syncSetupProxy(vm._attrsProxy, attrs, (prevVNode.data && prevVNode.data.attrs) || emptyObject, vm, '$attrs')) {
3901
3929
  needsForceUpdate = true;
3902
3930
  }
3903
3931
  }
3904
3932
  vm.$attrs = attrs;
3905
- vm.$listeners = listeners || emptyObject;
3933
+ // update listeners
3934
+ listeners = listeners || emptyObject;
3935
+ var prevListeners = vm.$options._parentListeners;
3936
+ if (vm._listenersProxy) {
3937
+ syncSetupProxy(vm._listenersProxy, listeners, prevListeners || emptyObject, vm, '$listeners');
3938
+ }
3939
+ vm.$listeners = vm.$options._parentListeners = listeners;
3940
+ updateComponentListeners(vm, listeners, prevListeners);
3906
3941
  // update props
3907
3942
  if (propsData && vm.$options.props) {
3908
3943
  toggleObserving(false);
@@ -3917,11 +3952,6 @@
3917
3952
  // keep a copy of raw propsData
3918
3953
  vm.$options.propsData = propsData;
3919
3954
  }
3920
- // update listeners
3921
- listeners = listeners || emptyObject;
3922
- var oldListeners = vm.$options._parentListeners;
3923
- vm.$options._parentListeners = listeners;
3924
- updateComponentListeners(vm, listeners, oldListeners);
3925
3955
  // resolve slots + force update if has children
3926
3956
  if (needsForceUpdate) {
3927
3957
  vm.$slots = resolveSlots(renderChildren, parentVnode.context);
@@ -5213,13 +5243,13 @@
5213
5243
  'referenced during render. Make sure that this property is reactive, ' +
5214
5244
  'either in the data option, or for class-based components, by ' +
5215
5245
  'initializing the property. ' +
5216
- 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
5246
+ 'See: https://v2.vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.', target);
5217
5247
  };
5218
5248
  var warnReservedPrefix_1 = function (target, key) {
5219
5249
  warn("Property \"".concat(key, "\" must be accessed with \"$data.").concat(key, "\" because ") +
5220
5250
  'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
5221
5251
  'prevent conflicts with Vue internals. ' +
5222
- 'See: https://vuejs.org/v2/api/#data', target);
5252
+ 'See: https://v2.vuejs.org/v2/api/#data', target);
5223
5253
  };
5224
5254
  var hasProxy_1 = typeof Proxy !== 'undefined' && isNative(Proxy);
5225
5255
  if (hasProxy_1) {
@@ -5361,7 +5391,7 @@
5361
5391
  if (!isPlainObject(data)) {
5362
5392
  data = {};
5363
5393
  warn('data functions should return an object:\n' +
5364
- 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
5394
+ 'https://v2.vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm);
5365
5395
  }
5366
5396
  // proxy data on instance
5367
5397
  var keys = Object.keys(data);
@@ -5593,6 +5623,7 @@
5593
5623
  vm.__v_skip = true;
5594
5624
  // effect scope
5595
5625
  vm._scope = new EffectScope(true /* detached */);
5626
+ vm._scope._vm = true;
5596
5627
  // merge options
5597
5628
  if (options && options._isComponent) {
5598
5629
  // optimize internal component instantiation
@@ -7165,7 +7196,16 @@
7165
7196
  }
7166
7197
  res[getRawDirName(dir)] = dir;
7167
7198
  if (vm._setupState && vm._setupState.__sfc) {
7168
- dir.def = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
7199
+ var setupDef = dir.def || resolveAsset(vm, '_setupState', 'v-' + dir.name);
7200
+ if (typeof setupDef === 'function') {
7201
+ dir.def = {
7202
+ bind: setupDef,
7203
+ update: setupDef,
7204
+ };
7205
+ }
7206
+ else {
7207
+ dir.def = setupDef;
7208
+ }
7169
7209
  }
7170
7210
  dir.def = dir.def || resolveAsset(vm.$options, 'directives', dir.name, true);
7171
7211
  }