@vue/compat 3.6.0-beta.14 → 3.6.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.6.0-beta.14
2
+ * @vue/compat v3.6.0-beta.16
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -2246,8 +2246,9 @@ var WatcherEffect = class extends ReactiveEffect {
2246
2246
  if (once && cb) {
2247
2247
  const _cb = cb;
2248
2248
  cb = (...args) => {
2249
- _cb(...args);
2249
+ const res = _cb(...args);
2250
2250
  this.stop();
2251
+ return res;
2251
2252
  };
2252
2253
  }
2253
2254
  this.cb = cb;
@@ -2261,7 +2262,7 @@ var WatcherEffect = class extends ReactiveEffect {
2261
2262
  if (!this.cb) return;
2262
2263
  const { immediate, deep, call } = this.options;
2263
2264
  if (initialRun && !immediate) return;
2264
- if (deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2265
+ if (initialRun || deep || this.forceTrigger || (this.isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
2265
2266
  cleanup(this);
2266
2267
  const currentWatcher = activeWatcher;
2267
2268
  activeWatcher = this;
@@ -4669,11 +4670,16 @@ function defineAsyncComponent(source) {
4669
4670
  onError(err);
4670
4671
  return () => errorComponent ? createVNode(errorComponent, { error: err }) : null;
4671
4672
  });
4672
- const { loaded, error, delayed } = useAsyncComponentState(delay, timeout, onError);
4673
+ const { loaded, error, delayed } = useAsyncComponentState(delay, timeout, onError, instance);
4673
4674
  load().then(() => {
4675
+ if (instance.isUnmounted) return;
4674
4676
  loaded.value = true;
4675
4677
  if (instance.parent && instance.parent.vnode && isKeepAlive(instance.parent.vnode)) instance.parent.update();
4676
4678
  }).catch((err) => {
4679
+ if (instance.isUnmounted) {
4680
+ setPendingRequest(null);
4681
+ return;
4682
+ }
4677
4683
  onError(err);
4678
4684
  error.value = err;
4679
4685
  });
@@ -4731,14 +4737,22 @@ function createAsyncComponentContext(source) {
4731
4737
  setPendingRequest: (request) => pendingRequest = request
4732
4738
  };
4733
4739
  }
4734
- const useAsyncComponentState = (delay, timeout, onError) => {
4740
+ const useAsyncComponentState = (delay, timeout, onError, instance = currentInstance) => {
4735
4741
  const loaded = /* @__PURE__ */ ref(false);
4736
4742
  const error = /* @__PURE__ */ ref();
4737
4743
  const delayed = /* @__PURE__ */ ref(!!delay);
4738
- if (delay) setTimeout(() => {
4744
+ let timeoutTimer;
4745
+ let delayTimer;
4746
+ if (instance) onUnmounted(() => {
4747
+ if (timeoutTimer != null) clearTimeout(timeoutTimer);
4748
+ if (delayTimer != null) clearTimeout(delayTimer);
4749
+ }, instance);
4750
+ if (delay) delayTimer = setTimeout(() => {
4751
+ if (instance && instance.isUnmounted) return;
4739
4752
  delayed.value = false;
4740
4753
  }, delay);
4741
- if (timeout != null) setTimeout(() => {
4754
+ if (timeout != null) timeoutTimer = setTimeout(() => {
4755
+ if (instance && instance.isUnmounted) return;
4742
4756
  if (!loaded.value && !error.value) {
4743
4757
  const err = /* @__PURE__ */ new Error(`Async component timed out after ${timeout}ms.`);
4744
4758
  onError(err);
@@ -6293,7 +6307,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6293
6307
  if (options.el) return vm.$mount(options.el);
6294
6308
  else return vm;
6295
6309
  }
6296
- Vue.version = `2.6.14-compat:3.6.0-beta.14`;
6310
+ Vue.version = `2.6.14-compat:3.6.0-beta.16`;
6297
6311
  Vue.config = singletonApp.config;
6298
6312
  Vue.use = (plugin, ...options) => {
6299
6313
  if (plugin && isFunction(plugin.install)) plugin.install(Vue, ...options);
@@ -6548,7 +6562,9 @@ function defineReactive(obj, key, val) {
6548
6562
  else Object.keys(val).forEach((key) => {
6549
6563
  try {
6550
6564
  defineReactiveSimple(val, key, val[key]);
6551
- } catch (e) {}
6565
+ } catch (e) {
6566
+ warn$1(`Failed making property "${key}" reactive:`, e);
6567
+ }
6552
6568
  });
6553
6569
  }
6554
6570
  const i = obj.$;
@@ -6793,12 +6809,13 @@ function useModel(props, name, options = EMPTY_OBJ) {
6793
6809
  for (const key of rawPropKeys) if (key === name || key === camelizedName || key === hyphenatedName) parentPassedModelValue = true;
6794
6810
  else if (key === `onUpdate:${name}` || key === `onUpdate:${camelizedName}` || key === `onUpdate:${hyphenatedName}`) parentPassedModelUpdater = true;
6795
6811
  }
6796
- if (!parentPassedModelValue || !parentPassedModelUpdater) {
6812
+ const hasVModel = parentPassedModelValue && parentPassedModelUpdater;
6813
+ if (!hasVModel) {
6797
6814
  localValue = value;
6798
6815
  trigger();
6799
6816
  }
6800
6817
  i.emit(`update:${name}`, emittedValue);
6801
- if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) trigger();
6818
+ if (hasChanged(value, prevSetValue) && (hasChanged(value, emittedValue) && !hasChanged(emittedValue, prevEmittedValue) || hasVModel && prevSetValue !== EMPTY_OBJ && !hasChanged(emittedValue, localValue))) trigger();
6802
6819
  prevSetValue = value;
6803
6820
  prevEmittedValue = emittedValue;
6804
6821
  }
@@ -9753,7 +9770,7 @@ function isMemoSame(cached, memo) {
9753
9770
  }
9754
9771
  //#endregion
9755
9772
  //#region packages/runtime-core/src/index.ts
9756
- const version = "3.6.0-beta.14";
9773
+ const version = "3.6.0-beta.16";
9757
9774
  const warn = warn$1;
9758
9775
  /**
9759
9776
  * Runtime error messages. Only exposed in dev or esm builds.
@@ -10383,7 +10400,7 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
10383
10400
  const existingInvoker = invokers[rawName];
10384
10401
  if (nextValue && existingInvoker) existingInvoker.value = sanitizeEventValue(nextValue, rawName);
10385
10402
  else {
10386
- const [name, options] = parseName(rawName);
10403
+ const [name, options] = parseEventName(rawName);
10387
10404
  if (nextValue) addEventListener(el, name, invokers[rawName] = createInvoker(sanitizeEventValue(nextValue, rawName), instance), options);
10388
10405
  else if (existingInvoker) {
10389
10406
  removeEventListener(el, name, existingInvoker, options);
@@ -10392,7 +10409,7 @@ function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
10392
10409
  }
10393
10410
  }
10394
10411
  const optionsModifierRE = /(?:Once|Passive|Capture)$/;
10395
- function parseName(name) {
10412
+ function parseEventName(name) {
10396
10413
  let options;
10397
10414
  if (optionsModifierRE.test(name)) {
10398
10415
  options = {};
@@ -10956,7 +10973,7 @@ const TransitionGroup = /* @__PURE__ */ decorate({
10956
10973
  prevChildren = [];
10957
10974
  if (children) for (let i = 0; i < children.length; i++) {
10958
10975
  const child = children[i];
10959
- if (child.el && child.el instanceof Element) {
10976
+ if (child.el && child.el instanceof Element && !child.el[vShowHidden]) {
10960
10977
  prevChildren.push(child);
10961
10978
  setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
10962
10979
  positionMap.set(child, getPosition(child.el));
@@ -13177,7 +13194,7 @@ const tokenizer = new Tokenizer(stack, {
13177
13194
  }
13178
13195
  },
13179
13196
  oncdata(start, end) {
13180
- if (stack[0].ns !== 0) onText(getSlice(start, end), start, end);
13197
+ if ((stack[0] ? stack[0].ns : currentOptions.ns) !== 0) onText(getSlice(start, end), start, end);
13181
13198
  else emitError(1, start - 9);
13182
13199
  },
13183
13200
  onprocessinginstruction(start) {
@@ -13669,7 +13686,7 @@ function getSelfName(filename) {
13669
13686
  const nameMatch = filename.replace(/\?.*$/, "").match(/([^/\\]+)\.\w+$/);
13670
13687
  return nameMatch ? capitalize(camelize(nameMatch[1])) : null;
13671
13688
  }
13672
- function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
13689
+ function createTransformContext(root, { filename = "", prefixIdentifiers = false, hoistStatic = false, hmr = false, cacheHandlers = false, nodeTransforms = [], directiveTransforms = {}, transformHoist = null, isBuiltInComponent = NOOP, isCustomElement = NOOP, expressionPlugins = [], scopeId = null, slotted = true, ssr = false, inSSR = false, ssrCssVars = ``, bindingMetadata = EMPTY_OBJ, inline = false, isTS = false, eventDelegation = true, onError = defaultOnError, onWarn = defaultOnWarn, compatConfig }) {
13673
13690
  const context = {
13674
13691
  filename,
13675
13692
  selfName: getSelfName(filename),
@@ -13691,6 +13708,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
13691
13708
  bindingMetadata,
13692
13709
  inline,
13693
13710
  isTS,
13711
+ eventDelegation,
13694
13712
  onError,
13695
13713
  onWarn,
13696
13714
  compatConfig,
@@ -13702,6 +13720,7 @@ function createTransformContext(root, { filename = "", prefixIdentifiers = false
13702
13720
  imports: [],
13703
13721
  cached: [],
13704
13722
  constantCache: /* @__PURE__ */ new WeakMap(),
13723
+ vForMemoKeyedNodes: /* @__PURE__ */ new WeakSet(),
13705
13724
  temps: 0,
13706
13725
  identifiers: Object.create(null),
13707
13726
  identifierScopes: Object.create(null),
@@ -14332,7 +14351,7 @@ const transformExpression = (node, context) => {
14332
14351
  if (dir.type === 7 && dir.name !== "for") {
14333
14352
  const exp = dir.exp;
14334
14353
  const arg = dir.arg;
14335
- if (exp && exp.type === 4 && !(dir.name === "on" && arg) && !(memo && arg && arg.type === 4 && arg.content === "key")) dir.exp = processExpression(exp, context, dir.name === "slot");
14354
+ if (exp && exp.type === 4 && !(dir.name === "on" && arg) && !(memo && context.vForMemoKeyedNodes.has(node) && arg && arg.type === 4 && arg.content === "key")) dir.exp = processExpression(exp, context, dir.name === "slot");
14336
14355
  if (arg && arg.type === 4 && !arg.isStatic) dir.arg = processExpression(arg, context);
14337
14356
  }
14338
14357
  }