@vue/compat 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;
@@ -3513,6 +3514,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3513
3514
  {
3514
3515
  assertNumber(timeout, `Suspense timeout`);
3515
3516
  }
3517
+ const initialAnchor = anchor;
3516
3518
  const suspense = {
3517
3519
  vnode,
3518
3520
  parent: parentSuspense,
@@ -3520,7 +3522,6 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3520
3522
  namespace,
3521
3523
  container,
3522
3524
  hiddenContainer,
3523
- anchor,
3524
3525
  deps: 0,
3525
3526
  pendingId: suspenseId++,
3526
3527
  timeout: typeof timeout === "number" ? timeout : -1,
@@ -3563,20 +3564,21 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3563
3564
  move(
3564
3565
  pendingBranch,
3565
3566
  container2,
3566
- next(activeBranch),
3567
+ anchor === initialAnchor ? next(activeBranch) : anchor,
3567
3568
  0
3568
3569
  );
3569
3570
  queuePostFlushCb(effects);
3570
3571
  }
3571
3572
  };
3572
3573
  }
3573
- let { anchor: anchor2 } = suspense;
3574
3574
  if (activeBranch) {
3575
- anchor2 = next(activeBranch);
3575
+ if (parentNode(activeBranch.el) !== suspense.hiddenContainer) {
3576
+ anchor = next(activeBranch);
3577
+ }
3576
3578
  unmount(activeBranch, parentComponent2, suspense, true);
3577
3579
  }
3578
3580
  if (!delayEnter) {
3579
- move(pendingBranch, container2, anchor2, 0);
3581
+ move(pendingBranch, container2, anchor, 0);
3580
3582
  }
3581
3583
  }
3582
3584
  setActiveBranch(suspense, pendingBranch);
@@ -4077,14 +4079,9 @@ function instanceWatch(source, value, options) {
4077
4079
  cb = value.handler;
4078
4080
  options = value;
4079
4081
  }
4080
- const cur = currentInstance;
4081
- setCurrentInstance(this);
4082
+ const reset = setCurrentInstance(this);
4082
4083
  const res = doWatch(getter, cb.bind(publicThis), options);
4083
- if (cur) {
4084
- setCurrentInstance(cur);
4085
- } else {
4086
- unsetCurrentInstance();
4087
- }
4084
+ reset();
4088
4085
  return res;
4089
4086
  }
4090
4087
  function createPathGetter(ctx, path) {
@@ -4136,12 +4133,11 @@ function validateDirectiveName(name) {
4136
4133
  }
4137
4134
  }
4138
4135
  function withDirectives(vnode, directives) {
4139
- const internalInstance = currentRenderingInstance;
4140
- if (internalInstance === null) {
4136
+ if (currentRenderingInstance === null) {
4141
4137
  warn$1(`withDirectives can only be used inside render functions.`);
4142
4138
  return vnode;
4143
4139
  }
4144
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
4140
+ const instance = getExposeProxy(currentRenderingInstance) || currentRenderingInstance.proxy;
4145
4141
  const bindings = vnode.dirs || (vnode.dirs = []);
4146
4142
  for (let i = 0; i < directives.length; i++) {
4147
4143
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -4930,9 +4926,9 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4930
4926
  return;
4931
4927
  }
4932
4928
  pauseTracking();
4933
- setCurrentInstance(target);
4929
+ const reset = setCurrentInstance(target);
4934
4930
  const res = callWithAsyncErrorHandling(hook, target, type, args);
4935
- unsetCurrentInstance();
4931
+ reset();
4936
4932
  resetTracking();
4937
4933
  return res;
4938
4934
  });
@@ -6524,7 +6520,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6524
6520
  return vm;
6525
6521
  }
6526
6522
  }
6527
- Vue.version = `2.6.14-compat:${"3.4.5"}`;
6523
+ Vue.version = `2.6.14-compat:${"3.4.7"}`;
6528
6524
  Vue.config = singletonApp.config;
6529
6525
  Vue.use = (p, ...options) => {
6530
6526
  if (p && isFunction(p.install)) {
@@ -7364,12 +7360,12 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
7364
7360
  if (key in propsDefaults) {
7365
7361
  value = propsDefaults[key];
7366
7362
  } else {
7367
- setCurrentInstance(instance);
7363
+ const reset = setCurrentInstance(instance);
7368
7364
  value = propsDefaults[key] = defaultValue.call(
7369
7365
  isCompatEnabled$1("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props, key) : null,
7370
7366
  props
7371
7367
  );
7372
- unsetCurrentInstance();
7368
+ reset();
7373
7369
  }
7374
7370
  } else {
7375
7371
  value = defaultValue;
@@ -8069,7 +8065,7 @@ Server rendered element contains more child nodes than client vdom.`
8069
8065
  if (props) {
8070
8066
  {
8071
8067
  for (const key in props) {
8072
- if (propHasMismatch(el, key, props[key])) {
8068
+ if (propHasMismatch(el, key, props[key], vnode)) {
8073
8069
  hasMismatch = true;
8074
8070
  }
8075
8071
  if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
@@ -8244,7 +8240,7 @@ Server rendered element contains fewer child nodes than client vdom.`
8244
8240
  };
8245
8241
  return [hydrate, hydrateNode];
8246
8242
  }
8247
- function propHasMismatch(el, key, clientValue) {
8243
+ function propHasMismatch(el, key, clientValue, vnode) {
8248
8244
  let mismatchType;
8249
8245
  let mismatchKey;
8250
8246
  let actual;
@@ -8256,14 +8252,23 @@ function propHasMismatch(el, key, clientValue) {
8256
8252
  mismatchType = mismatchKey = `class`;
8257
8253
  }
8258
8254
  } else if (key === "style") {
8259
- actual = el.getAttribute("style");
8260
- expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
8261
- if (actual !== expected) {
8255
+ actual = toStyleMap(el.getAttribute("style") || "");
8256
+ expected = toStyleMap(
8257
+ isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue))
8258
+ );
8259
+ if (vnode.dirs) {
8260
+ for (const { dir, value } of vnode.dirs) {
8261
+ if (dir.name === "show" && !value) {
8262
+ expected.set("display", "none");
8263
+ }
8264
+ }
8265
+ }
8266
+ if (!isMapEqual(actual, expected)) {
8262
8267
  mismatchType = mismatchKey = "style";
8263
8268
  }
8264
8269
  } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
8265
- actual = el.hasAttribute(key) && el.getAttribute(key);
8266
- expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? "" : false : clientValue == null ? false : String(clientValue);
8270
+ actual = el.hasAttribute(key) ? el.getAttribute(key) : key in el ? el[key] : "";
8271
+ expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? "" : false : clientValue == null ? "" : String(clientValue);
8267
8272
  if (actual !== expected) {
8268
8273
  mismatchType = `attribute`;
8269
8274
  mismatchKey = key;
@@ -8298,6 +8303,29 @@ function isSetEqual(a, b) {
8298
8303
  }
8299
8304
  return true;
8300
8305
  }
8306
+ function toStyleMap(str) {
8307
+ const styleMap = /* @__PURE__ */ new Map();
8308
+ for (const item of str.split(";")) {
8309
+ let [key, value] = item.split(":");
8310
+ key = key == null ? void 0 : key.trim();
8311
+ value = value == null ? void 0 : value.trim();
8312
+ if (key && value) {
8313
+ styleMap.set(key, value);
8314
+ }
8315
+ }
8316
+ return styleMap;
8317
+ }
8318
+ function isMapEqual(a, b) {
8319
+ if (a.size !== b.size) {
8320
+ return false;
8321
+ }
8322
+ for (const [key, value] of a) {
8323
+ if (value !== b.get(key)) {
8324
+ return false;
8325
+ }
8326
+ }
8327
+ return true;
8328
+ }
8301
8329
 
8302
8330
  let supported;
8303
8331
  let perf;
@@ -8886,7 +8914,11 @@ function baseCreateRenderer(options, createHydrationFns) {
8886
8914
  hostInsert(fragmentStartAnchor, container, anchor);
8887
8915
  hostInsert(fragmentEndAnchor, container, anchor);
8888
8916
  mountChildren(
8889
- n2.children,
8917
+ // #10007
8918
+ // such fragment like `<></>` will be compiled into
8919
+ // a fragment which doesn't have a children.
8920
+ // In this case fallback to an empty array
8921
+ n2.children || [],
8890
8922
  container,
8891
8923
  fragmentEndAnchor,
8892
8924
  parentComponent,
@@ -9754,6 +9786,7 @@ function baseCreateRenderer(options, createHydrationFns) {
9754
9786
  }
9755
9787
  return hostNextSibling(vnode.anchor || vnode.el);
9756
9788
  };
9789
+ let isFlushing = false;
9757
9790
  const render = (vnode, container, namespace) => {
9758
9791
  if (vnode == null) {
9759
9792
  if (container._vnode) {
@@ -9770,8 +9803,12 @@ function baseCreateRenderer(options, createHydrationFns) {
9770
9803
  namespace
9771
9804
  );
9772
9805
  }
9773
- flushPreFlushCbs();
9774
- flushPostFlushCbs();
9806
+ if (!isFlushing) {
9807
+ isFlushing = true;
9808
+ flushPreFlushCbs();
9809
+ flushPostFlushCbs();
9810
+ isFlushing = false;
9811
+ }
9775
9812
  container._vnode = vnode;
9776
9813
  };
9777
9814
  const internals = {
@@ -10687,8 +10724,13 @@ let setInSSRSetupState;
10687
10724
  };
10688
10725
  }
10689
10726
  const setCurrentInstance = (instance) => {
10727
+ const prev = currentInstance;
10690
10728
  internalSetCurrentInstance(instance);
10691
10729
  instance.scope.on();
10730
+ return () => {
10731
+ instance.scope.off();
10732
+ internalSetCurrentInstance(prev);
10733
+ };
10692
10734
  };
10693
10735
  const unsetCurrentInstance = () => {
10694
10736
  currentInstance && currentInstance.scope.off();
@@ -10750,7 +10792,7 @@ function setupStatefulComponent(instance, isSSR) {
10750
10792
  const { setup } = Component;
10751
10793
  if (setup) {
10752
10794
  const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
10753
- setCurrentInstance(instance);
10795
+ const reset = setCurrentInstance(instance);
10754
10796
  pauseTracking();
10755
10797
  const setupResult = callWithErrorHandling(
10756
10798
  setup,
@@ -10762,7 +10804,7 @@ function setupStatefulComponent(instance, isSSR) {
10762
10804
  ]
10763
10805
  );
10764
10806
  resetTracking();
10765
- unsetCurrentInstance();
10807
+ reset();
10766
10808
  if (isPromise(setupResult)) {
10767
10809
  setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
10768
10810
  if (isSSR) {
@@ -10868,13 +10910,13 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
10868
10910
  }
10869
10911
  }
10870
10912
  if (!skipOptions) {
10871
- setCurrentInstance(instance);
10913
+ const reset = setCurrentInstance(instance);
10872
10914
  pauseTracking();
10873
10915
  try {
10874
10916
  applyOptions(instance);
10875
10917
  } finally {
10876
10918
  resetTracking();
10877
- unsetCurrentInstance();
10919
+ reset();
10878
10920
  }
10879
10921
  }
10880
10922
  if (!Component.render && instance.render === NOOP && !isSSR) {
@@ -11227,7 +11269,7 @@ function isMemoSame(cached, memo) {
11227
11269
  return true;
11228
11270
  }
11229
11271
 
11230
- const version = "3.4.5";
11272
+ const version = "3.4.7";
11231
11273
  const warn = warn$1 ;
11232
11274
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11233
11275
  const devtools = devtools$1 ;
@@ -11668,6 +11710,9 @@ const vShow = {
11668
11710
  setDisplay(el, value);
11669
11711
  }
11670
11712
  };
11713
+ {
11714
+ vShow.name = "show";
11715
+ }
11671
11716
  function setDisplay(el, value) {
11672
11717
  el.style.display = value ? el[vShowOldKey] : "none";
11673
11718
  }
@@ -14996,7 +15041,7 @@ function onCloseTag(el, end, isImplied = false) {
14996
15041
  }
14997
15042
  }
14998
15043
  }
14999
- if (isCompatEnabled(
15044
+ if (!tokenizer.inSFCRoot && isCompatEnabled(
15000
15045
  "COMPILER_NATIVE_TEMPLATE",
15001
15046
  currentOptions
15002
15047
  ) && el.tag === "template" && !isFragmentTemplate(el)) {
@@ -15609,8 +15654,7 @@ function createTransformContext(root, {
15609
15654
  }
15610
15655
  context.parent.children.splice(removalIndex, 1);
15611
15656
  },
15612
- onNodeRemoved: () => {
15613
- },
15657
+ onNodeRemoved: NOOP,
15614
15658
  addIdentifiers(exp) {
15615
15659
  },
15616
15660
  removeIdentifiers(exp) {