vue 3.4.6 → 3.4.7

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.
@@ -3510,14 +3510,9 @@ function instanceWatch(source, value, options) {
3510
3510
  cb = value.handler;
3511
3511
  options = value;
3512
3512
  }
3513
- const cur = currentInstance;
3514
- setCurrentInstance(this);
3513
+ const reset = setCurrentInstance(this);
3515
3514
  const res = doWatch(getter, cb.bind(publicThis), options);
3516
- if (cur) {
3517
- setCurrentInstance(cur);
3518
- } else {
3519
- unsetCurrentInstance();
3520
- }
3515
+ reset();
3521
3516
  return res;
3522
3517
  }
3523
3518
  function createPathGetter(ctx, path) {
@@ -3569,12 +3564,11 @@ function validateDirectiveName(name) {
3569
3564
  }
3570
3565
  }
3571
3566
  function withDirectives(vnode, directives) {
3572
- const internalInstance = currentRenderingInstance;
3573
- if (internalInstance === null) {
3567
+ if (currentRenderingInstance === null) {
3574
3568
  warn$1(`withDirectives can only be used inside render functions.`);
3575
3569
  return vnode;
3576
3570
  }
3577
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
3571
+ const instance = getExposeProxy(currentRenderingInstance) || currentRenderingInstance.proxy;
3578
3572
  const bindings = vnode.dirs || (vnode.dirs = []);
3579
3573
  for (let i = 0; i < directives.length; i++) {
3580
3574
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -4354,9 +4348,9 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4354
4348
  return;
4355
4349
  }
4356
4350
  pauseTracking();
4357
- setCurrentInstance(target);
4351
+ const reset = setCurrentInstance(target);
4358
4352
  const res = callWithAsyncErrorHandling(hook, target, type, args);
4359
- unsetCurrentInstance();
4353
+ reset();
4360
4354
  resetTracking();
4361
4355
  return res;
4362
4356
  });
@@ -5741,12 +5735,12 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
5741
5735
  if (key in propsDefaults) {
5742
5736
  value = propsDefaults[key];
5743
5737
  } else {
5744
- setCurrentInstance(instance);
5738
+ const reset = setCurrentInstance(instance);
5745
5739
  value = propsDefaults[key] = defaultValue.call(
5746
5740
  null,
5747
5741
  props
5748
5742
  );
5749
- unsetCurrentInstance();
5743
+ reset();
5750
5744
  }
5751
5745
  } else {
5752
5746
  value = defaultValue;
@@ -8993,14 +8987,7 @@ function createComponentInstance(vnode, parent, suspense) {
8993
8987
  return instance;
8994
8988
  }
8995
8989
  let currentInstance = null;
8996
- const getCurrentInstance = () => {
8997
- if (isInComputedGetter) {
8998
- warn$1(
8999
- `getCurrentInstance() called inside a computed getter. This is incorrect usage as computed getters are not guaranteed to be executed with an active component instance. If you are using a composable inside a computed getter, move it ouside to the setup scope.`
9000
- );
9001
- }
9002
- return currentInstance || currentRenderingInstance;
9003
- };
8990
+ const getCurrentInstance = () => currentInstance || currentRenderingInstance;
9004
8991
  let internalSetCurrentInstance;
9005
8992
  let setInSSRSetupState;
9006
8993
  {
@@ -9012,8 +8999,13 @@ let setInSSRSetupState;
9012
8999
  };
9013
9000
  }
9014
9001
  const setCurrentInstance = (instance) => {
9002
+ const prev = currentInstance;
9015
9003
  internalSetCurrentInstance(instance);
9016
9004
  instance.scope.on();
9005
+ return () => {
9006
+ instance.scope.off();
9007
+ internalSetCurrentInstance(prev);
9008
+ };
9017
9009
  };
9018
9010
  const unsetCurrentInstance = () => {
9019
9011
  currentInstance && currentInstance.scope.off();
@@ -9075,7 +9067,7 @@ function setupStatefulComponent(instance, isSSR) {
9075
9067
  const { setup } = Component;
9076
9068
  if (setup) {
9077
9069
  const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
9078
- setCurrentInstance(instance);
9070
+ const reset = setCurrentInstance(instance);
9079
9071
  pauseTracking();
9080
9072
  const setupResult = callWithErrorHandling(
9081
9073
  setup,
@@ -9087,7 +9079,7 @@ function setupStatefulComponent(instance, isSSR) {
9087
9079
  ]
9088
9080
  );
9089
9081
  resetTracking();
9090
- unsetCurrentInstance();
9082
+ reset();
9091
9083
  if (isPromise(setupResult)) {
9092
9084
  setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
9093
9085
  if (isSSR) {
@@ -9181,13 +9173,13 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
9181
9173
  }
9182
9174
  }
9183
9175
  {
9184
- setCurrentInstance(instance);
9176
+ const reset = setCurrentInstance(instance);
9185
9177
  pauseTracking();
9186
9178
  try {
9187
9179
  applyOptions(instance);
9188
9180
  } finally {
9189
9181
  resetTracking();
9190
- unsetCurrentInstance();
9182
+ reset();
9191
9183
  }
9192
9184
  }
9193
9185
  if (!Component.render && instance.render === NOOP && !isSSR) {
@@ -9314,25 +9306,7 @@ function isClassComponent(value) {
9314
9306
  return isFunction(value) && "__vccOpts" in value;
9315
9307
  }
9316
9308
 
9317
- let isInComputedGetter = false;
9318
- function wrapComputedGetter(getter) {
9319
- return () => {
9320
- isInComputedGetter = true;
9321
- try {
9322
- return getter();
9323
- } finally {
9324
- isInComputedGetter = false;
9325
- }
9326
- };
9327
- }
9328
9309
  const computed = (getterOrOptions, debugOptions) => {
9329
- {
9330
- if (isFunction(getterOrOptions)) {
9331
- getterOrOptions = wrapComputedGetter(getterOrOptions);
9332
- } else {
9333
- getterOrOptions.get = wrapComputedGetter(getterOrOptions.get);
9334
- }
9335
- }
9336
9310
  return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
9337
9311
  };
9338
9312
 
@@ -9558,7 +9532,7 @@ function isMemoSame(cached, memo) {
9558
9532
  return true;
9559
9533
  }
9560
9534
 
9561
- const version = "3.4.6";
9535
+ const version = "3.4.7";
9562
9536
  const warn = warn$1 ;
9563
9537
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9564
9538
  const devtools = devtools$1 ;
@@ -13630,8 +13604,7 @@ function createTransformContext(root, {
13630
13604
  }
13631
13605
  context.parent.children.splice(removalIndex, 1);
13632
13606
  },
13633
- onNodeRemoved: () => {
13634
- },
13607
+ onNodeRemoved: NOOP,
13635
13608
  addIdentifiers(exp) {
13636
13609
  },
13637
13610
  removeIdentifiers(exp) {