@vue/compat 3.4.4 → 3.4.6

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
@@ -1940,7 +1940,9 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1940
1940
  }
1941
1941
  function flushPostFlushCbs(seen) {
1942
1942
  if (pendingPostFlushCbs.length) {
1943
- const deduped = [...new Set(pendingPostFlushCbs)];
1943
+ const deduped = [...new Set(pendingPostFlushCbs)].sort(
1944
+ (a, b) => getId(a) - getId(b)
1945
+ );
1944
1946
  pendingPostFlushCbs.length = 0;
1945
1947
  if (activePostFlushCbs) {
1946
1948
  activePostFlushCbs.push(...deduped);
@@ -1950,7 +1952,6 @@ function flushPostFlushCbs(seen) {
1950
1952
  {
1951
1953
  seen = seen || /* @__PURE__ */ new Map();
1952
1954
  }
1953
- activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
1954
1955
  for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
1955
1956
  if (checkRecursiveUpdates(seen, activePostFlushCbs[postFlushIndex])) {
1956
1957
  continue;
@@ -3564,6 +3565,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3564
3565
  {
3565
3566
  assertNumber(timeout, `Suspense timeout`);
3566
3567
  }
3568
+ const initialAnchor = anchor;
3567
3569
  const suspense = {
3568
3570
  vnode,
3569
3571
  parent: parentSuspense,
@@ -3571,7 +3573,6 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3571
3573
  namespace,
3572
3574
  container,
3573
3575
  hiddenContainer,
3574
- anchor,
3575
3576
  deps: 0,
3576
3577
  pendingId: suspenseId++,
3577
3578
  timeout: typeof timeout === "number" ? timeout : -1,
@@ -3614,20 +3615,21 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3614
3615
  move(
3615
3616
  pendingBranch,
3616
3617
  container2,
3617
- next(activeBranch),
3618
+ anchor === initialAnchor ? next(activeBranch) : anchor,
3618
3619
  0
3619
3620
  );
3620
3621
  queuePostFlushCb(effects);
3621
3622
  }
3622
3623
  };
3623
3624
  }
3624
- let { anchor: anchor2 } = suspense;
3625
3625
  if (activeBranch) {
3626
- anchor2 = next(activeBranch);
3626
+ if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
3627
+ anchor = next(activeBranch);
3628
+ }
3627
3629
  unmount(activeBranch, parentComponent2, suspense, true);
3628
3630
  }
3629
3631
  if (!delayEnter) {
3630
- move(pendingBranch, container2, anchor2, 0);
3632
+ move(pendingBranch, container2, anchor, 0);
3631
3633
  }
3632
3634
  }
3633
3635
  setActiveBranch(suspense, pendingBranch);
@@ -4110,10 +4112,11 @@ function doWatch(source, cb, {
4110
4112
  scheduler = () => queueJob(job);
4111
4113
  }
4112
4114
  const effect = new ReactiveEffect(getter, NOOP, scheduler);
4115
+ const scope = getCurrentScope();
4113
4116
  const unwatch = () => {
4114
4117
  effect.stop();
4115
- if (instance && instance.scope) {
4116
- remove(instance.scope.effects, effect);
4118
+ if (scope) {
4119
+ remove(scope.effects, effect);
4117
4120
  }
4118
4121
  };
4119
4122
  {
@@ -6601,7 +6604,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6601
6604
  return vm;
6602
6605
  }
6603
6606
  }
6604
- Vue.version = `2.6.14-compat:${"3.4.4"}`;
6607
+ Vue.version = `2.6.14-compat:${"3.4.6"}`;
6605
6608
  Vue.config = singletonApp.config;
6606
6609
  Vue.use = (p, ...options) => {
6607
6610
  if (p && isFunction(p.install)) {
@@ -8146,7 +8149,7 @@ Server rendered element contains more child nodes than client vdom.`
8146
8149
  if (props) {
8147
8150
  {
8148
8151
  for (const key in props) {
8149
- if (propHasMismatch(el, key, props[key])) {
8152
+ if (propHasMismatch(el, key, props[key], vnode)) {
8150
8153
  hasMismatch = true;
8151
8154
  }
8152
8155
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
@@ -8321,7 +8324,7 @@ Server rendered element contains fewer child nodes than client vdom.`
8321
8324
  };
8322
8325
  return [hydrate, hydrateNode];
8323
8326
  }
8324
- function propHasMismatch(el, key, clientValue) {
8327
+ function propHasMismatch(el, key, clientValue, vnode) {
8325
8328
  let mismatchType;
8326
8329
  let mismatchKey;
8327
8330
  let actual;
@@ -8333,14 +8336,23 @@ function propHasMismatch(el, key, clientValue) {
8333
8336
  mismatchType = mismatchKey = `class`;
8334
8337
  }
8335
8338
  } else if (key === "style") {
8336
- actual = el.getAttribute("style");
8337
- expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
8338
- if (actual !== expected) {
8339
+ actual = toStyleMap(el.getAttribute("style") || "");
8340
+ expected = toStyleMap(
8341
+ isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue))
8342
+ );
8343
+ if (vnode.dirs) {
8344
+ for (const { dir, value } of vnode.dirs) {
8345
+ if (dir.name === "show" && !value) {
8346
+ expected.set("display", "none");
8347
+ }
8348
+ }
8349
+ }
8350
+ if (!isMapEqual(actual, expected)) {
8339
8351
  mismatchType = mismatchKey = "style";
8340
8352
  }
8341
8353
  } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
8342
- actual = el.hasAttribute(key) && el.getAttribute(key);
8343
- expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? "" : false : clientValue == null ? false : String(clientValue);
8354
+ actual = el.hasAttribute(key) ? el.getAttribute(key) : key in el ? el[key] : "";
8355
+ expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? "" : false : clientValue == null ? "" : String(clientValue);
8344
8356
  if (actual !== expected) {
8345
8357
  mismatchType = `attribute`;
8346
8358
  mismatchKey = key;
@@ -8375,6 +8387,29 @@ function isSetEqual(a, b) {
8375
8387
  }
8376
8388
  return true;
8377
8389
  }
8390
+ function toStyleMap(str) {
8391
+ const styleMap = /* @__PURE__ */ new Map();
8392
+ for (const item of str.split(";")) {
8393
+ let [key, value] = item.split(":");
8394
+ key = key == null ? void 0 : key.trim();
8395
+ value = value == null ? void 0 : value.trim();
8396
+ if (key && value) {
8397
+ styleMap.set(key, value);
8398
+ }
8399
+ }
8400
+ return styleMap;
8401
+ }
8402
+ function isMapEqual(a, b) {
8403
+ if (a.size !== b.size) {
8404
+ return false;
8405
+ }
8406
+ for (const [key, value] of a) {
8407
+ if (value !== b.get(key)) {
8408
+ return false;
8409
+ }
8410
+ }
8411
+ return true;
8412
+ }
8378
8413
 
8379
8414
  let supported;
8380
8415
  let perf;
@@ -8963,7 +8998,11 @@ function baseCreateRenderer(options, createHydrationFns) {
8963
8998
  hostInsert(fragmentStartAnchor, container, anchor);
8964
8999
  hostInsert(fragmentEndAnchor, container, anchor);
8965
9000
  mountChildren(
8966
- n2.children,
9001
+ // #10007
9002
+ // such fragment like `<></>` will be compiled into
9003
+ // a fragment which doesn't have a children.
9004
+ // In this case fallback to an empty array
9005
+ n2.children || [],
8967
9006
  container,
8968
9007
  fragmentEndAnchor,
8969
9008
  parentComponent,
@@ -9831,6 +9870,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9831
9870
  }
9832
9871
  return hostNextSibling(vnode.anchor || vnode.el);
9833
9872
  };
9873
+ let isFlushing = false;
9834
9874
  const render = (vnode, container, namespace) => {
9835
9875
  if (vnode == null) {
9836
9876
  if (container._vnode) {
@@ -9847,8 +9887,12 @@ function baseCreateRenderer(options, createHydrationFns) {
9847
9887
  namespace
9848
9888
  );
9849
9889
  }
9850
- flushPreFlushCbs();
9851
- flushPostFlushCbs();
9890
+ if (!isFlushing) {
9891
+ isFlushing = true;
9892
+ flushPreFlushCbs();
9893
+ flushPostFlushCbs();
9894
+ isFlushing = false;
9895
+ }
9852
9896
  container._vnode = vnode;
9853
9897
  };
9854
9898
  const internals = {
@@ -10752,7 +10796,14 @@ function createComponentInstance(vnode, parent, suspense) {
10752
10796
  return instance;
10753
10797
  }
10754
10798
  let currentInstance = null;
10755
- const getCurrentInstance = () => currentInstance || currentRenderingInstance;
10799
+ const getCurrentInstance = () => {
10800
+ if (isInComputedGetter) {
10801
+ warn$1(
10802
+ `getCurrentInstance() called inside a computed getter. This is incorrect usage as computed getters are not guaranteed to be executed with an active component instance. If you are using a composable inside a computed getter, move it ouside to the setup scope.`
10803
+ );
10804
+ }
10805
+ return currentInstance || currentRenderingInstance;
10806
+ };
10756
10807
  let internalSetCurrentInstance;
10757
10808
  let setInSSRSetupState;
10758
10809
  {
@@ -11095,7 +11146,25 @@ function isClassComponent(value) {
11095
11146
  return isFunction(value) && "__vccOpts" in value;
11096
11147
  }
11097
11148
 
11149
+ let isInComputedGetter = false;
11150
+ function wrapComputedGetter(getter) {
11151
+ return () => {
11152
+ isInComputedGetter = true;
11153
+ try {
11154
+ return getter();
11155
+ } finally {
11156
+ isInComputedGetter = false;
11157
+ }
11158
+ };
11159
+ }
11098
11160
  const computed = (getterOrOptions, debugOptions) => {
11161
+ {
11162
+ if (isFunction(getterOrOptions)) {
11163
+ getterOrOptions = wrapComputedGetter(getterOrOptions);
11164
+ } else {
11165
+ getterOrOptions.get = wrapComputedGetter(getterOrOptions.get);
11166
+ }
11167
+ }
11099
11168
  return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
11100
11169
  };
11101
11170
 
@@ -11321,7 +11390,7 @@ function isMemoSame(cached, memo) {
11321
11390
  return true;
11322
11391
  }
11323
11392
 
11324
- const version = "3.4.4";
11393
+ const version = "3.4.6";
11325
11394
  const warn = warn$1 ;
11326
11395
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11327
11396
  const devtools = devtools$1 ;
@@ -11770,6 +11839,9 @@ const vShow = {
11770
11839
  setDisplay(el, value);
11771
11840
  }
11772
11841
  };
11842
+ {
11843
+ vShow.name = "show";
11844
+ }
11773
11845
  function setDisplay(el, value) {
11774
11846
  el.style.display = value ? el[vShowOldKey] : "none";
11775
11847
  }
@@ -14488,6 +14560,18 @@ function isInDestructureAssignment(parent, parentStack) {
14488
14560
  }
14489
14561
  return false;
14490
14562
  }
14563
+ function isInNewExpression(parentStack) {
14564
+ let i = parentStack.length;
14565
+ while (i--) {
14566
+ const p = parentStack[i];
14567
+ if (p.type === "NewExpression") {
14568
+ return true;
14569
+ } else if (p.type !== "MemberExpression") {
14570
+ break;
14571
+ }
14572
+ }
14573
+ return false;
14574
+ }
14491
14575
  function walkFunctionParams(node, onIdent) {
14492
14576
  for (const p of node.params) {
14493
14577
  for (const id of extractIdentifiers(p)) {
@@ -17073,12 +17157,17 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
17073
17157
  const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
17074
17158
  const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
17075
17159
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
17160
+ const isNewExpression = parent && isInNewExpression(parentStack);
17161
+ const wrapWithUnref = (raw2) => {
17162
+ const wrapped = `${context.helperString(UNREF)}(${raw2})`;
17163
+ return isNewExpression ? `(${wrapped})` : wrapped;
17164
+ };
17076
17165
  if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
17077
17166
  return raw;
17078
17167
  } else if (type === "setup-ref") {
17079
17168
  return `${raw}.value`;
17080
17169
  } else if (type === "setup-maybe-ref") {
17081
- return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : `${context.helperString(UNREF)}(${raw})`;
17170
+ return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
17082
17171
  } else if (type === "setup-let") {
17083
17172
  if (isAssignmentLVal) {
17084
17173
  const { right: rVal, operator } = parent;
@@ -17105,7 +17194,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
17105
17194
  } else if (isDestructureAssignment) {
17106
17195
  return raw;
17107
17196
  } else {
17108
- return `${context.helperString(UNREF)}(${raw})`;
17197
+ return wrapWithUnref(raw);
17109
17198
  }
17110
17199
  } else if (type === "props") {
17111
17200
  return genPropsAccessExp(raw);
@@ -1657,14 +1657,15 @@ function flushPreFlushCbs(instance, seen, i = isFlushing ? flushIndex + 1 : 0) {
1657
1657
  }
1658
1658
  function flushPostFlushCbs(seen) {
1659
1659
  if (pendingPostFlushCbs.length) {
1660
- const deduped = [...new Set(pendingPostFlushCbs)];
1660
+ const deduped = [...new Set(pendingPostFlushCbs)].sort(
1661
+ (a, b) => getId(a) - getId(b)
1662
+ );
1661
1663
  pendingPostFlushCbs.length = 0;
1662
1664
  if (activePostFlushCbs) {
1663
1665
  activePostFlushCbs.push(...deduped);
1664
1666
  return;
1665
1667
  }
1666
1668
  activePostFlushCbs = deduped;
1667
- activePostFlushCbs.sort((a, b) => getId(a) - getId(b));
1668
1669
  for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
1669
1670
  activePostFlushCbs[postFlushIndex]();
1670
1671
  }
@@ -2617,6 +2618,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2617
2618
  }
2618
2619
  }
2619
2620
  const timeout = vnode.props ? toNumber(vnode.props.timeout) : void 0;
2621
+ const initialAnchor = anchor;
2620
2622
  const suspense = {
2621
2623
  vnode,
2622
2624
  parent: parentSuspense,
@@ -2624,7 +2626,6 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2624
2626
  namespace,
2625
2627
  container,
2626
2628
  hiddenContainer,
2627
- anchor,
2628
2629
  deps: 0,
2629
2630
  pendingId: suspenseId++,
2630
2631
  timeout: typeof timeout === "number" ? timeout : -1,
@@ -2655,20 +2656,21 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2655
2656
  move(
2656
2657
  pendingBranch,
2657
2658
  container2,
2658
- next(activeBranch),
2659
+ anchor === initialAnchor ? next(activeBranch) : anchor,
2659
2660
  0
2660
2661
  );
2661
2662
  queuePostFlushCb(effects);
2662
2663
  }
2663
2664
  };
2664
2665
  }
2665
- let { anchor: anchor2 } = suspense;
2666
2666
  if (activeBranch) {
2667
- anchor2 = next(activeBranch);
2667
+ if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
2668
+ anchor = next(activeBranch);
2669
+ }
2668
2670
  unmount(activeBranch, parentComponent2, suspense, true);
2669
2671
  }
2670
2672
  if (!delayEnter) {
2671
- move(pendingBranch, container2, anchor2, 0);
2673
+ move(pendingBranch, container2, anchor, 0);
2672
2674
  }
2673
2675
  }
2674
2676
  setActiveBranch(suspense, pendingBranch);
@@ -3100,10 +3102,11 @@ function doWatch(source, cb, {
3100
3102
  scheduler = () => queueJob(job);
3101
3103
  }
3102
3104
  const effect = new ReactiveEffect(getter, NOOP, scheduler);
3105
+ const scope = getCurrentScope();
3103
3106
  const unwatch = () => {
3104
3107
  effect.stop();
3105
- if (instance && instance.scope) {
3106
- remove(instance.scope.effects, effect);
3108
+ if (scope) {
3109
+ remove(scope.effects, effect);
3107
3110
  }
3108
3111
  };
3109
3112
  if (cb) {
@@ -5282,7 +5285,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
5282
5285
  return vm;
5283
5286
  }
5284
5287
  }
5285
- Vue.version = `2.6.14-compat:${"3.4.4"}`;
5288
+ Vue.version = `2.6.14-compat:${"3.4.6"}`;
5286
5289
  Vue.config = singletonApp.config;
5287
5290
  Vue.use = (p, ...options) => {
5288
5291
  if (p && isFunction(p.install)) {
@@ -7179,7 +7182,11 @@ function baseCreateRenderer(options, createHydrationFns) {
7179
7182
  hostInsert(fragmentStartAnchor, container, anchor);
7180
7183
  hostInsert(fragmentEndAnchor, container, anchor);
7181
7184
  mountChildren(
7182
- n2.children,
7185
+ // #10007
7186
+ // such fragment like `<></>` will be compiled into
7187
+ // a fragment which doesn't have a children.
7188
+ // In this case fallback to an empty array
7189
+ n2.children || [],
7183
7190
  container,
7184
7191
  fragmentEndAnchor,
7185
7192
  parentComponent,
@@ -7961,6 +7968,7 @@ function baseCreateRenderer(options, createHydrationFns) {
7961
7968
  }
7962
7969
  return hostNextSibling(vnode.anchor || vnode.el);
7963
7970
  };
7971
+ let isFlushing = false;
7964
7972
  const render = (vnode, container, namespace) => {
7965
7973
  if (vnode == null) {
7966
7974
  if (container._vnode) {
@@ -7977,8 +7985,12 @@ function baseCreateRenderer(options, createHydrationFns) {
7977
7985
  namespace
7978
7986
  );
7979
7987
  }
7980
- flushPreFlushCbs();
7981
- flushPostFlushCbs();
7988
+ if (!isFlushing) {
7989
+ isFlushing = true;
7990
+ flushPreFlushCbs();
7991
+ flushPostFlushCbs();
7992
+ isFlushing = false;
7993
+ }
7982
7994
  container._vnode = vnode;
7983
7995
  };
7984
7996
  const internals = {
@@ -8822,7 +8834,9 @@ function createComponentInstance(vnode, parent, suspense) {
8822
8834
  return instance;
8823
8835
  }
8824
8836
  let currentInstance = null;
8825
- const getCurrentInstance = () => currentInstance || currentRenderingInstance;
8837
+ const getCurrentInstance = () => {
8838
+ return currentInstance || currentRenderingInstance;
8839
+ };
8826
8840
  let internalSetCurrentInstance;
8827
8841
  let setInSSRSetupState;
8828
8842
  {
@@ -9082,7 +9096,7 @@ function isMemoSame(cached, memo) {
9082
9096
  return true;
9083
9097
  }
9084
9098
 
9085
- const version = "3.4.4";
9099
+ const version = "3.4.6";
9086
9100
  const warn$1 = NOOP;
9087
9101
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9088
9102
  const devtools = void 0;
@@ -12078,6 +12092,18 @@ function isInDestructureAssignment(parent, parentStack) {
12078
12092
  }
12079
12093
  return false;
12080
12094
  }
12095
+ function isInNewExpression(parentStack) {
12096
+ let i = parentStack.length;
12097
+ while (i--) {
12098
+ const p = parentStack[i];
12099
+ if (p.type === "NewExpression") {
12100
+ return true;
12101
+ } else if (p.type !== "MemberExpression") {
12102
+ break;
12103
+ }
12104
+ }
12105
+ return false;
12106
+ }
12081
12107
  function walkFunctionParams(node, onIdent) {
12082
12108
  for (const p of node.params) {
12083
12109
  for (const id of extractIdentifiers(p)) {
@@ -14590,12 +14616,17 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
14590
14616
  const isAssignmentLVal = parent && parent.type === "AssignmentExpression" && parent.left === id;
14591
14617
  const isUpdateArg = parent && parent.type === "UpdateExpression" && parent.argument === id;
14592
14618
  const isDestructureAssignment = parent && isInDestructureAssignment(parent, parentStack);
14619
+ const isNewExpression = parent && isInNewExpression(parentStack);
14620
+ const wrapWithUnref = (raw2) => {
14621
+ const wrapped = `${context.helperString(UNREF)}(${raw2})`;
14622
+ return isNewExpression ? `(${wrapped})` : wrapped;
14623
+ };
14593
14624
  if (isConst(type) || type === "setup-reactive-const" || localVars[raw]) {
14594
14625
  return raw;
14595
14626
  } else if (type === "setup-ref") {
14596
14627
  return `${raw}.value`;
14597
14628
  } else if (type === "setup-maybe-ref") {
14598
- return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : `${context.helperString(UNREF)}(${raw})`;
14629
+ return isAssignmentLVal || isUpdateArg || isDestructureAssignment ? `${raw}.value` : wrapWithUnref(raw);
14599
14630
  } else if (type === "setup-let") {
14600
14631
  if (isAssignmentLVal) {
14601
14632
  const { right: rVal, operator } = parent;
@@ -14622,7 +14653,7 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
14622
14653
  } else if (isDestructureAssignment) {
14623
14654
  return raw;
14624
14655
  } else {
14625
- return `${context.helperString(UNREF)}(${raw})`;
14656
+ return wrapWithUnref(raw);
14626
14657
  }
14627
14658
  } else if (type === "props") {
14628
14659
  return genPropsAccessExp(raw);