@vue/compat 3.4.6 → 3.4.8

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.8
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) {
@@ -3805,7 +3808,12 @@ function queueEffectWithSuspense(fn, suspense) {
3805
3808
  function setActiveBranch(suspense, branch) {
3806
3809
  suspense.activeBranch = branch;
3807
3810
  const { vnode, parentComponent } = suspense;
3808
- const el = vnode.el = branch.el;
3811
+ let el = branch.el;
3812
+ while (!el && branch.component) {
3813
+ branch = branch.component.subTree;
3814
+ el = branch.el;
3815
+ }
3816
+ vnode.el = el;
3809
3817
  if (parentComponent && parentComponent.subTree === vnode) {
3810
3818
  parentComponent.vnode.el = el;
3811
3819
  updateHOCHostEl(parentComponent, el);
@@ -4079,14 +4087,9 @@ function instanceWatch(source, value, options) {
4079
4087
  cb = value.handler;
4080
4088
  options = value;
4081
4089
  }
4082
- const cur = currentInstance;
4083
- setCurrentInstance(this);
4090
+ const reset = setCurrentInstance(this);
4084
4091
  const res = doWatch(getter, cb.bind(publicThis), options);
4085
- if (cur) {
4086
- setCurrentInstance(cur);
4087
- } else {
4088
- unsetCurrentInstance();
4089
- }
4092
+ reset();
4090
4093
  return res;
4091
4094
  }
4092
4095
  function createPathGetter(ctx, path) {
@@ -4138,12 +4141,11 @@ function validateDirectiveName(name) {
4138
4141
  }
4139
4142
  }
4140
4143
  function withDirectives(vnode, directives) {
4141
- const internalInstance = currentRenderingInstance;
4142
- if (internalInstance === null) {
4144
+ if (currentRenderingInstance === null) {
4143
4145
  warn$1(`withDirectives can only be used inside render functions.`);
4144
4146
  return vnode;
4145
4147
  }
4146
- const instance = getExposeProxy(internalInstance) || internalInstance.proxy;
4148
+ const instance = getExposeProxy(currentRenderingInstance) || currentRenderingInstance.proxy;
4147
4149
  const bindings = vnode.dirs || (vnode.dirs = []);
4148
4150
  for (let i = 0; i < directives.length; i++) {
4149
4151
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
@@ -4932,9 +4934,9 @@ function injectHook(type, hook, target = currentInstance, prepend = false) {
4932
4934
  return;
4933
4935
  }
4934
4936
  pauseTracking();
4935
- setCurrentInstance(target);
4937
+ const reset = setCurrentInstance(target);
4936
4938
  const res = callWithAsyncErrorHandling(hook, target, type, args);
4937
- unsetCurrentInstance();
4939
+ reset();
4938
4940
  resetTracking();
4939
4941
  return res;
4940
4942
  });
@@ -6526,7 +6528,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6526
6528
  return vm;
6527
6529
  }
6528
6530
  }
6529
- Vue.version = `2.6.14-compat:${"3.4.6"}`;
6531
+ Vue.version = `2.6.14-compat:${"3.4.8"}`;
6530
6532
  Vue.config = singletonApp.config;
6531
6533
  Vue.use = (p, ...options) => {
6532
6534
  if (p && isFunction(p.install)) {
@@ -7366,12 +7368,12 @@ function resolvePropValue(options, props, key, value, instance, isAbsent) {
7366
7368
  if (key in propsDefaults) {
7367
7369
  value = propsDefaults[key];
7368
7370
  } else {
7369
- setCurrentInstance(instance);
7371
+ const reset = setCurrentInstance(instance);
7370
7372
  value = propsDefaults[key] = defaultValue.call(
7371
7373
  isCompatEnabled$1("PROPS_DEFAULT_THIS", instance) ? createPropsDefaultThis(instance, props, key) : null,
7372
7374
  props
7373
7375
  );
7374
- unsetCurrentInstance();
7376
+ reset();
7375
7377
  }
7376
7378
  } else {
7377
7379
  value = defaultValue;
@@ -8252,29 +8254,34 @@ function propHasMismatch(el, key, clientValue, vnode) {
8252
8254
  let actual;
8253
8255
  let expected;
8254
8256
  if (key === "class") {
8255
- actual = toClassSet(el.getAttribute("class") || "");
8256
- expected = toClassSet(normalizeClass(clientValue));
8257
- if (!isSetEqual(actual, expected)) {
8257
+ actual = el.getAttribute("class");
8258
+ expected = normalizeClass(clientValue);
8259
+ if (!isSetEqual(toClassSet(actual || ""), toClassSet(expected))) {
8258
8260
  mismatchType = mismatchKey = `class`;
8259
8261
  }
8260
8262
  } else if (key === "style") {
8261
- actual = toStyleMap(el.getAttribute("style") || "");
8262
- expected = toStyleMap(
8263
- isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue))
8264
- );
8263
+ actual = el.getAttribute("style");
8264
+ expected = isString(clientValue) ? clientValue : stringifyStyle(normalizeStyle(clientValue));
8265
+ const actualMap = toStyleMap(actual);
8266
+ const expectedMap = toStyleMap(expected);
8265
8267
  if (vnode.dirs) {
8266
8268
  for (const { dir, value } of vnode.dirs) {
8267
8269
  if (dir.name === "show" && !value) {
8268
- expected.set("display", "none");
8270
+ expectedMap.set("display", "none");
8269
8271
  }
8270
8272
  }
8271
8273
  }
8272
- if (!isMapEqual(actual, expected)) {
8274
+ if (!isMapEqual(actualMap, expectedMap)) {
8273
8275
  mismatchType = mismatchKey = "style";
8274
8276
  }
8275
8277
  } else if (el instanceof SVGElement && isKnownSvgAttr(key) || el instanceof HTMLElement && (isBooleanAttr(key) || isKnownHtmlAttr(key))) {
8276
- actual = el.hasAttribute(key) ? el.getAttribute(key) : key in el ? el[key] : "";
8277
- expected = isBooleanAttr(key) ? includeBooleanAttr(clientValue) ? "" : false : clientValue == null ? "" : String(clientValue);
8278
+ if (isBooleanAttr(key)) {
8279
+ actual = el.hasAttribute(key);
8280
+ expected = includeBooleanAttr(clientValue);
8281
+ } else {
8282
+ actual = el.hasAttribute(key) ? el.getAttribute(key) : key in el ? el[key] : "";
8283
+ expected = clientValue == null ? "" : String(clientValue);
8284
+ }
8278
8285
  if (actual !== expected) {
8279
8286
  mismatchType = `attribute`;
8280
8287
  mismatchKey = key;
@@ -10718,14 +10725,7 @@ function createComponentInstance(vnode, parent, suspense) {
10718
10725
  return instance;
10719
10726
  }
10720
10727
  let currentInstance = null;
10721
- const getCurrentInstance = () => {
10722
- if (isInComputedGetter) {
10723
- warn$1(
10724
- `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.`
10725
- );
10726
- }
10727
- return currentInstance || currentRenderingInstance;
10728
- };
10728
+ const getCurrentInstance = () => currentInstance || currentRenderingInstance;
10729
10729
  let internalSetCurrentInstance;
10730
10730
  let setInSSRSetupState;
10731
10731
  {
@@ -10737,8 +10737,13 @@ let setInSSRSetupState;
10737
10737
  };
10738
10738
  }
10739
10739
  const setCurrentInstance = (instance) => {
10740
+ const prev = currentInstance;
10740
10741
  internalSetCurrentInstance(instance);
10741
10742
  instance.scope.on();
10743
+ return () => {
10744
+ instance.scope.off();
10745
+ internalSetCurrentInstance(prev);
10746
+ };
10742
10747
  };
10743
10748
  const unsetCurrentInstance = () => {
10744
10749
  currentInstance && currentInstance.scope.off();
@@ -10800,7 +10805,7 @@ function setupStatefulComponent(instance, isSSR) {
10800
10805
  const { setup } = Component;
10801
10806
  if (setup) {
10802
10807
  const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
10803
- setCurrentInstance(instance);
10808
+ const reset = setCurrentInstance(instance);
10804
10809
  pauseTracking();
10805
10810
  const setupResult = callWithErrorHandling(
10806
10811
  setup,
@@ -10812,7 +10817,7 @@ function setupStatefulComponent(instance, isSSR) {
10812
10817
  ]
10813
10818
  );
10814
10819
  resetTracking();
10815
- unsetCurrentInstance();
10820
+ reset();
10816
10821
  if (isPromise(setupResult)) {
10817
10822
  setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
10818
10823
  if (isSSR) {
@@ -10918,13 +10923,13 @@ function finishComponentSetup(instance, isSSR, skipOptions) {
10918
10923
  }
10919
10924
  }
10920
10925
  if (!skipOptions) {
10921
- setCurrentInstance(instance);
10926
+ const reset = setCurrentInstance(instance);
10922
10927
  pauseTracking();
10923
10928
  try {
10924
10929
  applyOptions(instance);
10925
10930
  } finally {
10926
10931
  resetTracking();
10927
- unsetCurrentInstance();
10932
+ reset();
10928
10933
  }
10929
10934
  }
10930
10935
  if (!Component.render && instance.render === NOOP && !isSSR) {
@@ -11051,25 +11056,7 @@ function isClassComponent(value) {
11051
11056
  return isFunction(value) && "__vccOpts" in value;
11052
11057
  }
11053
11058
 
11054
- let isInComputedGetter = false;
11055
- function wrapComputedGetter(getter) {
11056
- return () => {
11057
- isInComputedGetter = true;
11058
- try {
11059
- return getter();
11060
- } finally {
11061
- isInComputedGetter = false;
11062
- }
11063
- };
11064
- }
11065
11059
  const computed = (getterOrOptions, debugOptions) => {
11066
- {
11067
- if (isFunction(getterOrOptions)) {
11068
- getterOrOptions = wrapComputedGetter(getterOrOptions);
11069
- } else {
11070
- getterOrOptions.get = wrapComputedGetter(getterOrOptions.get);
11071
- }
11072
- }
11073
11060
  return computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
11074
11061
  };
11075
11062
 
@@ -11295,7 +11282,7 @@ function isMemoSame(cached, memo) {
11295
11282
  return true;
11296
11283
  }
11297
11284
 
11298
- const version = "3.4.6";
11285
+ const version = "3.4.8";
11299
11286
  const warn = warn$1 ;
11300
11287
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
11301
11288
  const devtools = devtools$1 ;
@@ -15067,7 +15054,7 @@ function onCloseTag(el, end, isImplied = false) {
15067
15054
  }
15068
15055
  }
15069
15056
  }
15070
- if (isCompatEnabled(
15057
+ if (!tokenizer.inSFCRoot && isCompatEnabled(
15071
15058
  "COMPILER_NATIVE_TEMPLATE",
15072
15059
  currentOptions
15073
15060
  ) && el.tag === "template" && !isFragmentTemplate(el)) {
@@ -15680,8 +15667,7 @@ function createTransformContext(root, {
15680
15667
  }
15681
15668
  context.parent.children.splice(removalIndex, 1);
15682
15669
  },
15683
- onNodeRemoved: () => {
15684
- },
15670
+ onNodeRemoved: NOOP,
15685
15671
  addIdentifiers(exp) {
15686
15672
  },
15687
15673
  removeIdentifiers(exp) {