@vue/compat 3.4.7 → 3.4.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,3 +1,8 @@
1
+ /**
2
+ * @vue/compat v3.4.9
3
+ * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
+ * @license MIT
5
+ **/
1
6
  function makeMap(str, expectsLowerCase) {
2
7
  const set = new Set(str.split(","));
3
8
  return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
@@ -3159,8 +3164,6 @@ function hasPropsChanged(prevProps, nextProps, emitsOptions) {
3159
3164
  return false;
3160
3165
  }
3161
3166
  function updateHOCHostEl({ vnode, parent }, el) {
3162
- if (!el)
3163
- return;
3164
3167
  while (parent) {
3165
3168
  const root = parent.subTree;
3166
3169
  if (root.suspense && root.suspense.activeBranch === vnode) {
@@ -3256,6 +3259,10 @@ const SuspenseImpl = {
3256
3259
  rendererInternals
3257
3260
  );
3258
3261
  } else {
3262
+ if (parentSuspense && parentSuspense.deps > 0) {
3263
+ n2.suspense = n1.suspense;
3264
+ return;
3265
+ }
3259
3266
  patchSuspense(
3260
3267
  n1,
3261
3268
  n2,
@@ -3805,7 +3812,12 @@ function queueEffectWithSuspense(fn, suspense) {
3805
3812
  function setActiveBranch(suspense, branch) {
3806
3813
  suspense.activeBranch = branch;
3807
3814
  const { vnode, parentComponent } = suspense;
3808
- const el = vnode.el = branch.el;
3815
+ let el = branch.el;
3816
+ while (!el && branch.component) {
3817
+ branch = branch.component.subTree;
3818
+ el = branch.el;
3819
+ }
3820
+ vnode.el = el;
3809
3821
  if (parentComponent && parentComponent.subTree === vnode) {
3810
3822
  parentComponent.vnode.el = el;
3811
3823
  updateHOCHostEl(parentComponent, el);
@@ -5897,58 +5909,6 @@ function useSlots() {
5897
5909
  function useAttrs() {
5898
5910
  return getContext().attrs;
5899
5911
  }
5900
- function useModel(props, name, options = EMPTY_OBJ) {
5901
- const i = getCurrentInstance();
5902
- if (!i) {
5903
- warn$1(`useModel() called without active instance.`);
5904
- return ref();
5905
- }
5906
- if (!i.propsOptions[0][name]) {
5907
- warn$1(`useModel() called with prop "${name}" which is not declared.`);
5908
- return ref();
5909
- }
5910
- const camelizedName = camelize(name);
5911
- const hyphenatedName = hyphenate(name);
5912
- const res = customRef((track, trigger) => {
5913
- let localValue;
5914
- watchSyncEffect(() => {
5915
- const propValue = props[name];
5916
- if (hasChanged(localValue, propValue)) {
5917
- localValue = propValue;
5918
- trigger();
5919
- }
5920
- });
5921
- return {
5922
- get() {
5923
- track();
5924
- return options.get ? options.get(localValue) : localValue;
5925
- },
5926
- set(value) {
5927
- const rawProps = i.vnode.props;
5928
- if (!(rawProps && // check if parent has passed v-model
5929
- (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
5930
- localValue = value;
5931
- trigger();
5932
- }
5933
- i.emit(`update:${name}`, options.set ? options.set(value) : value);
5934
- }
5935
- };
5936
- });
5937
- const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
5938
- res[Symbol.iterator] = () => {
5939
- let i2 = 0;
5940
- return {
5941
- next() {
5942
- if (i2 < 2) {
5943
- return { value: i2++ ? props[modifierKey] || {} : res, done: false };
5944
- } else {
5945
- return { done: true };
5946
- }
5947
- }
5948
- };
5949
- };
5950
- return res;
5951
- }
5952
5912
  function getContext() {
5953
5913
  const i = getCurrentInstance();
5954
5914
  if (!i) {
@@ -6520,7 +6480,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6520
6480
  return vm;
6521
6481
  }
6522
6482
  }
6523
- Vue.version = `2.6.14-compat:${"3.4.7"}`;
6483
+ Vue.version = `2.6.14-compat:${"3.4.9"}`;
6524
6484
  Vue.config = singletonApp.config;
6525
6485
  Vue.use = (p, ...options) => {
6526
6486
  if (p && isFunction(p.install)) {
@@ -8246,29 +8206,43 @@ function propHasMismatch(el, key, clientValue, vnode) {
8246
8206
  let actual;
8247
8207
  let expected;
8248
8208
  if (key === "class") {
8249
- actual = toClassSet(el.getAttribute("class") || "");
8250
- expected = toClassSet(normalizeClass(clientValue));
8251
- if (!isSetEqual(actual, expected)) {
8209
+ actual = el.getAttribute("class");
8210
+ expected = normalizeClass(clientValue);
8211
+ if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
8252
8212
  mismatchType = mismatchKey = `class`;
8253
8213
  }
8254
8214
  } else if (key === "style") {
8255
- actual = toStyleMap(el.getAttribute("style") || "");
8256
- expected = toStyleMap(
8257
- isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue))
8258
- );
8215
+ actual = el.getAttribute("style");
8216
+ expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
8217
+ const actualMap = toStyleMap(actual);
8218
+ const expectedMap = toStyleMap(expected);
8259
8219
  if (vnode.dirs) {
8260
8220
  for (const { dir, value } of vnode.dirs) {
8261
8221
  if (dir.name === "show" && !value) {
8262
- expected.set("display", "none");
8222
+ expectedMap.set("display", "none");
8263
8223
  }
8264
8224
  }
8265
8225
  }
8266
- if (!isMapEqual(actual, expected)) {
8226
+ if (!isMapEqual(actualMap, expectedMap)) {
8267
8227
  mismatchType = mismatchKey = "style";
8268
8228
  }
8269
8229
  } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
8270
- actual = el.hasAttribute(key) ? el.getAttribute(key) : key in el ? el[key] : "";
8271
- expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? "" : false : clientValue == null ? "" : String(clientValue);
8230
+ if (isBooleanAttr(key)) {
8231
+ actual = el.hasAttribute(key);
8232
+ expected = includeBooleanAttr(clientValue);
8233
+ } else {
8234
+ if (el.hasAttribute(key)) {
8235
+ actual = el.getAttribute(key);
8236
+ } else if (key in el) {
8237
+ const serverValue = el[key];
8238
+ if (!isObject(serverValue)) {
8239
+ actual = serverValue == null ? "" : String(serverValue);
8240
+ }
8241
+ }
8242
+ if (!isObject(clientValue)) {
8243
+ expected = clientValue == null ? "" : String(clientValue);
8244
+ }
8245
+ }
8272
8246
  if (actual !== expected) {
8273
8247
  mismatchType = `attribute`;
8274
8248
  mismatchKey = key;
@@ -8276,15 +8250,15 @@ function propHasMismatch(el, key, clientValue, vnode) {
8276
8250
  }
8277
8251
  if (mismatchType) {
8278
8252
  const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`;
8279
- warn$1(
8280
- `Hydration ${mismatchType} mismatch on`,
8281
- el,
8282
- `
8253
+ const preSegment = `Hydration ${mismatchType} mismatch on`;
8254
+ const postSegment = `
8283
8255
  - rendered on server: ${format(actual)}
8284
8256
  - expected on client: ${format(expected)}
8285
8257
  Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
8286
- You should fix the source of the mismatch.`
8287
- );
8258
+ You should fix the source of the mismatch.`;
8259
+ {
8260
+ warn$1(preSegment, el, postSegment);
8261
+ }
8288
8262
  return true;
8289
8263
  }
8290
8264
  return false;
@@ -11047,6 +11021,59 @@ const computed = (getterOrOptions, debugOptions) => {
11047
11021
  return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
11048
11022
  };
11049
11023
 
11024
+ function useModel(props, name, options = EMPTY_OBJ) {
11025
+ const i = getCurrentInstance();
11026
+ if (!i) {
11027
+ warn$1(`useModel() called without active instance.`);
11028
+ return ref();
11029
+ }
11030
+ if (!i.propsOptions[0][name]) {
11031
+ warn$1(`useModel() called with prop "${name}" which is not declared.`);
11032
+ return ref();
11033
+ }
11034
+ const camelizedName = camelize(name);
11035
+ const hyphenatedName = hyphenate(name);
11036
+ const res = customRef((track, trigger) => {
11037
+ let localValue;
11038
+ watchSyncEffect(() => {
11039
+ const propValue = props[name];
11040
+ if (hasChanged(localValue, propValue)) {
11041
+ localValue = propValue;
11042
+ trigger();
11043
+ }
11044
+ });
11045
+ return {
11046
+ get() {
11047
+ track();
11048
+ return options.get ? options.get(localValue) : localValue;
11049
+ },
11050
+ set(value) {
11051
+ const rawProps = i.vnode.props;
11052
+ if (!(rawProps && // check if parent has passed v-model
11053
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
11054
+ localValue = value;
11055
+ trigger();
11056
+ }
11057
+ i.emit(`update:${name}`, options.set ? options.set(value) : value);
11058
+ }
11059
+ };
11060
+ });
11061
+ const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
11062
+ res[Symbol.iterator] = () => {
11063
+ let i2 = 0;
11064
+ return {
11065
+ next() {
11066
+ if (i2 < 2) {
11067
+ return { value: i2++ ? props[modifierKey] || {} : res, done: false };
11068
+ } else {
11069
+ return { done: true };
11070
+ }
11071
+ }
11072
+ };
11073
+ };
11074
+ return res;
11075
+ }
11076
+
11050
11077
  function h(type, propsOrChildren, children) {
11051
11078
  const l = arguments.length;
11052
11079
  if (l === 2) {
@@ -11269,7 +11296,7 @@ function isMemoSame(cached, memo) {
11269
11296
  return true;
11270
11297
  }
11271
11298
 
11272
- const version = "3.4.7";
11299
+ const version = "3.4.9";
11273
11300
  const warn = warn$1 ;
11274
11301
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11275
11302
  const devtools = devtools$1 ;
@@ -11782,6 +11809,7 @@ function setVarsOnNode(el, vars) {
11782
11809
 
11783
11810
  function patchStyle(el, prev, next) {
11784
11811
  const style = el.style;
11812
+ const currentDisplay = style.display;
11785
11813
  const isCssString = isString(next);
11786
11814
  if (next && !isCssString) {
11787
11815
  if (prev && !isString(prev)) {
@@ -11795,7 +11823,6 @@ function patchStyle(el, prev, next) {
11795
11823
  setStyle(style, key, next[key]);
11796
11824
  }
11797
11825
  } else {
11798
- const currentDisplay = style.display;
11799
11826
  if (isCssString) {
11800
11827
  if (prev !== next) {
11801
11828
  const cssVarText = style[CSS_VAR_TEXT];
@@ -11807,9 +11834,9 @@ function patchStyle(el, prev, next) {
11807
11834
  } else if (prev) {
11808
11835
  el.removeAttribute("style");
11809
11836
  }
11810
- if (vShowOldKey in el) {
11811
- style.display = currentDisplay;
11812
- }
11837
+ }
11838
+ if (vShowOldKey in el) {
11839
+ style.display = currentDisplay;
11813
11840
  }
11814
11841
  }
11815
11842
  const semicolonRE = /[^\\];\s*$/;