@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);
@@ -3094,8 +3099,6 @@ function hasPropsChanged(prevProps, nextProps, emitsOptions) {
3094
3099
  return false;
3095
3100
  }
3096
3101
  function updateHOCHostEl({ vnode, parent }, el) {
3097
- if (!el)
3098
- return;
3099
3102
  while (parent) {
3100
3103
  const root = parent.subTree;
3101
3104
  if (root.suspense && root.suspense.activeBranch === vnode) {
@@ -3191,6 +3194,10 @@ const SuspenseImpl = {
3191
3194
  rendererInternals
3192
3195
  );
3193
3196
  } else {
3197
+ if (parentSuspense && parentSuspense.deps > 0) {
3198
+ n2.suspense = n1.suspense;
3199
+ return;
3200
+ }
3194
3201
  patchSuspense(
3195
3202
  n1,
3196
3203
  n2,
@@ -3740,7 +3747,12 @@ function queueEffectWithSuspense(fn, suspense) {
3740
3747
  function setActiveBranch(suspense, branch) {
3741
3748
  suspense.activeBranch = branch;
3742
3749
  const { vnode, parentComponent } = suspense;
3743
- const el = vnode.el = branch.el;
3750
+ let el = branch.el;
3751
+ while (!el && branch.component) {
3752
+ branch = branch.component.subTree;
3753
+ el = branch.el;
3754
+ }
3755
+ vnode.el = el;
3744
3756
  if (parentComponent && parentComponent.subTree === vnode) {
3745
3757
  parentComponent.vnode.el = el;
3746
3758
  updateHOCHostEl(parentComponent, el);
@@ -5832,58 +5844,6 @@ function useSlots() {
5832
5844
  function useAttrs() {
5833
5845
  return getContext().attrs;
5834
5846
  }
5835
- function useModel(props, name, options = EMPTY_OBJ) {
5836
- const i = getCurrentInstance();
5837
- if (!i) {
5838
- warn$1(`useModel() called without active instance.`);
5839
- return ref();
5840
- }
5841
- if (!i.propsOptions[0][name]) {
5842
- warn$1(`useModel() called with prop "${name}" which is not declared.`);
5843
- return ref();
5844
- }
5845
- const camelizedName = camelize(name);
5846
- const hyphenatedName = hyphenate(name);
5847
- const res = customRef((track, trigger) => {
5848
- let localValue;
5849
- watchSyncEffect(() => {
5850
- const propValue = props[name];
5851
- if (hasChanged(localValue, propValue)) {
5852
- localValue = propValue;
5853
- trigger();
5854
- }
5855
- });
5856
- return {
5857
- get() {
5858
- track();
5859
- return options.get ? options.get(localValue) : localValue;
5860
- },
5861
- set(value) {
5862
- const rawProps = i.vnode.props;
5863
- if (!(rawProps && // check if parent has passed v-model
5864
- (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
5865
- localValue = value;
5866
- trigger();
5867
- }
5868
- i.emit(`update:${name}`, options.set ? options.set(value) : value);
5869
- }
5870
- };
5871
- });
5872
- const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
5873
- res[Symbol.iterator] = () => {
5874
- let i2 = 0;
5875
- return {
5876
- next() {
5877
- if (i2 < 2) {
5878
- return { value: i2++ ? props[modifierKey] || {} : res, done: false };
5879
- } else {
5880
- return { done: true };
5881
- }
5882
- }
5883
- };
5884
- };
5885
- return res;
5886
- }
5887
5847
  function getContext() {
5888
5848
  const i = getCurrentInstance();
5889
5849
  if (!i) {
@@ -6455,7 +6415,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6455
6415
  return vm;
6456
6416
  }
6457
6417
  }
6458
- Vue.version = `2.6.14-compat:${"3.4.7"}`;
6418
+ Vue.version = `2.6.14-compat:${"3.4.9"}`;
6459
6419
  Vue.config = singletonApp.config;
6460
6420
  Vue.use = (p, ...options) => {
6461
6421
  if (p && isFunction(p.install)) {
@@ -8181,29 +8141,43 @@ function propHasMismatch(el, key, clientValue, vnode) {
8181
8141
  let actual;
8182
8142
  let expected;
8183
8143
  if (key === "class") {
8184
- actual = toClassSet(el.getAttribute("class") || "");
8185
- expected = toClassSet(normalizeClass(clientValue));
8186
- if (!isSetEqual(actual, expected)) {
8144
+ actual = el.getAttribute("class");
8145
+ expected = normalizeClass(clientValue);
8146
+ if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
8187
8147
  mismatchType = mismatchKey = `class`;
8188
8148
  }
8189
8149
  } else if (key === "style") {
8190
- actual = toStyleMap(el.getAttribute("style") || "");
8191
- expected = toStyleMap(
8192
- isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue))
8193
- );
8150
+ actual = el.getAttribute("style");
8151
+ expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
8152
+ const actualMap = toStyleMap(actual);
8153
+ const expectedMap = toStyleMap(expected);
8194
8154
  if (vnode.dirs) {
8195
8155
  for (const { dir, value } of vnode.dirs) {
8196
8156
  if (dir.name === "show" && !value) {
8197
- expected.set("display", "none");
8157
+ expectedMap.set("display", "none");
8198
8158
  }
8199
8159
  }
8200
8160
  }
8201
- if (!isMapEqual(actual, expected)) {
8161
+ if (!isMapEqual(actualMap, expectedMap)) {
8202
8162
  mismatchType = mismatchKey = "style";
8203
8163
  }
8204
8164
  } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
8205
- actual = el.hasAttribute(key) ? el.getAttribute(key) : key in el ? el[key] : "";
8206
- expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? "" : false : clientValue == null ? "" : String(clientValue);
8165
+ if (isBooleanAttr(key)) {
8166
+ actual = el.hasAttribute(key);
8167
+ expected = includeBooleanAttr(clientValue);
8168
+ } else {
8169
+ if (el.hasAttribute(key)) {
8170
+ actual = el.getAttribute(key);
8171
+ } else if (key in el) {
8172
+ const serverValue = el[key];
8173
+ if (!isObject(serverValue)) {
8174
+ actual = serverValue == null ? "" : String(serverValue);
8175
+ }
8176
+ }
8177
+ if (!isObject(clientValue)) {
8178
+ expected = clientValue == null ? "" : String(clientValue);
8179
+ }
8180
+ }
8207
8181
  if (actual !== expected) {
8208
8182
  mismatchType = `attribute`;
8209
8183
  mismatchKey = key;
@@ -8211,15 +8185,15 @@ function propHasMismatch(el, key, clientValue, vnode) {
8211
8185
  }
8212
8186
  if (mismatchType) {
8213
8187
  const format = (v) => v === false ? `(not rendered)` : `${mismatchKey}="${v}"`;
8214
- warn$1(
8215
- `Hydration ${mismatchType} mismatch on`,
8216
- el,
8217
- `
8188
+ const preSegment = `Hydration ${mismatchType} mismatch on`;
8189
+ const postSegment = `
8218
8190
  - rendered on server: ${format(actual)}
8219
8191
  - expected on client: ${format(expected)}
8220
8192
  Note: this mismatch is check-only. The DOM will not be rectified in production due to performance overhead.
8221
- You should fix the source of the mismatch.`
8222
- );
8193
+ You should fix the source of the mismatch.`;
8194
+ {
8195
+ warn$1(preSegment, el, postSegment);
8196
+ }
8223
8197
  return true;
8224
8198
  }
8225
8199
  return false;
@@ -10982,6 +10956,59 @@ const computed = (getterOrOptions, debugOptions) => {
10982
10956
  return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
10983
10957
  };
10984
10958
 
10959
+ function useModel(props, name, options = EMPTY_OBJ) {
10960
+ const i = getCurrentInstance();
10961
+ if (!i) {
10962
+ warn$1(`useModel() called without active instance.`);
10963
+ return ref();
10964
+ }
10965
+ if (!i.propsOptions[0][name]) {
10966
+ warn$1(`useModel() called with prop "${name}" which is not declared.`);
10967
+ return ref();
10968
+ }
10969
+ const camelizedName = camelize(name);
10970
+ const hyphenatedName = hyphenate(name);
10971
+ const res = customRef((track, trigger) => {
10972
+ let localValue;
10973
+ watchSyncEffect(() => {
10974
+ const propValue = props[name];
10975
+ if (hasChanged(localValue, propValue)) {
10976
+ localValue = propValue;
10977
+ trigger();
10978
+ }
10979
+ });
10980
+ return {
10981
+ get() {
10982
+ track();
10983
+ return options.get ? options.get(localValue) : localValue;
10984
+ },
10985
+ set(value) {
10986
+ const rawProps = i.vnode.props;
10987
+ if (!(rawProps && // check if parent has passed v-model
10988
+ (name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps)) && hasChanged(value, localValue)) {
10989
+ localValue = value;
10990
+ trigger();
10991
+ }
10992
+ i.emit(`update:${name}`, options.set ? options.set(value) : value);
10993
+ }
10994
+ };
10995
+ });
10996
+ const modifierKey = name === "modelValue" ? "modelModifiers" : `${name}Modifiers`;
10997
+ res[Symbol.iterator] = () => {
10998
+ let i2 = 0;
10999
+ return {
11000
+ next() {
11001
+ if (i2 < 2) {
11002
+ return { value: i2++ ? props[modifierKey] || {} : res, done: false };
11003
+ } else {
11004
+ return { done: true };
11005
+ }
11006
+ }
11007
+ };
11008
+ };
11009
+ return res;
11010
+ }
11011
+
10985
11012
  function h(type, propsOrChildren, children) {
10986
11013
  const l = arguments.length;
10987
11014
  if (l === 2) {
@@ -11204,7 +11231,7 @@ function isMemoSame(cached, memo) {
11204
11231
  return true;
11205
11232
  }
11206
11233
 
11207
- const version = "3.4.7";
11234
+ const version = "3.4.9";
11208
11235
  const warn = warn$1 ;
11209
11236
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11210
11237
  const devtools = devtools$1 ;
@@ -11717,6 +11744,7 @@ function setVarsOnNode(el, vars) {
11717
11744
 
11718
11745
  function patchStyle(el, prev, next) {
11719
11746
  const style = el.style;
11747
+ const currentDisplay = style.display;
11720
11748
  const isCssString = isString(next);
11721
11749
  if (next && !isCssString) {
11722
11750
  if (prev && !isString(prev)) {
@@ -11730,7 +11758,6 @@ function patchStyle(el, prev, next) {
11730
11758
  setStyle(style, key, next[key]);
11731
11759
  }
11732
11760
  } else {
11733
- const currentDisplay = style.display;
11734
11761
  if (isCssString) {
11735
11762
  if (prev !== next) {
11736
11763
  const cssVarText = style[CSS_VAR_TEXT];
@@ -11742,9 +11769,9 @@ function patchStyle(el, prev, next) {
11742
11769
  } else if (prev) {
11743
11770
  el.removeAttribute("style");
11744
11771
  }
11745
- if (vShowOldKey in el) {
11746
- style.display = currentDisplay;
11747
- }
11772
+ }
11773
+ if (vShowOldKey in el) {
11774
+ style.display = currentDisplay;
11748
11775
  }
11749
11776
  }
11750
11777
  const semicolonRE = /[^\\];\s*$/;