@vue/compat 3.5.21 → 3.5.22

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,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.21
2
+ * @vue/compat v3.5.22
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -1215,7 +1215,7 @@ function iterator(self, method, wrapValue) {
1215
1215
  iter._next = iter.next;
1216
1216
  iter.next = () => {
1217
1217
  const result = iter._next();
1218
- if (result.value) {
1218
+ if (!result.done) {
1219
1219
  result.value = wrapValue(result.value);
1220
1220
  }
1221
1221
  return result;
@@ -1342,7 +1342,8 @@ class BaseReactiveHandler {
1342
1342
  return res;
1343
1343
  }
1344
1344
  if (isRef(res)) {
1345
- return targetIsArray && isIntegerKey(key) ? res : res.value;
1345
+ const value = targetIsArray && isIntegerKey(key) ? res : res.value;
1346
+ return isReadonly2 && isObject(value) ? readonly(value) : value;
1346
1347
  }
1347
1348
  if (isObject(res)) {
1348
1349
  return isReadonly2 ? readonly(res) : reactive(res);
@@ -2692,14 +2693,11 @@ function checkRecursiveUpdates(seen, fn) {
2692
2693
  let isHmrUpdating = false;
2693
2694
  const hmrDirtyComponents = /* @__PURE__ */ new Map();
2694
2695
  {
2695
- const g = getGlobalThis();
2696
- if (!g.__VUE_HMR_RUNTIME__) {
2697
- g.__VUE_HMR_RUNTIME__ = {
2698
- createRecord: tryWrap(createRecord),
2699
- rerender: tryWrap(rerender),
2700
- reload: tryWrap(reload)
2701
- };
2702
- }
2696
+ getGlobalThis().__VUE_HMR_RUNTIME__ = {
2697
+ createRecord: tryWrap(createRecord),
2698
+ rerender: tryWrap(rerender),
2699
+ reload: tryWrap(reload)
2700
+ };
2703
2701
  }
2704
2702
  const map = /* @__PURE__ */ new Map();
2705
2703
  function registerHMR(instance) {
@@ -3594,9 +3592,6 @@ const TeleportImpl = {
3594
3592
  insert(mainAnchor, container, anchor);
3595
3593
  const mount = (container2, anchor2) => {
3596
3594
  if (shapeFlag & 16) {
3597
- if (parentComponent && parentComponent.isCE) {
3598
- parentComponent.ce._teleportTarget = container2;
3599
- }
3600
3595
  mountChildren(
3601
3596
  children,
3602
3597
  container2,
@@ -3618,6 +3613,9 @@ const TeleportImpl = {
3618
3613
  } else if (namespace !== "mathml" && isTargetMathML(target)) {
3619
3614
  namespace = "mathml";
3620
3615
  }
3616
+ if (parentComponent && parentComponent.isCE) {
3617
+ (parentComponent.ce._teleportTargets || (parentComponent.ce._teleportTargets = /* @__PURE__ */ new Set())).add(target);
3618
+ }
3621
3619
  if (!disabled) {
3622
3620
  mount(target, targetAnchor);
3623
3621
  updateCssVars(n2, false);
@@ -6077,12 +6075,13 @@ function createSlots(slots, dynamicSlots) {
6077
6075
 
6078
6076
  function renderSlot(slots, name, props = {}, fallback, noSlotted) {
6079
6077
  if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
6078
+ const hasProps = Object.keys(props).length > 0;
6080
6079
  if (name !== "default") props.name = name;
6081
6080
  return openBlock(), createBlock(
6082
6081
  Fragment,
6083
6082
  null,
6084
6083
  [createVNode("slot", props, fallback && fallback())],
6085
- 64
6084
+ hasProps ? -2 : 64
6086
6085
  );
6087
6086
  }
6088
6087
  let slot = slots[name];
@@ -7273,7 +7272,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7273
7272
  return vm;
7274
7273
  }
7275
7274
  }
7276
- Vue.version = `2.6.14-compat:${"3.5.21"}`;
7275
+ Vue.version = `2.6.14-compat:${"3.5.22"}`;
7277
7276
  Vue.config = singletonApp.config;
7278
7277
  Vue.use = (plugin, ...options) => {
7279
7278
  if (plugin && isFunction(plugin.install)) {
@@ -12198,31 +12197,28 @@ const computed = (getterOrOptions, debugOptions) => {
12198
12197
  };
12199
12198
 
12200
12199
  function h(type, propsOrChildren, children) {
12201
- const doCreateVNode = (type2, props, children2) => {
12200
+ try {
12202
12201
  setBlockTracking(-1);
12203
- try {
12204
- return createVNode(type2, props, children2);
12205
- } finally {
12206
- setBlockTracking(1);
12207
- }
12208
- };
12209
- const l = arguments.length;
12210
- if (l === 2) {
12211
- if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
12212
- if (isVNode(propsOrChildren)) {
12213
- return doCreateVNode(type, null, [propsOrChildren]);
12202
+ const l = arguments.length;
12203
+ if (l === 2) {
12204
+ if (isObject(propsOrChildren) && !isArray(propsOrChildren)) {
12205
+ if (isVNode(propsOrChildren)) {
12206
+ return createVNode(type, null, [propsOrChildren]);
12207
+ }
12208
+ return createVNode(type, propsOrChildren);
12209
+ } else {
12210
+ return createVNode(type, null, propsOrChildren);
12214
12211
  }
12215
- return doCreateVNode(type, propsOrChildren);
12216
12212
  } else {
12217
- return doCreateVNode(type, null, propsOrChildren);
12218
- }
12219
- } else {
12220
- if (l > 3) {
12221
- children = Array.prototype.slice.call(arguments, 2);
12222
- } else if (l === 3 && isVNode(children)) {
12223
- children = [children];
12213
+ if (l > 3) {
12214
+ children = Array.prototype.slice.call(arguments, 2);
12215
+ } else if (l === 3 && isVNode(children)) {
12216
+ children = [children];
12217
+ }
12218
+ return createVNode(type, propsOrChildren, children);
12224
12219
  }
12225
- return doCreateVNode(type, propsOrChildren, children);
12220
+ } finally {
12221
+ setBlockTracking(1);
12226
12222
  }
12227
12223
  }
12228
12224
 
@@ -12432,7 +12428,7 @@ function isMemoSame(cached, memo) {
12432
12428
  return true;
12433
12429
  }
12434
12430
 
12435
- const version = "3.5.21";
12431
+ const version = "3.5.22";
12436
12432
  const warn = warn$1 ;
12437
12433
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12438
12434
  const devtools = devtools$1 ;
@@ -12702,11 +12698,11 @@ function resolveTransitionProps(rawProps) {
12702
12698
  addTransitionClass(el, legacyLeaveFromClass);
12703
12699
  }
12704
12700
  if (!el._enterCancelled) {
12705
- forceReflow();
12701
+ forceReflow(el);
12706
12702
  addTransitionClass(el, leaveActiveClass);
12707
12703
  } else {
12708
12704
  addTransitionClass(el, leaveActiveClass);
12709
- forceReflow();
12705
+ forceReflow(el);
12710
12706
  }
12711
12707
  nextFrame(() => {
12712
12708
  if (!el._isLeaving) {
@@ -12855,8 +12851,9 @@ function toMs(s) {
12855
12851
  if (s === "auto") return 0;
12856
12852
  return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
12857
12853
  }
12858
- function forceReflow() {
12859
- return document.body.offsetHeight;
12854
+ function forceReflow(el) {
12855
+ const targetDocument = el ? el.ownerDocument : document;
12856
+ return targetDocument.body.offsetHeight;
12860
12857
  }
12861
12858
 
12862
12859
  function patchClass(el, value, isSVG) {
@@ -13413,7 +13410,11 @@ class VueElement extends BaseClass {
13413
13410
  );
13414
13411
  }
13415
13412
  if (_def.shadowRoot !== false) {
13416
- this.attachShadow({ mode: "open" });
13413
+ this.attachShadow(
13414
+ extend({}, _def.shadowRootOptions, {
13415
+ mode: "open"
13416
+ })
13417
+ );
13417
13418
  this._root = this.shadowRoot;
13418
13419
  } else {
13419
13420
  this._root = this;
@@ -13473,9 +13474,18 @@ class VueElement extends BaseClass {
13473
13474
  this._app && this._app.unmount();
13474
13475
  if (this._instance) this._instance.ce = void 0;
13475
13476
  this._app = this._instance = null;
13477
+ if (this._teleportTargets) {
13478
+ this._teleportTargets.clear();
13479
+ this._teleportTargets = void 0;
13480
+ }
13476
13481
  }
13477
13482
  });
13478
13483
  }
13484
+ _processMutations(mutations) {
13485
+ for (const m of mutations) {
13486
+ this._setAttr(m.attributeName);
13487
+ }
13488
+ }
13479
13489
  /**
13480
13490
  * resolve inner component definition (handle possible async component)
13481
13491
  */
@@ -13486,11 +13496,7 @@ class VueElement extends BaseClass {
13486
13496
  for (let i = 0; i < this.attributes.length; i++) {
13487
13497
  this._setAttr(this.attributes[i].name);
13488
13498
  }
13489
- this._ob = new MutationObserver((mutations) => {
13490
- for (const m of mutations) {
13491
- this._setAttr(m.attributeName);
13492
- }
13493
- });
13499
+ this._ob = new MutationObserver(this._processMutations.bind(this));
13494
13500
  this._ob.observe(this, { attributes: true });
13495
13501
  const resolve = (def, isAsync = false) => {
13496
13502
  this._resolved = true;
@@ -13606,7 +13612,10 @@ class VueElement extends BaseClass {
13606
13612
  }
13607
13613
  if (shouldReflect) {
13608
13614
  const ob = this._ob;
13609
- ob && ob.disconnect();
13615
+ if (ob) {
13616
+ this._processMutations(ob.takeRecords());
13617
+ ob.disconnect();
13618
+ }
13610
13619
  if (val === true) {
13611
13620
  this.setAttribute(hyphenate(key), "");
13612
13621
  } else if (typeof val === "string" || typeof val === "number") {
@@ -13710,7 +13719,7 @@ class VueElement extends BaseClass {
13710
13719
  * Only called when shadowRoot is false
13711
13720
  */
13712
13721
  _renderSlots() {
13713
- const outlets = (this._teleportTarget || this).querySelectorAll("slot");
13722
+ const outlets = this._getSlots();
13714
13723
  const scopeId = this._instance.type.__scopeId;
13715
13724
  for (let i = 0; i < outlets.length; i++) {
13716
13725
  const o = outlets[i];
@@ -13736,6 +13745,19 @@ class VueElement extends BaseClass {
13736
13745
  parent.removeChild(o);
13737
13746
  }
13738
13747
  }
13748
+ /**
13749
+ * @internal
13750
+ */
13751
+ _getSlots() {
13752
+ const roots = [this];
13753
+ if (this._teleportTargets) {
13754
+ roots.push(...this._teleportTargets);
13755
+ }
13756
+ return roots.reduce((res, i) => {
13757
+ res.push(...Array.from(i.querySelectorAll("slot")));
13758
+ return res;
13759
+ }, []);
13760
+ }
13739
13761
  /**
13740
13762
  * @internal
13741
13763
  */
@@ -13840,7 +13862,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
13840
13862
  prevChildren.forEach(callPendingCbs);
13841
13863
  prevChildren.forEach(recordPosition);
13842
13864
  const movedChildren = prevChildren.filter(applyTranslation);
13843
- forceReflow();
13865
+ forceReflow(instance.vnode.el);
13844
13866
  movedChildren.forEach((c) => {
13845
13867
  const el = c.el;
13846
13868
  const style = el.style;
@@ -18317,80 +18339,6 @@ function getParentCondition(node) {
18317
18339
  }
18318
18340
  }
18319
18341
 
18320
- const transformBind = (dir, _node, context) => {
18321
- const { modifiers, loc } = dir;
18322
- const arg = dir.arg;
18323
- let { exp } = dir;
18324
- if (exp && exp.type === 4 && !exp.content.trim()) {
18325
- {
18326
- exp = void 0;
18327
- }
18328
- }
18329
- if (!exp) {
18330
- if (arg.type !== 4 || !arg.isStatic) {
18331
- context.onError(
18332
- createCompilerError(
18333
- 52,
18334
- arg.loc
18335
- )
18336
- );
18337
- return {
18338
- props: [
18339
- createObjectProperty(arg, createSimpleExpression("", true, loc))
18340
- ]
18341
- };
18342
- }
18343
- transformBindShorthand(dir);
18344
- exp = dir.exp;
18345
- }
18346
- if (arg.type !== 4) {
18347
- arg.children.unshift(`(`);
18348
- arg.children.push(`) || ""`);
18349
- } else if (!arg.isStatic) {
18350
- arg.content = arg.content ? `${arg.content} || ""` : `""`;
18351
- }
18352
- if (modifiers.some((mod) => mod.content === "camel")) {
18353
- if (arg.type === 4) {
18354
- if (arg.isStatic) {
18355
- arg.content = camelize(arg.content);
18356
- } else {
18357
- arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
18358
- }
18359
- } else {
18360
- arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
18361
- arg.children.push(`)`);
18362
- }
18363
- }
18364
- if (!context.inSSR) {
18365
- if (modifiers.some((mod) => mod.content === "prop")) {
18366
- injectPrefix(arg, ".");
18367
- }
18368
- if (modifiers.some((mod) => mod.content === "attr")) {
18369
- injectPrefix(arg, "^");
18370
- }
18371
- }
18372
- return {
18373
- props: [createObjectProperty(arg, exp)]
18374
- };
18375
- };
18376
- const transformBindShorthand = (dir, context) => {
18377
- const arg = dir.arg;
18378
- const propName = camelize(arg.content);
18379
- dir.exp = createSimpleExpression(propName, false, arg.loc);
18380
- };
18381
- const injectPrefix = (arg, prefix) => {
18382
- if (arg.type === 4) {
18383
- if (arg.isStatic) {
18384
- arg.content = prefix + arg.content;
18385
- } else {
18386
- arg.content = `\`${prefix}\${${arg.content}}\``;
18387
- }
18388
- } else {
18389
- arg.children.unshift(`'${prefix}' + (`);
18390
- arg.children.push(`)`);
18391
- }
18392
- };
18393
-
18394
18342
  const transformFor = createStructuralDirectiveTransform(
18395
18343
  "for",
18396
18344
  (node, dir, context) => {
@@ -18402,10 +18350,7 @@ const transformFor = createStructuralDirectiveTransform(
18402
18350
  const isTemplate = isTemplateNode(node);
18403
18351
  const memo = findDir(node, "memo");
18404
18352
  const keyProp = findProp(node, `key`, false, true);
18405
- const isDirKey = keyProp && keyProp.type === 7;
18406
- if (isDirKey && !keyProp.exp) {
18407
- transformBindShorthand(keyProp);
18408
- }
18353
+ keyProp && keyProp.type === 7;
18409
18354
  let keyExp = keyProp && (keyProp.type === 6 ? keyProp.value ? createSimpleExpression(keyProp.value.content, true) : void 0 : keyProp.exp);
18410
18355
  const keyProperty = keyProp && keyExp ? createObjectProperty(`key`, keyExp) : null;
18411
18356
  const isStableFragment = forNode.source.type === 4 && forNode.source.constType > 0;
@@ -19558,6 +19503,58 @@ const transformOn$1 = (dir, node, context, augmentor) => {
19558
19503
  return ret;
19559
19504
  };
19560
19505
 
19506
+ const transformBind = (dir, _node, context) => {
19507
+ const { modifiers, loc } = dir;
19508
+ const arg = dir.arg;
19509
+ let { exp } = dir;
19510
+ if (exp && exp.type === 4 && !exp.content.trim()) {
19511
+ {
19512
+ exp = void 0;
19513
+ }
19514
+ }
19515
+ if (arg.type !== 4) {
19516
+ arg.children.unshift(`(`);
19517
+ arg.children.push(`) || ""`);
19518
+ } else if (!arg.isStatic) {
19519
+ arg.content = arg.content ? `${arg.content} || ""` : `""`;
19520
+ }
19521
+ if (modifiers.some((mod) => mod.content === "camel")) {
19522
+ if (arg.type === 4) {
19523
+ if (arg.isStatic) {
19524
+ arg.content = camelize(arg.content);
19525
+ } else {
19526
+ arg.content = `${context.helperString(CAMELIZE)}(${arg.content})`;
19527
+ }
19528
+ } else {
19529
+ arg.children.unshift(`${context.helperString(CAMELIZE)}(`);
19530
+ arg.children.push(`)`);
19531
+ }
19532
+ }
19533
+ if (!context.inSSR) {
19534
+ if (modifiers.some((mod) => mod.content === "prop")) {
19535
+ injectPrefix(arg, ".");
19536
+ }
19537
+ if (modifiers.some((mod) => mod.content === "attr")) {
19538
+ injectPrefix(arg, "^");
19539
+ }
19540
+ }
19541
+ return {
19542
+ props: [createObjectProperty(arg, exp)]
19543
+ };
19544
+ };
19545
+ const injectPrefix = (arg, prefix) => {
19546
+ if (arg.type === 4) {
19547
+ if (arg.isStatic) {
19548
+ arg.content = prefix + arg.content;
19549
+ } else {
19550
+ arg.content = `\`${prefix}\${${arg.content}}\``;
19551
+ }
19552
+ } else {
19553
+ arg.children.unshift(`'${prefix}' + (`);
19554
+ arg.children.push(`)`);
19555
+ }
19556
+ };
19557
+
19561
19558
  const transformText = (node, context) => {
19562
19559
  if (node.type === 0 || node.type === 1 || node.type === 11 || node.type === 10) {
19563
19560
  return () => {
@@ -19888,9 +19885,35 @@ const transformMemo = (node, context) => {
19888
19885
  }
19889
19886
  };
19890
19887
 
19888
+ const transformVBindShorthand = (node, context) => {
19889
+ if (node.type === 1) {
19890
+ for (const prop of node.props) {
19891
+ if (prop.type === 7 && prop.name === "bind" && !prop.exp) {
19892
+ const arg = prop.arg;
19893
+ if (arg.type !== 4 || !arg.isStatic) {
19894
+ context.onError(
19895
+ createCompilerError(
19896
+ 52,
19897
+ arg.loc
19898
+ )
19899
+ );
19900
+ prop.exp = createSimpleExpression("", true, arg.loc);
19901
+ } else {
19902
+ const propName = camelize(arg.content);
19903
+ if (validFirstIdentCharRE.test(propName[0]) || // allow hyphen first char for https://github.com/vuejs/language-tools/pull/3424
19904
+ propName[0] === "-") {
19905
+ prop.exp = createSimpleExpression(propName, false, arg.loc);
19906
+ }
19907
+ }
19908
+ }
19909
+ }
19910
+ }
19911
+ };
19912
+
19891
19913
  function getBaseTransformPreset(prefixIdentifiers) {
19892
19914
  return [
19893
19915
  [
19916
+ transformVBindShorthand,
19894
19917
  transformOnce,
19895
19918
  transformIf,
19896
19919
  transformMemo,