@vue/runtime-dom 3.6.0-rc.7 → 3.6.0-rc.9

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/runtime-dom v3.6.0-rc.7
2
+ * @vue/runtime-dom v3.6.0-rc.9
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.6.0-rc.7
2
+ * @vue/runtime-dom v3.6.0-rc.9
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/runtime-dom v3.6.0-rc.7
2
+ * @vue/runtime-dom v3.6.0-rc.9
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -147,10 +147,10 @@ function normalizeStyle(value) {
147
147
  }
148
148
  const listDelimiterRE = /;(?![^(]*\))/g;
149
149
  const propertyDelimiterRE = /:([^]+)/;
150
- const styleCommentRE = /\/\*[^]*?\*\//g;
150
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
151
151
  function parseStringStyle(cssText) {
152
152
  const ret = {};
153
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
153
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
154
154
  if (item) {
155
155
  const tmp = item.split(propertyDelimiterRE);
156
156
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -272,19 +272,19 @@ function getEscapedCssVarName(key, doubleEscape) {
272
272
  }
273
273
  //#endregion
274
274
  //#region packages/shared/src/looseEqual.ts
275
- function looseCompareArrays(a, b) {
275
+ function looseCompareArrays(a, b, seen) {
276
276
  if (a.length !== b.length) return false;
277
277
  let equal = true;
278
- for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
278
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i], seen);
279
279
  return equal;
280
280
  }
281
- function looseCompareCollections(a, b) {
281
+ function looseCompareCollections(a, b, seen) {
282
282
  if (a.size !== b.size) return false;
283
283
  const candidates = Array.from(b);
284
284
  const matched = new Uint8Array(candidates.length);
285
285
  for (const item of a) {
286
286
  let index = -1;
287
- for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i])) {
287
+ for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i], seen)) {
288
288
  index = i;
289
289
  break;
290
290
  }
@@ -293,7 +293,33 @@ function looseCompareCollections(a, b) {
293
293
  }
294
294
  return true;
295
295
  }
296
- function looseEqual(a, b) {
296
+ function looseCompareObjects(a, b, seen) {
297
+ let aValidType = isMap(a);
298
+ let bValidType = isMap(b);
299
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
300
+ aValidType = isSet(a);
301
+ bValidType = isSet(b);
302
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
303
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
304
+ for (const key in a) {
305
+ const aHasKey = a.hasOwnProperty(key);
306
+ const bHasKey = b.hasOwnProperty(key);
307
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) return false;
308
+ }
309
+ return String(a) === String(b);
310
+ }
311
+ function looseCompareNested(a, b, seen, compare) {
312
+ if (!seen) seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
313
+ const [seenA, seenB] = seen;
314
+ if (seenA.has(a) || seenB.has(b)) return seenA.get(a) === b && seenB.get(b) === a;
315
+ seenA.set(a, b);
316
+ seenB.set(b, a);
317
+ const equal = compare(a, b, seen);
318
+ seenA.delete(a);
319
+ seenB.delete(b);
320
+ return equal;
321
+ }
322
+ function looseEqual(a, b, seen) {
297
323
  if (a === b) return true;
298
324
  let aValidType = isDate(a);
299
325
  let bValidType = isDate(b);
@@ -303,23 +329,12 @@ function looseEqual(a, b) {
303
329
  if (aValidType || bValidType) return a === b;
304
330
  aValidType = isArray(a);
305
331
  bValidType = isArray(b);
306
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
332
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
307
333
  aValidType = isObject(a);
308
334
  bValidType = isObject(b);
309
335
  if (aValidType || bValidType) {
310
336
  if (!aValidType || !bValidType) return false;
311
- aValidType = isMap(a);
312
- bValidType = isMap(b);
313
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
314
- aValidType = isSet(a);
315
- bValidType = isSet(b);
316
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
317
- if (Object.keys(a).length !== Object.keys(b).length) return false;
318
- for (const key in a) {
319
- const aHasKey = a.hasOwnProperty(key);
320
- const bHasKey = b.hasOwnProperty(key);
321
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
322
- }
337
+ return looseCompareNested(a, b, seen, looseCompareObjects);
323
338
  }
324
339
  return String(a) === String(b);
325
340
  }
@@ -449,6 +464,8 @@ function setupFlagsHandler(target) {
449
464
  function warn$2(msg, ...args) {
450
465
  console.warn(`[Vue warn] ${msg}`, ...args);
451
466
  }
467
+ //#endregion
468
+ //#region packages/reactivity/src/system.ts
452
469
  const notifyBuffer = [];
453
470
  let batchDepth = 0;
454
471
  let activeSub = void 0;
@@ -775,13 +792,17 @@ function getDepFromReactive(object, key) {
775
792
  /**
776
793
  * Track array iteration and return:
777
794
  * - if input is reactive: a cloned raw array with reactive values
778
- * - if input is non-reactive or shallowReactive: the original raw array
795
+ * - if input is readonly: a cloned raw array with readonly values, preserving
796
+ * reactivity
797
+ * - if input is raw or shallow: the original raw array
779
798
  */
780
799
  function reactiveReadArray(array) {
781
800
  const raw = /* @__PURE__ */ toRaw(array);
782
801
  if (raw === array) return raw;
783
802
  track(raw, "iterate", ARRAY_ITERATE_KEY);
784
- return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
803
+ if (/* @__PURE__ */ isShallow(array)) return raw;
804
+ if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
805
+ return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
785
806
  }
786
807
  /**
787
808
  * Track array iteration and return raw array
@@ -3941,12 +3962,12 @@ function createHydrationFunctions(rendererInternals) {
3941
3962
  } else {
3942
3963
  mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized);
3943
3964
  const component = vnode.component;
3944
- if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep && !component.asyncResolved)) {
3965
+ if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep)) {
3945
3966
  let subTree;
3946
3967
  if (isFragmentStart) {
3947
3968
  subTree = createVNode(Static);
3948
3969
  subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
3949
- } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
3970
+ } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode(node.nodeType === 8 ? Comment : "div");
3950
3971
  subTree.el = node;
3951
3972
  component.subTree = subTree;
3952
3973
  }
@@ -5330,37 +5351,32 @@ function createPropsRestProxy(props, excludedKeys) {
5330
5351
  function withAsyncContext(getAwaitable) {
5331
5352
  const ctx = getCurrentGenericInstance();
5332
5353
  const inSSRSetup = isInSSRComponentSetup;
5333
- const restoreAsyncContext = ctx && ctx.restoreAsyncContext ? ctx.restoreAsyncContext.bind(ctx) : void 0;
5334
5354
  if (!ctx) warn$1("withAsyncContext called without active current instance. This is likely a bug.");
5335
5355
  let awaitable = getAwaitable();
5336
5356
  setCurrentInstance(null, void 0);
5337
5357
  if (inSSRSetup) setInSSRSetupState(false);
5338
5358
  const restore = () => {
5339
- const resetStoppedScope = ctx && !ctx.scope.active ? ctx.scope : void 0;
5359
+ const stoppedScope = ctx && !ctx.scope.active ? ctx.scope : void 0;
5340
5360
  setCurrentInstance(ctx);
5341
5361
  if (inSSRSetup) setInSSRSetupState(true);
5342
- const reset = restoreAsyncContext && restoreAsyncContext();
5343
- return () => {
5344
- if (reset) reset();
5345
- if (resetStoppedScope) resetStoppedScope.reset();
5346
- };
5362
+ return stoppedScope;
5347
5363
  };
5348
5364
  const cleanup = () => {
5349
5365
  setCurrentInstance(null, void 0);
5350
5366
  if (inSSRSetup) setInSSRSetupState(false);
5351
5367
  };
5352
5368
  if (isPromise(awaitable)) awaitable = awaitable.catch((e) => {
5353
- const reset = restore();
5369
+ const stoppedScope = restore();
5354
5370
  Promise.resolve().then(() => Promise.resolve().then(() => {
5355
- if (reset) reset();
5371
+ if (stoppedScope) stoppedScope.reset();
5356
5372
  cleanup();
5357
5373
  }));
5358
5374
  throw e;
5359
5375
  });
5360
5376
  return [awaitable, () => {
5361
- const reset = restore();
5377
+ const stoppedScope = restore();
5362
5378
  Promise.resolve().then(() => {
5363
- if (reset) reset();
5379
+ if (stoppedScope) stoppedScope.reset();
5364
5380
  cleanup();
5365
5381
  });
5366
5382
  }];
@@ -6578,6 +6594,10 @@ function baseCreateRenderer(options, createHydrationFns) {
6578
6594
  optimized = false;
6579
6595
  n2.dynamicChildren = null;
6580
6596
  }
6597
+ if (n2.dynamicChildren && n1 && n1.dynamicChildren && n1.dynamicChildren.hasOnce) {
6598
+ if (n2.dynamicChildren === EMPTY_ARR) n2.dynamicChildren = [];
6599
+ n2.dynamicChildren.hasOnce = true;
6600
+ }
6581
6601
  const { type, ref, shapeFlag } = n2;
6582
6602
  switch (type) {
6583
6603
  case Text:
@@ -6894,6 +6914,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6894
6914
  if (shouldUpdateComponent(n1, n2, optimized)) {
6895
6915
  if (instance.asyncDep && !instance.asyncResolved) {
6896
6916
  pushWarningContext(n2);
6917
+ n2.el = n1.el;
6897
6918
  updateComponentPreRender(instance, n2, optimized);
6898
6919
  popWarningContext();
6899
6920
  return;
@@ -7202,13 +7223,13 @@ function baseCreateRenderer(options, createHydrationFns) {
7202
7223
  };
7203
7224
  const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
7204
7225
  const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex, memo } = vnode;
7205
- if (patchFlag === -2) optimized = false;
7226
+ if (patchFlag === -2 || dynamicChildren && dynamicChildren.hasOnce) optimized = false;
7206
7227
  if (ref != null) {
7207
7228
  const prevSub = setActiveSub();
7208
7229
  setRef(ref, null, parentSuspense, vnode, true);
7209
7230
  setActiveSub(prevSub);
7210
7231
  }
7211
- if (cacheIndex != null) parentComponent.renderCache[cacheIndex] = void 0;
7232
+ if (cacheIndex != null && (!vnode.ctx || vnode.ctx === parentComponent)) parentComponent.renderCache[cacheIndex] = void 0;
7212
7233
  if (shapeFlag & 256) {
7213
7234
  if (isVaporComponent(vnode.type)) getVaporInterface(parentComponent, vnode).deactivate(vnode, parentComponent.ctx.getStorageContainer(), parentSuspense);
7214
7235
  else parentComponent.ctx.deactivate(vnode);
@@ -7262,6 +7283,7 @@ function baseCreateRenderer(options, createHydrationFns) {
7262
7283
  }
7263
7284
  if (type === Static) {
7264
7285
  removeStaticNode(vnode);
7286
+ if (transition && !transition.persisted && transition.afterLeave) transition.afterLeave();
7265
7287
  return;
7266
7288
  }
7267
7289
  if (transition) performTransitionLeave(el, transition, () => hostRemove(el), !!(vnode.shapeFlag & 1));
@@ -7286,7 +7308,10 @@ function baseCreateRenderer(options, createHydrationFns) {
7286
7308
  if (effect) {
7287
7309
  effect.stop();
7288
7310
  unmount(subTree, instance, parentSuspense, doRemove);
7289
- } else if (doRemove && subTree && instance.vnode.el) remove(subTree);
7311
+ } else if (instance.vnode.el && subTree) {
7312
+ subTree.transition = instance.vnode.transition;
7313
+ unmount(subTree, instance, parentSuspense, doRemove);
7314
+ }
7290
7315
  if (um) queuePostRenderEffect(um, void 0, parentSuspense);
7291
7316
  queuePostRenderEffect(() => instance.isUnmounted = true, void 0, parentSuspense);
7292
7317
  devtoolsComponentRemoved(instance);
@@ -7492,7 +7517,7 @@ const Suspense = {
7492
7517
  process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
7493
7518
  if (n1 == null) mountSuspense(n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals);
7494
7519
  else {
7495
- if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
7520
+ if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback && !parentSuspense.isHydrating) {
7496
7521
  n2.suspense = n1.suspense;
7497
7522
  n2.suspense.vnode = n2;
7498
7523
  n2.el = n1.el;
@@ -7530,7 +7555,9 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, sl
7530
7555
  if (pendingBranch) {
7531
7556
  suspense.pendingBranch = newBranch;
7532
7557
  if (isSameVNodeType(pendingBranch, newBranch)) {
7533
- patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
7558
+ suspense.deps++;
7559
+ patch(pendingBranch, newBranch, isHydrating ? container : suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
7560
+ suspense.deps--;
7534
7561
  if (suspense.deps <= 0) suspense.resolve();
7535
7562
  else if (isInFallback) {
7536
7563
  if (!isHydrating && !suspense.isFallbackMountPending) {
@@ -7666,6 +7693,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
7666
7693
  suspense.effects = [];
7667
7694
  if (isSuspensible) {
7668
7695
  if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
7696
+ parentSuspenseId = void 0;
7669
7697
  parentSuspense.deps--;
7670
7698
  if (parentSuspense.deps === 0 && !sync) parentSuspense.resolve();
7671
7699
  }
@@ -7703,11 +7731,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
7703
7731
  registerDep(instance, onResolve) {
7704
7732
  const isInPendingSuspense = !!suspense.pendingBranch;
7705
7733
  if (isInPendingSuspense) suspense.deps++;
7734
+ const hydratedEl = instance.vnode && instance.vnode.el;
7706
7735
  instance.asyncDep.catch((err) => {
7707
7736
  handleError(err, instance, 0);
7708
7737
  }).then((asyncSetupResult) => {
7709
7738
  if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) return;
7710
7739
  setCurrentInstance(null, void 0);
7740
+ if (hydratedEl && !instance.scope.active) {
7741
+ if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
7742
+ return;
7743
+ }
7711
7744
  instance.asyncResolved = true;
7712
7745
  onResolve(asyncSetupResult);
7713
7746
  if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
@@ -8020,7 +8053,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
8020
8053
  vs: cloneVaporSlotMeta(vnode),
8021
8054
  vb: vnode.vb,
8022
8055
  ibu: vnode.ibu,
8023
- iu: vnode.iu
8056
+ iu: vnode.iu,
8057
+ cacheIndex: vnode.cacheIndex
8024
8058
  };
8025
8059
  if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
8026
8060
  return cloned;
@@ -8720,7 +8754,7 @@ function isMemoSame(cached, memo) {
8720
8754
  }
8721
8755
  //#endregion
8722
8756
  //#region packages/runtime-core/src/index.ts
8723
- const version = "3.6.0-rc.7";
8757
+ const version = "3.6.0-rc.9";
8724
8758
  const warn = warn$1;
8725
8759
  /**
8726
8760
  * Runtime error messages. Only exposed in dev or esm builds.
@@ -9093,49 +9127,20 @@ const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT");
9093
9127
  */
9094
9128
  function useCssVars(getter) {
9095
9129
  const instance = getCurrentInstance();
9096
- const getVars = () => getter(instance.proxy);
9097
- const setVars = (vars) => {
9098
- if (instance.ce) setVarsOnNode(instance.ce, vars);
9099
- else setVarsOnVNode(instance.subTree, vars);
9100
- };
9101
- baseUseCssVars(instance, () => instance.subTree.el.parentNode, getVars, setVars);
9102
- }
9103
- function setVarsOnVNode(vnode, vars) {
9104
- if (vnode.shapeFlag & 128) {
9105
- const suspense = vnode.suspense;
9106
- vnode = suspense.activeBranch;
9107
- if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => {
9108
- setVarsOnVNode(suspense.activeBranch, vars);
9109
- });
9110
- }
9111
- while (vnode.component) vnode = vnode.component.subTree;
9112
- if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars);
9113
- else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars));
9114
- else if (vnode.type === Static) {
9115
- let { el, anchor } = vnode;
9116
- while (el) {
9117
- setVarsOnNode(el, vars);
9118
- if (el === anchor) break;
9119
- el = el.nextSibling;
9120
- }
9121
- }
9122
- }
9123
- /**
9124
- * @internal
9125
- * shared between vdom and vapor
9126
- */
9127
- function baseUseCssVars(instance, getParentNode, getVars, setVars) {
9128
9130
  /* v8 ignore start */
9129
9131
  if (!instance) {
9130
9132
  warn(`useCssVars is called without current active component instance.`);
9131
9133
  return;
9132
9134
  }
9135
+ /* v8 ignore stop */
9136
+ const getVars = () => getter(instance.proxy);
9133
9137
  instance.getCssVars = getVars;
9134
9138
  const updateTeleports = instance.ut = (vars = getVars()) => {
9135
9139
  Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach((node) => setVarsOnNode(node, vars));
9136
9140
  };
9137
9141
  const applyCssVars = (vars = getVars()) => {
9138
- setVars(vars);
9142
+ if (instance.ce) setVarsOnNode(instance.ce, vars);
9143
+ else setVarsOnVNode(instance.subTree, vars);
9139
9144
  updateTeleports(vars);
9140
9145
  };
9141
9146
  onBeforeUpdate(() => {
@@ -9148,10 +9153,37 @@ function baseUseCssVars(instance, getParentNode, getVars, setVars) {
9148
9153
  applyCssVars(vars);
9149
9154
  }, NOOP, { flush: "post" });
9150
9155
  const ob = new MutationObserver(() => applyCssVars());
9151
- ob.observe(getParentNode(), { childList: true });
9156
+ ob.observe(instance.subTree.el.parentNode, { childList: true });
9152
9157
  onUnmounted(() => ob.disconnect());
9153
9158
  });
9154
9159
  }
9160
+ function setVarsOnVNode(vnode, vars) {
9161
+ if (vnode.shapeFlag & 128) {
9162
+ const suspense = vnode.suspense;
9163
+ vnode = suspense.activeBranch;
9164
+ if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => {
9165
+ setVarsOnVNode(suspense.activeBranch, vars);
9166
+ });
9167
+ }
9168
+ while (vnode.component) {
9169
+ const component = vnode.component;
9170
+ if (component.vapor) {
9171
+ component.appContext.vapor.applyCssVars(vnode, vars);
9172
+ return;
9173
+ }
9174
+ vnode = vnode.component.subTree;
9175
+ }
9176
+ if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars);
9177
+ else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars));
9178
+ else if (vnode.type === Static) {
9179
+ let { el, anchor } = vnode;
9180
+ while (el) {
9181
+ setVarsOnNode(el, vars);
9182
+ if (el === anchor) break;
9183
+ el = el.nextSibling;
9184
+ }
9185
+ }
9186
+ }
9155
9187
  /**
9156
9188
  * @internal
9157
9189
  * shared between vdom and vapor