@vue/runtime-dom 3.6.0-rc.8 → 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.8
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.8
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.8
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
  }
@@ -777,13 +792,17 @@ function getDepFromReactive(object, key) {
777
792
  /**
778
793
  * Track array iteration and return:
779
794
  * - if input is reactive: a cloned raw array with reactive values
780
- * - 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
781
798
  */
782
799
  function reactiveReadArray(array) {
783
800
  const raw = /* @__PURE__ */ toRaw(array);
784
801
  if (raw === array) return raw;
785
802
  track(raw, "iterate", ARRAY_ITERATE_KEY);
786
- 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);
787
806
  }
788
807
  /**
789
808
  * Track array iteration and return raw array
@@ -3943,12 +3962,12 @@ function createHydrationFunctions(rendererInternals) {
3943
3962
  } else {
3944
3963
  mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized);
3945
3964
  const component = vnode.component;
3946
- if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep && !component.asyncResolved)) {
3965
+ if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep)) {
3947
3966
  let subTree;
3948
3967
  if (isFragmentStart) {
3949
3968
  subTree = createVNode(Static);
3950
3969
  subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
3951
- } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
3970
+ } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode(node.nodeType === 8 ? Comment : "div");
3952
3971
  subTree.el = node;
3953
3972
  component.subTree = subTree;
3954
3973
  }
@@ -6575,6 +6594,10 @@ function baseCreateRenderer(options, createHydrationFns) {
6575
6594
  optimized = false;
6576
6595
  n2.dynamicChildren = null;
6577
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
+ }
6578
6601
  const { type, ref, shapeFlag } = n2;
6579
6602
  switch (type) {
6580
6603
  case Text:
@@ -6891,6 +6914,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6891
6914
  if (shouldUpdateComponent(n1, n2, optimized)) {
6892
6915
  if (instance.asyncDep && !instance.asyncResolved) {
6893
6916
  pushWarningContext(n2);
6917
+ n2.el = n1.el;
6894
6918
  updateComponentPreRender(instance, n2, optimized);
6895
6919
  popWarningContext();
6896
6920
  return;
@@ -7199,13 +7223,13 @@ function baseCreateRenderer(options, createHydrationFns) {
7199
7223
  };
7200
7224
  const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
7201
7225
  const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex, memo } = vnode;
7202
- if (patchFlag === -2) optimized = false;
7226
+ if (patchFlag === -2 || dynamicChildren && dynamicChildren.hasOnce) optimized = false;
7203
7227
  if (ref != null) {
7204
7228
  const prevSub = setActiveSub();
7205
7229
  setRef(ref, null, parentSuspense, vnode, true);
7206
7230
  setActiveSub(prevSub);
7207
7231
  }
7208
- if (cacheIndex != null) parentComponent.renderCache[cacheIndex] = void 0;
7232
+ if (cacheIndex != null && (!vnode.ctx || vnode.ctx === parentComponent)) parentComponent.renderCache[cacheIndex] = void 0;
7209
7233
  if (shapeFlag & 256) {
7210
7234
  if (isVaporComponent(vnode.type)) getVaporInterface(parentComponent, vnode).deactivate(vnode, parentComponent.ctx.getStorageContainer(), parentSuspense);
7211
7235
  else parentComponent.ctx.deactivate(vnode);
@@ -7259,6 +7283,7 @@ function baseCreateRenderer(options, createHydrationFns) {
7259
7283
  }
7260
7284
  if (type === Static) {
7261
7285
  removeStaticNode(vnode);
7286
+ if (transition && !transition.persisted && transition.afterLeave) transition.afterLeave();
7262
7287
  return;
7263
7288
  }
7264
7289
  if (transition) performTransitionLeave(el, transition, () => hostRemove(el), !!(vnode.shapeFlag & 1));
@@ -7283,7 +7308,10 @@ function baseCreateRenderer(options, createHydrationFns) {
7283
7308
  if (effect) {
7284
7309
  effect.stop();
7285
7310
  unmount(subTree, instance, parentSuspense, doRemove);
7286
- } 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
+ }
7287
7315
  if (um) queuePostRenderEffect(um, void 0, parentSuspense);
7288
7316
  queuePostRenderEffect(() => instance.isUnmounted = true, void 0, parentSuspense);
7289
7317
  devtoolsComponentRemoved(instance);
@@ -7489,7 +7517,7 @@ const Suspense = {
7489
7517
  process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
7490
7518
  if (n1 == null) mountSuspense(n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals);
7491
7519
  else {
7492
- if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
7520
+ if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback && !parentSuspense.isHydrating) {
7493
7521
  n2.suspense = n1.suspense;
7494
7522
  n2.suspense.vnode = n2;
7495
7523
  n2.el = n1.el;
@@ -7527,7 +7555,9 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, sl
7527
7555
  if (pendingBranch) {
7528
7556
  suspense.pendingBranch = newBranch;
7529
7557
  if (isSameVNodeType(pendingBranch, newBranch)) {
7530
- 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--;
7531
7561
  if (suspense.deps <= 0) suspense.resolve();
7532
7562
  else if (isInFallback) {
7533
7563
  if (!isHydrating && !suspense.isFallbackMountPending) {
@@ -7663,6 +7693,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
7663
7693
  suspense.effects = [];
7664
7694
  if (isSuspensible) {
7665
7695
  if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
7696
+ parentSuspenseId = void 0;
7666
7697
  parentSuspense.deps--;
7667
7698
  if (parentSuspense.deps === 0 && !sync) parentSuspense.resolve();
7668
7699
  }
@@ -7700,11 +7731,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
7700
7731
  registerDep(instance, onResolve) {
7701
7732
  const isInPendingSuspense = !!suspense.pendingBranch;
7702
7733
  if (isInPendingSuspense) suspense.deps++;
7734
+ const hydratedEl = instance.vnode && instance.vnode.el;
7703
7735
  instance.asyncDep.catch((err) => {
7704
7736
  handleError(err, instance, 0);
7705
7737
  }).then((asyncSetupResult) => {
7706
7738
  if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) return;
7707
7739
  setCurrentInstance(null, void 0);
7740
+ if (hydratedEl && !instance.scope.active) {
7741
+ if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
7742
+ return;
7743
+ }
7708
7744
  instance.asyncResolved = true;
7709
7745
  onResolve(asyncSetupResult);
7710
7746
  if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
@@ -8017,7 +8053,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
8017
8053
  vs: cloneVaporSlotMeta(vnode),
8018
8054
  vb: vnode.vb,
8019
8055
  ibu: vnode.ibu,
8020
- iu: vnode.iu
8056
+ iu: vnode.iu,
8057
+ cacheIndex: vnode.cacheIndex
8021
8058
  };
8022
8059
  if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
8023
8060
  return cloned;
@@ -8717,7 +8754,7 @@ function isMemoSame(cached, memo) {
8717
8754
  }
8718
8755
  //#endregion
8719
8756
  //#region packages/runtime-core/src/index.ts
8720
- const version = "3.6.0-rc.8";
8757
+ const version = "3.6.0-rc.9";
8721
8758
  const warn = warn$1;
8722
8759
  /**
8723
8760
  * Runtime error messages. Only exposed in dev or esm builds.
@@ -9090,49 +9127,20 @@ const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT");
9090
9127
  */
9091
9128
  function useCssVars(getter) {
9092
9129
  const instance = getCurrentInstance();
9093
- const getVars = () => getter(instance.proxy);
9094
- const setVars = (vars) => {
9095
- if (instance.ce) setVarsOnNode(instance.ce, vars);
9096
- else setVarsOnVNode(instance.subTree, vars);
9097
- };
9098
- baseUseCssVars(instance, () => instance.subTree.el.parentNode, getVars, setVars);
9099
- }
9100
- function setVarsOnVNode(vnode, vars) {
9101
- if (vnode.shapeFlag & 128) {
9102
- const suspense = vnode.suspense;
9103
- vnode = suspense.activeBranch;
9104
- if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => {
9105
- setVarsOnVNode(suspense.activeBranch, vars);
9106
- });
9107
- }
9108
- while (vnode.component) vnode = vnode.component.subTree;
9109
- if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars);
9110
- else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars));
9111
- else if (vnode.type === Static) {
9112
- let { el, anchor } = vnode;
9113
- while (el) {
9114
- setVarsOnNode(el, vars);
9115
- if (el === anchor) break;
9116
- el = el.nextSibling;
9117
- }
9118
- }
9119
- }
9120
- /**
9121
- * @internal
9122
- * shared between vdom and vapor
9123
- */
9124
- function baseUseCssVars(instance, getParentNode, getVars, setVars) {
9125
9130
  /* v8 ignore start */
9126
9131
  if (!instance) {
9127
9132
  warn(`useCssVars is called without current active component instance.`);
9128
9133
  return;
9129
9134
  }
9135
+ /* v8 ignore stop */
9136
+ const getVars = () => getter(instance.proxy);
9130
9137
  instance.getCssVars = getVars;
9131
9138
  const updateTeleports = instance.ut = (vars = getVars()) => {
9132
9139
  Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach((node) => setVarsOnNode(node, vars));
9133
9140
  };
9134
9141
  const applyCssVars = (vars = getVars()) => {
9135
- setVars(vars);
9142
+ if (instance.ce) setVarsOnNode(instance.ce, vars);
9143
+ else setVarsOnVNode(instance.subTree, vars);
9136
9144
  updateTeleports(vars);
9137
9145
  };
9138
9146
  onBeforeUpdate(() => {
@@ -9145,10 +9153,37 @@ function baseUseCssVars(instance, getParentNode, getVars, setVars) {
9145
9153
  applyCssVars(vars);
9146
9154
  }, NOOP, { flush: "post" });
9147
9155
  const ob = new MutationObserver(() => applyCssVars());
9148
- ob.observe(getParentNode(), { childList: true });
9156
+ ob.observe(instance.subTree.el.parentNode, { childList: true });
9149
9157
  onUnmounted(() => ob.disconnect());
9150
9158
  });
9151
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
+ }
9152
9187
  /**
9153
9188
  * @internal
9154
9189
  * shared between vdom and vapor