@vue/compat 3.5.3 → 3.5.5

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,13 +1,14 @@
1
1
  /**
2
- * @vue/compat v3.5.3
2
+ * @vue/compat v3.5.5
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
6
6
  /*! #__NO_SIDE_EFFECTS__ */
7
7
  // @__NO_SIDE_EFFECTS__
8
- function makeMap(str, expectsLowerCase) {
9
- const set = new Set(str.split(","));
10
- return expectsLowerCase ? (val) => set.has(val.toLowerCase()) : (val) => set.has(val);
8
+ function makeMap(str) {
9
+ const map = /* @__PURE__ */ Object.create(null);
10
+ for (const key of str.split(",")) map[key] = 1;
11
+ return (val) => val in map;
11
12
  }
12
13
 
13
14
  const EMPTY_OBJ = Object.freeze({}) ;
@@ -662,9 +663,11 @@ function prepareDeps(sub) {
662
663
  function cleanupDeps(sub) {
663
664
  let head;
664
665
  let tail = sub.depsTail;
665
- for (let link = tail; link; link = link.prevDep) {
666
+ let link = tail;
667
+ while (link) {
668
+ const prev = link.prevDep;
666
669
  if (link.version === -1) {
667
- if (link === tail) tail = link.prevDep;
670
+ if (link === tail) tail = prev;
668
671
  removeSub(link);
669
672
  removeDep(link);
670
673
  } else {
@@ -672,13 +675,14 @@ function cleanupDeps(sub) {
672
675
  }
673
676
  link.dep.activeLink = link.prevActiveLink;
674
677
  link.prevActiveLink = void 0;
678
+ link = prev;
675
679
  }
676
680
  sub.deps = head;
677
681
  sub.depsTail = tail;
678
682
  }
679
683
  function isDirty(sub) {
680
684
  for (let link = sub.deps; link; link = link.nextDep) {
681
- if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) === false || link.dep.version !== link.version) {
685
+ if (link.dep.version !== link.version || link.dep.computed && refreshComputed(link.dep.computed) || link.dep.version !== link.version) {
682
686
  return true;
683
687
  }
684
688
  }
@@ -688,9 +692,6 @@ function isDirty(sub) {
688
692
  return false;
689
693
  }
690
694
  function refreshComputed(computed) {
691
- if (computed.flags & 2) {
692
- return false;
693
- }
694
695
  if (computed.flags & 4 && !(computed.flags & 16)) {
695
696
  return;
696
697
  }
@@ -803,6 +804,14 @@ function cleanupEffect(e) {
803
804
  }
804
805
 
805
806
  let globalVersion = 0;
807
+ class Link {
808
+ constructor(sub, dep) {
809
+ this.sub = sub;
810
+ this.dep = dep;
811
+ this.version = dep.version;
812
+ this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
813
+ }
814
+ }
806
815
  class Dep {
807
816
  constructor(computed) {
808
817
  this.computed = computed;
@@ -825,16 +834,7 @@ class Dep {
825
834
  }
826
835
  let link = this.activeLink;
827
836
  if (link === void 0 || link.sub !== activeSub) {
828
- link = this.activeLink = {
829
- dep: this,
830
- sub: activeSub,
831
- version: this.version,
832
- nextDep: void 0,
833
- prevDep: void 0,
834
- nextSub: void 0,
835
- prevSub: void 0,
836
- prevActiveLink: void 0
837
- };
837
+ link = this.activeLink = new Link(activeSub, this);
838
838
  if (!activeSub.deps) {
839
839
  activeSub.deps = activeSub.depsTail = link;
840
840
  } else {
@@ -957,9 +957,23 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
957
957
  globalVersion++;
958
958
  return;
959
959
  }
960
- let deps = [];
960
+ const run = (dep) => {
961
+ if (dep) {
962
+ {
963
+ dep.trigger({
964
+ target,
965
+ type,
966
+ key,
967
+ newValue,
968
+ oldValue,
969
+ oldTarget
970
+ });
971
+ }
972
+ }
973
+ };
974
+ startBatch();
961
975
  if (type === "clear") {
962
- deps = [...depsMap.values()];
976
+ depsMap.forEach(run);
963
977
  } else {
964
978
  const targetIsArray = isArray(target);
965
979
  const isArrayIndex = targetIsArray && isIntegerKey(key);
@@ -967,57 +981,43 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
967
981
  const newLength = Number(newValue);
968
982
  depsMap.forEach((dep, key2) => {
969
983
  if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
970
- deps.push(dep);
984
+ run(dep);
971
985
  }
972
986
  });
973
987
  } else {
974
- const push = (dep) => dep && deps.push(dep);
975
988
  if (key !== void 0) {
976
- push(depsMap.get(key));
989
+ run(depsMap.get(key));
977
990
  }
978
991
  if (isArrayIndex) {
979
- push(depsMap.get(ARRAY_ITERATE_KEY));
992
+ run(depsMap.get(ARRAY_ITERATE_KEY));
980
993
  }
981
994
  switch (type) {
982
995
  case "add":
983
996
  if (!targetIsArray) {
984
- push(depsMap.get(ITERATE_KEY));
997
+ run(depsMap.get(ITERATE_KEY));
985
998
  if (isMap(target)) {
986
- push(depsMap.get(MAP_KEY_ITERATE_KEY));
999
+ run(depsMap.get(MAP_KEY_ITERATE_KEY));
987
1000
  }
988
1001
  } else if (isArrayIndex) {
989
- push(depsMap.get("length"));
1002
+ run(depsMap.get("length"));
990
1003
  }
991
1004
  break;
992
1005
  case "delete":
993
1006
  if (!targetIsArray) {
994
- push(depsMap.get(ITERATE_KEY));
1007
+ run(depsMap.get(ITERATE_KEY));
995
1008
  if (isMap(target)) {
996
- push(depsMap.get(MAP_KEY_ITERATE_KEY));
1009
+ run(depsMap.get(MAP_KEY_ITERATE_KEY));
997
1010
  }
998
1011
  }
999
1012
  break;
1000
1013
  case "set":
1001
1014
  if (isMap(target)) {
1002
- push(depsMap.get(ITERATE_KEY));
1015
+ run(depsMap.get(ITERATE_KEY));
1003
1016
  }
1004
1017
  break;
1005
1018
  }
1006
1019
  }
1007
1020
  }
1008
- startBatch();
1009
- for (const dep of deps) {
1010
- {
1011
- dep.trigger({
1012
- target,
1013
- type,
1014
- key,
1015
- newValue,
1016
- oldValue,
1017
- oldTarget
1018
- });
1019
- }
1020
- }
1021
1021
  endBatch();
1022
1022
  }
1023
1023
  function getDepFromReactive(object, key) {
@@ -1755,7 +1755,7 @@ function toRaw(observed) {
1755
1755
  return raw ? toRaw(raw) : observed;
1756
1756
  }
1757
1757
  function markRaw(value) {
1758
- if (Object.isExtensible(value)) {
1758
+ if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
1759
1759
  def(value, "__v_skip", true);
1760
1760
  }
1761
1761
  return value;
@@ -1965,8 +1965,8 @@ class ComputedRefImpl {
1965
1965
  * @internal
1966
1966
  */
1967
1967
  notify() {
1968
+ this.flags |= 16;
1968
1969
  if (activeSub !== this) {
1969
- this.flags |= 16;
1970
1970
  this.dep.notify();
1971
1971
  }
1972
1972
  }
@@ -2654,23 +2654,19 @@ function flushJobs(seen) {
2654
2654
  }
2655
2655
  }
2656
2656
  function checkRecursiveUpdates(seen, fn) {
2657
- if (!seen.has(fn)) {
2658
- seen.set(fn, 1);
2659
- } else {
2660
- const count = seen.get(fn);
2661
- if (count > RECURSION_LIMIT) {
2662
- const instance = fn.i;
2663
- const componentName = instance && getComponentName(instance.type);
2664
- handleError(
2665
- `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
2666
- null,
2667
- 10
2668
- );
2669
- return true;
2670
- } else {
2671
- seen.set(fn, count + 1);
2672
- }
2657
+ const count = seen.get(fn) || 0;
2658
+ if (count > RECURSION_LIMIT) {
2659
+ const instance = fn.i;
2660
+ const componentName = instance && getComponentName(instance.type);
2661
+ handleError(
2662
+ `Maximum recursive updates exceeded${componentName ? ` in component <${componentName}>` : ``}. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.`,
2663
+ null,
2664
+ 10
2665
+ );
2666
+ return true;
2673
2667
  }
2668
+ seen.set(fn, count + 1);
2669
+ return false;
2674
2670
  }
2675
2671
 
2676
2672
  let isHmrUpdating = false;
@@ -2751,7 +2747,9 @@ function reload(id, newComp) {
2751
2747
  dirtyInstances.delete(instance);
2752
2748
  } else if (instance.parent) {
2753
2749
  queueJob(() => {
2750
+ isHmrUpdating = true;
2754
2751
  instance.parent.update();
2752
+ isHmrUpdating = false;
2755
2753
  dirtyInstances.delete(instance);
2756
2754
  });
2757
2755
  } else if (instance.appContext.reload) {
@@ -3570,6 +3568,9 @@ const TeleportImpl = {
3570
3568
  insert(mainAnchor, container, anchor);
3571
3569
  const mount = (container2, anchor2) => {
3572
3570
  if (shapeFlag & 16) {
3571
+ if (parentComponent && parentComponent.isCE) {
3572
+ parentComponent.ce._teleportTarget = container2;
3573
+ }
3573
3574
  mountChildren(
3574
3575
  children,
3575
3576
  container2,
@@ -4603,7 +4604,11 @@ Server rendered element contains more child nodes than client vdom.`
4603
4604
  remove(cur);
4604
4605
  }
4605
4606
  } else if (shapeFlag & 8) {
4606
- if (el.textContent !== vnode.children) {
4607
+ let clientText = vnode.children;
4608
+ if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
4609
+ clientText = clientText.slice(1);
4610
+ }
4611
+ if (el.textContent !== clientText) {
4607
4612
  if (!isMismatchAllowed(el, 0 /* TEXT */)) {
4608
4613
  warn$1(
4609
4614
  `Hydration text content mismatch on`,
@@ -4802,7 +4807,7 @@ Server rendered element contains fewer child nodes than client vdom.`
4802
4807
  }
4803
4808
  };
4804
4809
  const isTemplateNode = (node) => {
4805
- return node.nodeType === 1 && node.tagName.toLowerCase() === "template";
4810
+ return node.nodeType === 1 && node.tagName === "TEMPLATE";
4806
4811
  };
4807
4812
  return [hydrate, hydrateNode];
4808
4813
  }
@@ -5154,7 +5159,7 @@ function defineAsyncComponent(source) {
5154
5159
  load().then(() => {
5155
5160
  loaded.value = true;
5156
5161
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
5157
- queueJob(instance.parent.update);
5162
+ instance.parent.update();
5158
5163
  }
5159
5164
  }).catch((err) => {
5160
5165
  onError(err);
@@ -5846,13 +5851,15 @@ function renderList(source, renderItem, cache, index) {
5846
5851
  const sourceIsArray = isArray(source);
5847
5852
  if (sourceIsArray || isString(source)) {
5848
5853
  const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5854
+ let needsWrap = false;
5849
5855
  if (sourceIsReactiveArray) {
5856
+ needsWrap = !isShallow(source);
5850
5857
  source = shallowReadArray(source);
5851
5858
  }
5852
5859
  ret = new Array(source.length);
5853
5860
  for (let i = 0, l = source.length; i < l; i++) {
5854
5861
  ret[i] = renderItem(
5855
- sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5862
+ needsWrap ? toReactive(source[i]) : source[i],
5856
5863
  i,
5857
5864
  void 0,
5858
5865
  cached && cached[i]
@@ -7103,7 +7110,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7103
7110
  return vm;
7104
7111
  }
7105
7112
  }
7106
- Vue.version = `2.6.14-compat:${"3.5.3"}`;
7113
+ Vue.version = `2.6.14-compat:${"3.5.5"}`;
7107
7114
  Vue.config = singletonApp.config;
7108
7115
  Vue.use = (plugin, ...options) => {
7109
7116
  if (plugin && isFunction(plugin.install)) {
@@ -8925,6 +8932,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8925
8932
  }
8926
8933
  }
8927
8934
  if (instance.asyncDep) {
8935
+ if (isHmrUpdating) initialVNode.el = null;
8928
8936
  parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
8929
8937
  if (!initialVNode.el) {
8930
8938
  const placeholder = instance.subTree = createVNode(Comment);
@@ -12216,7 +12224,7 @@ function isMemoSame(cached, memo) {
12216
12224
  return true;
12217
12225
  }
12218
12226
 
12219
- const version = "3.5.3";
12227
+ const version = "3.5.5";
12220
12228
  const warn = warn$1 ;
12221
12229
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12222
12230
  const devtools = devtools$1 ;
@@ -13204,6 +13212,7 @@ class VueElement extends BaseClass {
13204
13212
  }
13205
13213
  }
13206
13214
  connectedCallback() {
13215
+ if (!this.isConnected) return;
13207
13216
  if (!this.shadowRoot) {
13208
13217
  this._parseSlots();
13209
13218
  }
@@ -13246,7 +13255,7 @@ class VueElement extends BaseClass {
13246
13255
  this._ob = null;
13247
13256
  }
13248
13257
  this._app && this._app.unmount();
13249
- this._instance.ce = void 0;
13258
+ if (this._instance) this._instance.ce = void 0;
13250
13259
  this._app = this._instance = null;
13251
13260
  }
13252
13261
  });
@@ -13465,7 +13474,7 @@ class VueElement extends BaseClass {
13465
13474
  }
13466
13475
  }
13467
13476
  /**
13468
- * Only called when shaddowRoot is false
13477
+ * Only called when shadowRoot is false
13469
13478
  */
13470
13479
  _parseSlots() {
13471
13480
  const slots = this._slots = {};
@@ -13477,10 +13486,10 @@ class VueElement extends BaseClass {
13477
13486
  }
13478
13487
  }
13479
13488
  /**
13480
- * Only called when shaddowRoot is false
13489
+ * Only called when shadowRoot is false
13481
13490
  */
13482
13491
  _renderSlots() {
13483
- const outlets = this.querySelectorAll("slot");
13492
+ const outlets = (this._teleportTarget || this).querySelectorAll("slot");
13484
13493
  const scopeId = this._instance.type.__scopeId;
13485
13494
  for (let i = 0; i < outlets.length; i++) {
13486
13495
  const o = outlets[i];
@@ -13668,7 +13677,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
13668
13677
  child,
13669
13678
  resolveTransitionHooks(child, cssTransitionProps, state, instance)
13670
13679
  );
13671
- } else {
13680
+ } else if (child.type !== Text) {
13672
13681
  warn(`<TransitionGroup> children must be keyed.`);
13673
13682
  }
13674
13683
  }
@@ -14910,7 +14919,7 @@ class Tokenizer {
14910
14919
  this.sequenceIndex += 1;
14911
14920
  } else if (this.sequenceIndex === 0) {
14912
14921
  if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
14913
- if (c === this.delimiterOpen[0]) {
14922
+ if (!this.inVPre && c === this.delimiterOpen[0]) {
14914
14923
  this.state = 2;
14915
14924
  this.delimiterIndex = 0;
14916
14925
  this.stateInterpolationOpen(c);
@@ -15880,6 +15889,7 @@ const defaultParserOptions = {
15880
15889
  getNamespace: () => 0,
15881
15890
  isVoidTag: NO,
15882
15891
  isPreTag: NO,
15892
+ isIgnoreNewlineTag: NO,
15883
15893
  isCustomElement: NO,
15884
15894
  onError: defaultOnError,
15885
15895
  onWarn: defaultOnWarn,
@@ -16322,7 +16332,7 @@ function onCloseTag(el, end, isImplied = false) {
16322
16332
  el.innerLoc.end.offset
16323
16333
  );
16324
16334
  }
16325
- const { tag, ns } = el;
16335
+ const { tag, ns, children } = el;
16326
16336
  if (!inVPre) {
16327
16337
  if (tag === "slot") {
16328
16338
  el.tagType = 2;
@@ -16333,7 +16343,13 @@ function onCloseTag(el, end, isImplied = false) {
16333
16343
  }
16334
16344
  }
16335
16345
  if (!tokenizer.inRCDATA) {
16336
- el.children = condenseWhitespace(el.children, el.tag);
16346
+ el.children = condenseWhitespace(children);
16347
+ }
16348
+ if (ns === 0 && currentOptions.isIgnoreNewlineTag(tag)) {
16349
+ const first = children[0];
16350
+ if (first && first.type === 2) {
16351
+ first.content = first.content.replace(/^\r?\n/, "");
16352
+ }
16337
16353
  }
16338
16354
  if (ns === 0 && currentOptions.isPreTag(tag)) {
16339
16355
  inPre--;
@@ -16485,12 +16501,6 @@ function condenseWhitespace(nodes, tag) {
16485
16501
  }
16486
16502
  }
16487
16503
  }
16488
- if (inPre && tag && currentOptions.isPreTag(tag)) {
16489
- const first = nodes[0];
16490
- if (first && first.type === 2) {
16491
- first.content = first.content.replace(/^\r?\n/, "");
16492
- }
16493
- }
16494
16504
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
16495
16505
  }
16496
16506
  function isAllWhitespace(str) {
@@ -17098,10 +17108,8 @@ function createRootCodegen(root, context) {
17098
17108
  }
17099
17109
  } else if (children.length > 1) {
17100
17110
  let patchFlag = 64;
17101
- let patchFlagText = PatchFlagNames[64];
17102
17111
  if (children.filter((c) => c.type !== 3).length === 1) {
17103
17112
  patchFlag |= 2048;
17104
- patchFlagText += `, ${PatchFlagNames[2048]}`;
17105
17113
  }
17106
17114
  root.codegenNode = createVNodeCall(
17107
17115
  context,
@@ -18009,10 +18017,8 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
18009
18017
  return vnodeCall;
18010
18018
  } else {
18011
18019
  let patchFlag = 64;
18012
- let patchFlagText = PatchFlagNames[64];
18013
18020
  if (!branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
18014
18021
  patchFlag |= 2048;
18015
- patchFlagText += `, ${PatchFlagNames[2048]}`;
18016
18022
  }
18017
18023
  return createVNodeCall(
18018
18024
  context,
@@ -19760,6 +19766,7 @@ const parserOptions = {
19760
19766
  isVoidTag,
19761
19767
  isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
19762
19768
  isPreTag: (tag) => tag === "pre",
19769
+ isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
19763
19770
  decodeEntities: decodeHtmlBrowser ,
19764
19771
  isBuiltInComponent: (tag) => {
19765
19772
  if (tag === "Transition" || tag === "transition") {
@@ -19987,10 +19994,7 @@ const isNonKeyModifier = /* @__PURE__ */ makeMap(
19987
19994
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
19988
19995
  );
19989
19996
  const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
19990
- const isKeyboardEvent = /* @__PURE__ */ makeMap(
19991
- `onkeyup,onkeydown,onkeypress`,
19992
- true
19993
- );
19997
+ const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
19994
19998
  const resolveModifiers = (key, modifiers, context, loc) => {
19995
19999
  const keyModifiers = [];
19996
20000
  const nonKeyModifiers = [];
@@ -20008,7 +20012,7 @@ const resolveModifiers = (key, modifiers, context, loc) => {
20008
20012
  } else {
20009
20013
  if (maybeKeyModifier(modifier)) {
20010
20014
  if (isStaticExp(key)) {
20011
- if (isKeyboardEvent(key.content)) {
20015
+ if (isKeyboardEvent(key.content.toLowerCase())) {
20012
20016
  keyModifiers.push(modifier);
20013
20017
  } else {
20014
20018
  nonKeyModifiers.push(modifier);
@@ -20061,7 +20065,7 @@ const transformOn = (dir, node, context) => {
20061
20065
  ]);
20062
20066
  }
20063
20067
  if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
20064
- (!isStaticExp(key) || isKeyboardEvent(key.content))) {
20068
+ (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
20065
20069
  handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
20066
20070
  handlerExp,
20067
20071
  JSON.stringify(keyModifiers)