vue 3.4.5 → 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.
@@ -1889,7 +1889,9 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1889
1889
  }
1890
1890
  function flushPostFlushCbs(seen) {
1891
1891
  if (pendingPostFlushCbs.length) {
1892
- const deduped = [...new Set(pendingPostFlushCbs)];
1892
+ const deduped = [...new Set(pendingPostFlushCbs)].sort(
1893
+ (a, b) => getId(a) - getId(b)
1894
+ );
1893
1895
  pendingPostFlushCbs.length = 0;
1894
1896
  if (activePostFlushCbs) {
1895
1897
  activePostFlushCbs.push(...deduped);
@@ -1899,7 +1901,6 @@ function flushPostFlushCbs(seen) {
1899
1901
  {
1900
1902
  seen = seen || /* @__PURE__ */ new Map();
1901
1903
  }
1902
- activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
1903
1904
  for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
1904
1905
  if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
1905
1906
  continue;
@@ -2992,6 +2993,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2992
2993
  {
2993
2994
  assertNumber(timeout, `Suspense timeout`);
2994
2995
  }
2996
+ const initialAnchor = anchor;
2995
2997
  const suspense = {
2996
2998
  vnode,
2997
2999
  parent: parentSuspense,
@@ -2999,7 +3001,6 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2999
3001
  namespace,
3000
3002
  container,
3001
3003
  hiddenContainer,
3002
- anchor,
3003
3004
  deps: 0,
3004
3005
  pendingId: suspenseId++,
3005
3006
  timeout: typeof timeout === "number" ? timeout : -1,
@@ -3042,20 +3043,21 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3042
3043
  move(
3043
3044
  pendingBranch,
3044
3045
  container2,
3045
- next(activeBranch),
3046
+ anchor === initialAnchor ? next(activeBranch) : anchor,
3046
3047
  0
3047
3048
  );
3048
3049
  queuePostFlushCb(effects);
3049
3050
  }
3050
3051
  };
3051
3052
  }
3052
- let { anchor: anchor2 } = suspense;
3053
3053
  if (activeBranch) {
3054
- anchor2 = next(activeBranch);
3054
+ if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
3055
+ anchor = next(activeBranch);
3056
+ }
3055
3057
  unmount(activeBranch, parentComponent2, suspense, true);
3056
3058
  }
3057
3059
  if (!delayEnter) {
3058
- move(pendingBranch, container2, anchor2, 0);
3060
+ move(pendingBranch, container2, anchor, 0);
3059
3061
  }
3060
3062
  }
3061
3063
  setActiveBranch(suspense, pendingBranch);
@@ -3508,14 +3510,9 @@ function instanceWatch(source, value, options) {
3508
3510
  cb = value.handler;
3509
3511
  options = value;
3510
3512
  }
3511
- const cur = currentInstance;
3512
- setCurrentInstance(this);
3513
+ const reset = setCurrentInstance(this);
3513
3514
  const res = doWatch(getter, cb.bind(publicThis), options);
3514
- if (cur) {
3515
- setCurrentInstance(cur);
3516
- } else {
3517
- unsetCurrentInstance();
3518
- }
3515
+ reset();
3519
3516
  return res;
3520
3517
  }
3521
3518
  function createPathGetter(ctx, path) {
@@ -3567,12 +3564,11 @@ function validateDirectiveName(name) {
3567
3564
  }
3568
3565
  }
3569
3566
  function withDirectives(vnode, directives) {
3570
- const internalInstance = currentRenderingInstance;
3571
- if (internalInstance === null) {
3567
+ if (currentRenderingInstance === null) {
3572
3568
  warn$1(`withDirectives can only be used inside render functions.`);
3573
3569
  return vnode;
3574
3570
  }
3575
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
3571
+ const instance = getExposeProxy(currentRenderingInstance) || currentRenderingInstance.proxy;
3576
3572
  const bindings = vnode.dirs || (vnode.dirs = []);
3577
3573
  for (let i = 0; i < directives.length; i++) {
3578
3574
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -4352,9 +4348,9 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4352
4348
  return;
4353
4349
  }
4354
4350
  pauseTracking();
4355
- setCurrentInstance(target);
4351
+ const reset = setCurrentInstance(target);
4356
4352
  const res = callWithAsyncErrorHandling(hook, target, type, args);
4357
- unsetCurrentInstance();
4353
+ reset();
4358
4354
  resetTracking();
4359
4355
  return res;
4360
4356
  });
@@ -5739,12 +5735,12 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
5739
5735
  if (key in propsDefaults) {
5740
5736
  value = propsDefaults[key];
5741
5737
  } else {
5742
- setCurrentInstance(instance);
5738
+ const reset = setCurrentInstance(instance);
5743
5739
  value = propsDefaults[key] = defaultValue.call(
5744
5740
  null,
5745
5741
  props
5746
5742
  );
5747
- unsetCurrentInstance();
5743
+ reset();
5748
5744
  }
5749
5745
  } else {
5750
5746
  value = defaultValue;
@@ -6439,7 +6435,7 @@ Server rendered element contains more child nodes than client vdom.`
6439
6435
  if (props) {
6440
6436
  {
6441
6437
  for (const key in props) {
6442
- if (propHasMismatch(el, key, props[key])) {
6438
+ if (propHasMismatch(el, key, props[key], vnode)) {
6443
6439
  hasMismatch = true;
6444
6440
  }
6445
6441
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
@@ -6614,7 +6610,7 @@ Server rendered element contains fewer child nodes than client vdom.`
6614
6610
  };
6615
6611
  return [hydrate, hydrateNode];
6616
6612
  }
6617
- function propHasMismatch(el, key, clientValue) {
6613
+ function propHasMismatch(el, key, clientValue, vnode) {
6618
6614
  let mismatchType;
6619
6615
  let mismatchKey;
6620
6616
  let actual;
@@ -6626,14 +6622,23 @@ function propHasMismatch(el, key, clientValue) {
6626
6622
  mismatchType = mismatchKey = `class`;
6627
6623
  }
6628
6624
  } else if (key === "style") {
6629
- actual = el.getAttribute("style");
6630
- expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
6631
- if (actual !== expected) {
6625
+ actual = toStyleMap(el.getAttribute("style") || "");
6626
+ expected = toStyleMap(
6627
+ isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue))
6628
+ );
6629
+ if (vnode.dirs) {
6630
+ for (const { dir, value } of vnode.dirs) {
6631
+ if (dir.name === "show" && !value) {
6632
+ expected.set("display", "none");
6633
+ }
6634
+ }
6635
+ }
6636
+ if (!isMapEqual(actual, expected)) {
6632
6637
  mismatchType = mismatchKey = "style";
6633
6638
  }
6634
6639
  } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
6635
- actual = el.hasAttribute(key) && el.getAttribute(key);
6636
- expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? "" : false : clientValue == null ? false : String(clientValue);
6640
+ actual = el.hasAttribute(key) ? el.getAttribute(key) : key in el ? el[key] : "";
6641
+ expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? "" : false : clientValue == null ? "" : String(clientValue);
6637
6642
  if (actual !== expected) {
6638
6643
  mismatchType = `attribute`;
6639
6644
  mismatchKey = key;
@@ -6668,6 +6673,29 @@ function isSetEqual(a, b) {
6668
6673
  }
6669
6674
  return true;
6670
6675
  }
6676
+ function toStyleMap(str) {
6677
+ const styleMap = /* @__PURE__ */ new Map();
6678
+ for (const item of str.split(";")) {
6679
+ let [key, value] = item.split(":");
6680
+ key = key == null ? void 0 : key.trim();
6681
+ value = value == null ? void 0 : value.trim();
6682
+ if (key && value) {
6683
+ styleMap.set(key, value);
6684
+ }
6685
+ }
6686
+ return styleMap;
6687
+ }
6688
+ function isMapEqual(a, b) {
6689
+ if (a.size !== b.size) {
6690
+ return false;
6691
+ }
6692
+ for (const [key, value] of a) {
6693
+ if (value !== b.get(key)) {
6694
+ return false;
6695
+ }
6696
+ }
6697
+ return true;
6698
+ }
6671
6699
 
6672
6700
  let supported;
6673
6701
  let perf;
@@ -7256,7 +7284,11 @@ function baseCreateRenderer(options, createHydrationFns) {
7256
7284
  hostInsert(fragmentStartAnchor, container, anchor);
7257
7285
  hostInsert(fragmentEndAnchor, container, anchor);
7258
7286
  mountChildren(
7259
- n2.children,
7287
+ // #10007
7288
+ // such fragment like `<></>` will be compiled into
7289
+ // a fragment which doesn't have a children.
7290
+ // In this case fallback to an empty array
7291
+ n2.children || [],
7260
7292
  container,
7261
7293
  fragmentEndAnchor,
7262
7294
  parentComponent,
@@ -8090,6 +8122,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8090
8122
  }
8091
8123
  return hostNextSibling(vnode.anchor || vnode.el);
8092
8124
  };
8125
+ let isFlushing = false;
8093
8126
  const render = (vnode, container, namespace) => {
8094
8127
  if (vnode == null) {
8095
8128
  if (container._vnode) {
@@ -8106,8 +8139,12 @@ function baseCreateRenderer(options, createHydrationFns) {
8106
8139
  namespace
8107
8140
  );
8108
8141
  }
8109
- flushPreFlushCbs();
8110
- flushPostFlushCbs();
8142
+ if (!isFlushing) {
8143
+ isFlushing = true;
8144
+ flushPreFlushCbs();
8145
+ flushPostFlushCbs();
8146
+ isFlushing = false;
8147
+ }
8111
8148
  container._vnode = vnode;
8112
8149
  };
8113
8150
  const internals = {
@@ -8962,8 +8999,13 @@ let setInSSRSetupState;
8962
8999
  };
8963
9000
  }
8964
9001
  const setCurrentInstance = (instance) => {
9002
+ const prev = currentInstance;
8965
9003
  internalSetCurrentInstance(instance);
8966
9004
  instance.scope.on();
9005
+ return () => {
9006
+ instance.scope.off();
9007
+ internalSetCurrentInstance(prev);
9008
+ };
8967
9009
  };
8968
9010
  const unsetCurrentInstance = () => {
8969
9011
  currentInstance && currentInstance.scope.off();
@@ -9025,7 +9067,7 @@ function setupStatefulComponent(instance, isSSR) {
9025
9067
  const { setup } = Component;
9026
9068
  if (setup) {
9027
9069
  const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
9028
- setCurrentInstance(instance);
9070
+ const reset = setCurrentInstance(instance);
9029
9071
  pauseTracking();
9030
9072
  const setupResult = callWithErrorHandling(
9031
9073
  setup,
@@ -9037,7 +9079,7 @@ function setupStatefulComponent(instance, isSSR) {
9037
9079
  ]
9038
9080
  );
9039
9081
  resetTracking();
9040
- unsetCurrentInstance();
9082
+ reset();
9041
9083
  if (isPromise(setupResult)) {
9042
9084
  setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
9043
9085
  if (isSSR) {
@@ -9131,13 +9173,13 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
9131
9173
  }
9132
9174
  }
9133
9175
  {
9134
- setCurrentInstance(instance);
9176
+ const reset = setCurrentInstance(instance);
9135
9177
  pauseTracking();
9136
9178
  try {
9137
9179
  applyOptions(instance);
9138
9180
  } finally {
9139
9181
  resetTracking();
9140
- unsetCurrentInstance();
9182
+ reset();
9141
9183
  }
9142
9184
  }
9143
9185
  if (!Component.render && instance.render === NOOP && !isSSR) {
@@ -9490,7 +9532,7 @@ function isMemoSame(cached, memo) {
9490
9532
  return true;
9491
9533
  }
9492
9534
 
9493
- const version = "3.4.5";
9535
+ const version = "3.4.7";
9494
9536
  const warn = warn$1 ;
9495
9537
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9496
9538
  const devtools = devtools$1 ;
@@ -9887,6 +9929,9 @@ const vShow = {
9887
9929
  setDisplay(el, value);
9888
9930
  }
9889
9931
  };
9932
+ {
9933
+ vShow.name = "show";
9934
+ }
9890
9935
  function setDisplay(el, value) {
9891
9936
  el.style.display = value ? el[vShowOldKey] : "none";
9892
9937
  }
@@ -13559,8 +13604,7 @@ function createTransformContext(root, {
13559
13604
  }
13560
13605
  context.parent.children.splice(removalIndex, 1);
13561
13606
  },
13562
- onNodeRemoved: () => {
13563
- },
13607
+ onNodeRemoved: NOOP,
13564
13608
  addIdentifiers(exp) {
13565
13609
  },
13566
13610
  removeIdentifiers(exp) {