vue 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.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * vue v3.6.0-rc.8
2
+ * vue 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 v3.6.0-rc.8
2
+ * vue 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 v3.6.0-rc.8
2
+ * vue v3.6.0-rc.9
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -231,10 +231,10 @@ function normalizeStyle(value) {
231
231
  }
232
232
  const listDelimiterRE = /;(?![^(]*\))/g;
233
233
  const propertyDelimiterRE = /:([^]+)/;
234
- const styleCommentRE = /\/\*[^]*?\*\//g;
234
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
235
235
  function parseStringStyle(cssText) {
236
236
  const ret = {};
237
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
237
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
238
238
  if (item) {
239
239
  const tmp = item.split(propertyDelimiterRE);
240
240
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -362,19 +362,19 @@ function getEscapedCssVarName(key, doubleEscape) {
362
362
  }
363
363
  //#endregion
364
364
  //#region packages/shared/src/looseEqual.ts
365
- function looseCompareArrays(a, b) {
365
+ function looseCompareArrays(a, b, seen) {
366
366
  if (a.length !== b.length) return false;
367
367
  let equal = true;
368
- for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
368
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i], seen);
369
369
  return equal;
370
370
  }
371
- function looseCompareCollections(a, b) {
371
+ function looseCompareCollections(a, b, seen) {
372
372
  if (a.size !== b.size) return false;
373
373
  const candidates = Array.from(b);
374
374
  const matched = new Uint8Array(candidates.length);
375
375
  for (const item of a) {
376
376
  let index = -1;
377
- for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i])) {
377
+ for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i], seen)) {
378
378
  index = i;
379
379
  break;
380
380
  }
@@ -383,7 +383,33 @@ function looseCompareCollections(a, b) {
383
383
  }
384
384
  return true;
385
385
  }
386
- function looseEqual(a, b) {
386
+ function looseCompareObjects(a, b, seen) {
387
+ let aValidType = isMap(a);
388
+ let bValidType = isMap(b);
389
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
390
+ aValidType = isSet(a);
391
+ bValidType = isSet(b);
392
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
393
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
394
+ for (const key in a) {
395
+ const aHasKey = a.hasOwnProperty(key);
396
+ const bHasKey = b.hasOwnProperty(key);
397
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) return false;
398
+ }
399
+ return String(a) === String(b);
400
+ }
401
+ function looseCompareNested(a, b, seen, compare) {
402
+ if (!seen) seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
403
+ const [seenA, seenB] = seen;
404
+ if (seenA.has(a) || seenB.has(b)) return seenA.get(a) === b && seenB.get(b) === a;
405
+ seenA.set(a, b);
406
+ seenB.set(b, a);
407
+ const equal = compare(a, b, seen);
408
+ seenA.delete(a);
409
+ seenB.delete(b);
410
+ return equal;
411
+ }
412
+ function looseEqual(a, b, seen) {
387
413
  if (a === b) return true;
388
414
  let aValidType = isDate(a);
389
415
  let bValidType = isDate(b);
@@ -393,23 +419,12 @@ function looseEqual(a, b) {
393
419
  if (aValidType || bValidType) return a === b;
394
420
  aValidType = isArray(a);
395
421
  bValidType = isArray(b);
396
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
422
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
397
423
  aValidType = isObject(a);
398
424
  bValidType = isObject(b);
399
425
  if (aValidType || bValidType) {
400
426
  if (!aValidType || !bValidType) return false;
401
- aValidType = isMap(a);
402
- bValidType = isMap(b);
403
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
404
- aValidType = isSet(a);
405
- bValidType = isSet(b);
406
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
407
- if (Object.keys(a).length !== Object.keys(b).length) return false;
408
- for (const key in a) {
409
- const aHasKey = a.hasOwnProperty(key);
410
- const bHasKey = b.hasOwnProperty(key);
411
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
412
- }
427
+ return looseCompareNested(a, b, seen, looseCompareObjects);
413
428
  }
414
429
  return String(a) === String(b);
415
430
  }
@@ -867,13 +882,17 @@ function getDepFromReactive(object, key) {
867
882
  /**
868
883
  * Track array iteration and return:
869
884
  * - if input is reactive: a cloned raw array with reactive values
870
- * - if input is non-reactive or shallowReactive: the original raw array
885
+ * - if input is readonly: a cloned raw array with readonly values, preserving
886
+ * reactivity
887
+ * - if input is raw or shallow: the original raw array
871
888
  */
872
889
  function reactiveReadArray(array) {
873
890
  const raw = /* @__PURE__ */ toRaw(array);
874
891
  if (raw === array) return raw;
875
892
  track(raw, "iterate", ARRAY_ITERATE_KEY);
876
- return /* @__PURE__ */ isShallow(array) ? raw : raw.map(toReactive);
893
+ if (/* @__PURE__ */ isShallow(array)) return raw;
894
+ if (!/* @__PURE__ */ isReadonly(array)) return raw.map(toReactive);
895
+ return /* @__PURE__ */ isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
877
896
  }
878
897
  /**
879
898
  * Track array iteration and return raw array
@@ -4033,12 +4052,12 @@ function createHydrationFunctions(rendererInternals) {
4033
4052
  } else {
4034
4053
  mountComponent(vnode, container, null, parentComponent, parentSuspense, getContainerType(container), optimized);
4035
4054
  const component = vnode.component;
4036
- if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep && !component.asyncResolved)) {
4055
+ if (!component.subTree && (isAsyncWrapper(vnode) || component.asyncDep)) {
4037
4056
  let subTree;
4038
4057
  if (isFragmentStart) {
4039
4058
  subTree = createVNode(Static);
4040
4059
  subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
4041
- } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
4060
+ } else subTree = node.nodeType === 3 ? createTextVNode("") : createVNode(node.nodeType === 8 ? Comment : "div");
4042
4061
  subTree.el = node;
4043
4062
  component.subTree = subTree;
4044
4063
  }
@@ -6665,6 +6684,10 @@ function baseCreateRenderer(options, createHydrationFns) {
6665
6684
  optimized = false;
6666
6685
  n2.dynamicChildren = null;
6667
6686
  }
6687
+ if (n2.dynamicChildren && n1 && n1.dynamicChildren && n1.dynamicChildren.hasOnce) {
6688
+ if (n2.dynamicChildren === EMPTY_ARR) n2.dynamicChildren = [];
6689
+ n2.dynamicChildren.hasOnce = true;
6690
+ }
6668
6691
  const { type, ref, shapeFlag } = n2;
6669
6692
  switch (type) {
6670
6693
  case Text:
@@ -6981,6 +7004,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6981
7004
  if (shouldUpdateComponent(n1, n2, optimized)) {
6982
7005
  if (instance.asyncDep && !instance.asyncResolved) {
6983
7006
  pushWarningContext(n2);
7007
+ n2.el = n1.el;
6984
7008
  updateComponentPreRender(instance, n2, optimized);
6985
7009
  popWarningContext();
6986
7010
  return;
@@ -7289,13 +7313,13 @@ function baseCreateRenderer(options, createHydrationFns) {
7289
7313
  };
7290
7314
  const unmount = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
7291
7315
  const { type, props, ref, children, dynamicChildren, shapeFlag, patchFlag, dirs, cacheIndex, memo } = vnode;
7292
- if (patchFlag === -2) optimized = false;
7316
+ if (patchFlag === -2 || dynamicChildren && dynamicChildren.hasOnce) optimized = false;
7293
7317
  if (ref != null) {
7294
7318
  const prevSub = setActiveSub();
7295
7319
  setRef(ref, null, parentSuspense, vnode, true);
7296
7320
  setActiveSub(prevSub);
7297
7321
  }
7298
- if (cacheIndex != null) parentComponent.renderCache[cacheIndex] = void 0;
7322
+ if (cacheIndex != null && (!vnode.ctx || vnode.ctx === parentComponent)) parentComponent.renderCache[cacheIndex] = void 0;
7299
7323
  if (shapeFlag & 256) {
7300
7324
  if (isVaporComponent(vnode.type)) getVaporInterface(parentComponent, vnode).deactivate(vnode, parentComponent.ctx.getStorageContainer(), parentSuspense);
7301
7325
  else parentComponent.ctx.deactivate(vnode);
@@ -7349,6 +7373,7 @@ function baseCreateRenderer(options, createHydrationFns) {
7349
7373
  }
7350
7374
  if (type === Static) {
7351
7375
  removeStaticNode(vnode);
7376
+ if (transition && !transition.persisted && transition.afterLeave) transition.afterLeave();
7352
7377
  return;
7353
7378
  }
7354
7379
  if (transition) performTransitionLeave(el, transition, () => hostRemove(el), !!(vnode.shapeFlag & 1));
@@ -7373,7 +7398,10 @@ function baseCreateRenderer(options, createHydrationFns) {
7373
7398
  if (effect) {
7374
7399
  effect.stop();
7375
7400
  unmount(subTree, instance, parentSuspense, doRemove);
7376
- } else if (doRemove && subTree && instance.vnode.el) remove(subTree);
7401
+ } else if (instance.vnode.el && subTree) {
7402
+ subTree.transition = instance.vnode.transition;
7403
+ unmount(subTree, instance, parentSuspense, doRemove);
7404
+ }
7377
7405
  if (um) queuePostRenderEffect(um, void 0, parentSuspense);
7378
7406
  queuePostRenderEffect(() => instance.isUnmounted = true, void 0, parentSuspense);
7379
7407
  devtoolsComponentRemoved(instance);
@@ -7579,7 +7607,7 @@ const Suspense = {
7579
7607
  process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals) {
7580
7608
  if (n1 == null) mountSuspense(n2, container, anchor, parentComponent, parentSuspense, namespace, slotScopeIds, optimized, rendererInternals);
7581
7609
  else {
7582
- if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
7610
+ if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback && !parentSuspense.isHydrating) {
7583
7611
  n2.suspense = n1.suspense;
7584
7612
  n2.suspense.vnode = n2;
7585
7613
  n2.el = n1.el;
@@ -7617,7 +7645,9 @@ function patchSuspense(n1, n2, container, anchor, parentComponent, namespace, sl
7617
7645
  if (pendingBranch) {
7618
7646
  suspense.pendingBranch = newBranch;
7619
7647
  if (isSameVNodeType(pendingBranch, newBranch)) {
7620
- patch(pendingBranch, newBranch, suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
7648
+ suspense.deps++;
7649
+ patch(pendingBranch, newBranch, isHydrating ? container : suspense.hiddenContainer, null, parentComponent, suspense, namespace, slotScopeIds, optimized);
7650
+ suspense.deps--;
7621
7651
  if (suspense.deps <= 0) suspense.resolve();
7622
7652
  else if (isInFallback) {
7623
7653
  if (!isHydrating && !suspense.isFallbackMountPending) {
@@ -7753,6 +7783,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
7753
7783
  suspense.effects = [];
7754
7784
  if (isSuspensible) {
7755
7785
  if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
7786
+ parentSuspenseId = void 0;
7756
7787
  parentSuspense.deps--;
7757
7788
  if (parentSuspense.deps === 0 && !sync) parentSuspense.resolve();
7758
7789
  }
@@ -7790,11 +7821,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
7790
7821
  registerDep(instance, onResolve) {
7791
7822
  const isInPendingSuspense = !!suspense.pendingBranch;
7792
7823
  if (isInPendingSuspense) suspense.deps++;
7824
+ const hydratedEl = instance.vnode && instance.vnode.el;
7793
7825
  instance.asyncDep.catch((err) => {
7794
7826
  handleError(err, instance, 0);
7795
7827
  }).then((asyncSetupResult) => {
7796
7828
  if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) return;
7797
7829
  setCurrentInstance(null, void 0);
7830
+ if (hydratedEl && !instance.scope.active) {
7831
+ if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
7832
+ return;
7833
+ }
7798
7834
  instance.asyncResolved = true;
7799
7835
  onResolve(asyncSetupResult);
7800
7836
  if (isInPendingSuspense && --suspense.deps === 0) suspense.resolve();
@@ -8107,7 +8143,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false
8107
8143
  vs: cloneVaporSlotMeta(vnode),
8108
8144
  vb: vnode.vb,
8109
8145
  ibu: vnode.ibu,
8110
- iu: vnode.iu
8146
+ iu: vnode.iu,
8147
+ cacheIndex: vnode.cacheIndex
8111
8148
  };
8112
8149
  if (transition && cloneTransition) setTransitionHooks(cloned, transition.clone(cloned));
8113
8150
  return cloned;
@@ -8807,7 +8844,7 @@ function isMemoSame(cached, memo) {
8807
8844
  }
8808
8845
  //#endregion
8809
8846
  //#region packages/runtime-core/src/index.ts
8810
- const version = "3.6.0-rc.8";
8847
+ const version = "3.6.0-rc.9";
8811
8848
  const warn = warn$1;
8812
8849
  /**
8813
8850
  * Runtime error messages. Only exposed in dev or esm builds.
@@ -9180,49 +9217,20 @@ const CSS_VAR_TEXT = Symbol("CSS_VAR_TEXT");
9180
9217
  */
9181
9218
  function useCssVars(getter) {
9182
9219
  const instance = getCurrentInstance();
9183
- const getVars = () => getter(instance.proxy);
9184
- const setVars = (vars) => {
9185
- if (instance.ce) setVarsOnNode(instance.ce, vars);
9186
- else setVarsOnVNode(instance.subTree, vars);
9187
- };
9188
- baseUseCssVars(instance, () => instance.subTree.el.parentNode, getVars, setVars);
9189
- }
9190
- function setVarsOnVNode(vnode, vars) {
9191
- if (vnode.shapeFlag & 128) {
9192
- const suspense = vnode.suspense;
9193
- vnode = suspense.activeBranch;
9194
- if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => {
9195
- setVarsOnVNode(suspense.activeBranch, vars);
9196
- });
9197
- }
9198
- while (vnode.component) vnode = vnode.component.subTree;
9199
- if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars);
9200
- else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars));
9201
- else if (vnode.type === Static) {
9202
- let { el, anchor } = vnode;
9203
- while (el) {
9204
- setVarsOnNode(el, vars);
9205
- if (el === anchor) break;
9206
- el = el.nextSibling;
9207
- }
9208
- }
9209
- }
9210
- /**
9211
- * @internal
9212
- * shared between vdom and vapor
9213
- */
9214
- function baseUseCssVars(instance, getParentNode, getVars, setVars) {
9215
9220
  /* v8 ignore start */
9216
9221
  if (!instance) {
9217
9222
  warn(`useCssVars is called without current active component instance.`);
9218
9223
  return;
9219
9224
  }
9225
+ /* v8 ignore stop */
9226
+ const getVars = () => getter(instance.proxy);
9220
9227
  instance.getCssVars = getVars;
9221
9228
  const updateTeleports = instance.ut = (vars = getVars()) => {
9222
9229
  Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach((node) => setVarsOnNode(node, vars));
9223
9230
  };
9224
9231
  const applyCssVars = (vars = getVars()) => {
9225
- setVars(vars);
9232
+ if (instance.ce) setVarsOnNode(instance.ce, vars);
9233
+ else setVarsOnVNode(instance.subTree, vars);
9226
9234
  updateTeleports(vars);
9227
9235
  };
9228
9236
  onBeforeUpdate(() => {
@@ -9235,10 +9243,37 @@ function baseUseCssVars(instance, getParentNode, getVars, setVars) {
9235
9243
  applyCssVars(vars);
9236
9244
  }, NOOP, { flush: "post" });
9237
9245
  const ob = new MutationObserver(() => applyCssVars());
9238
- ob.observe(getParentNode(), { childList: true });
9246
+ ob.observe(instance.subTree.el.parentNode, { childList: true });
9239
9247
  onUnmounted(() => ob.disconnect());
9240
9248
  });
9241
9249
  }
9250
+ function setVarsOnVNode(vnode, vars) {
9251
+ if (vnode.shapeFlag & 128) {
9252
+ const suspense = vnode.suspense;
9253
+ vnode = suspense.activeBranch;
9254
+ if (suspense.pendingBranch && !suspense.isHydrating) suspense.effects.push(() => {
9255
+ setVarsOnVNode(suspense.activeBranch, vars);
9256
+ });
9257
+ }
9258
+ while (vnode.component) {
9259
+ const component = vnode.component;
9260
+ if (component.vapor) {
9261
+ component.appContext.vapor.applyCssVars(vnode, vars);
9262
+ return;
9263
+ }
9264
+ vnode = vnode.component.subTree;
9265
+ }
9266
+ if (vnode.shapeFlag & 1 && vnode.el) setVarsOnNode(vnode.el, vars);
9267
+ else if (vnode.type === Fragment) vnode.children.forEach((c) => setVarsOnVNode(c, vars));
9268
+ else if (vnode.type === Static) {
9269
+ let { el, anchor } = vnode;
9270
+ while (el) {
9271
+ setVarsOnNode(el, vars);
9272
+ if (el === anchor) break;
9273
+ el = el.nextSibling;
9274
+ }
9275
+ }
9276
+ }
9242
9277
  /**
9243
9278
  * @internal
9244
9279
  * shared between vdom and vapor