@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 = !!(process.env.NODE_ENV !== "production") ? 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 {
@@ -959,9 +959,25 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
959
959
  globalVersion++;
960
960
  return;
961
961
  }
962
- let deps = [];
962
+ const run = (dep) => {
963
+ if (dep) {
964
+ if (!!(process.env.NODE_ENV !== "production")) {
965
+ dep.trigger({
966
+ target,
967
+ type,
968
+ key,
969
+ newValue,
970
+ oldValue,
971
+ oldTarget
972
+ });
973
+ } else {
974
+ dep.trigger();
975
+ }
976
+ }
977
+ };
978
+ startBatch();
963
979
  if (type === "clear") {
964
- deps = [...depsMap.values()];
980
+ depsMap.forEach(run);
965
981
  } else {
966
982
  const targetIsArray = isArray(target);
967
983
  const isArrayIndex = targetIsArray && isIntegerKey(key);
@@ -969,59 +985,43 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
969
985
  const newLength = Number(newValue);
970
986
  depsMap.forEach((dep, key2) => {
971
987
  if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
972
- deps.push(dep);
988
+ run(dep);
973
989
  }
974
990
  });
975
991
  } else {
976
- const push = (dep) => dep && deps.push(dep);
977
992
  if (key !== void 0) {
978
- push(depsMap.get(key));
993
+ run(depsMap.get(key));
979
994
  }
980
995
  if (isArrayIndex) {
981
- push(depsMap.get(ARRAY_ITERATE_KEY));
996
+ run(depsMap.get(ARRAY_ITERATE_KEY));
982
997
  }
983
998
  switch (type) {
984
999
  case "add":
985
1000
  if (!targetIsArray) {
986
- push(depsMap.get(ITERATE_KEY));
1001
+ run(depsMap.get(ITERATE_KEY));
987
1002
  if (isMap(target)) {
988
- push(depsMap.get(MAP_KEY_ITERATE_KEY));
1003
+ run(depsMap.get(MAP_KEY_ITERATE_KEY));
989
1004
  }
990
1005
  } else if (isArrayIndex) {
991
- push(depsMap.get("length"));
1006
+ run(depsMap.get("length"));
992
1007
  }
993
1008
  break;
994
1009
  case "delete":
995
1010
  if (!targetIsArray) {
996
- push(depsMap.get(ITERATE_KEY));
1011
+ run(depsMap.get(ITERATE_KEY));
997
1012
  if (isMap(target)) {
998
- push(depsMap.get(MAP_KEY_ITERATE_KEY));
1013
+ run(depsMap.get(MAP_KEY_ITERATE_KEY));
999
1014
  }
1000
1015
  }
1001
1016
  break;
1002
1017
  case "set":
1003
1018
  if (isMap(target)) {
1004
- push(depsMap.get(ITERATE_KEY));
1019
+ run(depsMap.get(ITERATE_KEY));
1005
1020
  }
1006
1021
  break;
1007
1022
  }
1008
1023
  }
1009
1024
  }
1010
- startBatch();
1011
- for (const dep of deps) {
1012
- if (!!(process.env.NODE_ENV !== "production")) {
1013
- dep.trigger({
1014
- target,
1015
- type,
1016
- key,
1017
- newValue,
1018
- oldValue,
1019
- oldTarget
1020
- });
1021
- } else {
1022
- dep.trigger();
1023
- }
1024
- }
1025
1025
  endBatch();
1026
1026
  }
1027
1027
  function getDepFromReactive(object, key) {
@@ -1759,7 +1759,7 @@ function toRaw(observed) {
1759
1759
  return raw ? toRaw(raw) : observed;
1760
1760
  }
1761
1761
  function markRaw(value) {
1762
- if (Object.isExtensible(value)) {
1762
+ if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
1763
1763
  def(value, "__v_skip", true);
1764
1764
  }
1765
1765
  return value;
@@ -1975,8 +1975,8 @@ class ComputedRefImpl {
1975
1975
  * @internal
1976
1976
  */
1977
1977
  notify() {
1978
+ this.flags |= 16;
1978
1979
  if (activeSub !== this) {
1979
- this.flags |= 16;
1980
1980
  this.dep.notify();
1981
1981
  } else if (!!(process.env.NODE_ENV !== "production")) ;
1982
1982
  }
@@ -2669,23 +2669,19 @@ function flushJobs(seen) {
2669
2669
  }
2670
2670
  }
2671
2671
  function checkRecursiveUpdates(seen, fn) {
2672
- if (!seen.has(fn)) {
2673
- seen.set(fn, 1);
2674
- } else {
2675
- const count = seen.get(fn);
2676
- if (count > RECURSION_LIMIT) {
2677
- const instance = fn.i;
2678
- const componentName = instance && getComponentName(instance.type);
2679
- handleError(
2680
- `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.`,
2681
- null,
2682
- 10
2683
- );
2684
- return true;
2685
- } else {
2686
- seen.set(fn, count + 1);
2687
- }
2672
+ const count = seen.get(fn) || 0;
2673
+ if (count > RECURSION_LIMIT) {
2674
+ const instance = fn.i;
2675
+ const componentName = instance && getComponentName(instance.type);
2676
+ handleError(
2677
+ `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.`,
2678
+ null,
2679
+ 10
2680
+ );
2681
+ return true;
2688
2682
  }
2683
+ seen.set(fn, count + 1);
2684
+ return false;
2689
2685
  }
2690
2686
 
2691
2687
  let isHmrUpdating = false;
@@ -2766,7 +2762,9 @@ function reload(id, newComp) {
2766
2762
  dirtyInstances.delete(instance);
2767
2763
  } else if (instance.parent) {
2768
2764
  queueJob(() => {
2765
+ isHmrUpdating = true;
2769
2766
  instance.parent.update();
2767
+ isHmrUpdating = false;
2770
2768
  dirtyInstances.delete(instance);
2771
2769
  });
2772
2770
  } else if (instance.appContext.reload) {
@@ -3588,6 +3586,9 @@ const TeleportImpl = {
3588
3586
  insert(mainAnchor, container, anchor);
3589
3587
  const mount = (container2, anchor2) => {
3590
3588
  if (shapeFlag & 16) {
3589
+ if (parentComponent && parentComponent.isCE) {
3590
+ parentComponent.ce._teleportTarget = container2;
3591
+ }
3591
3592
  mountChildren(
3592
3593
  children,
3593
3594
  container2,
@@ -4622,7 +4623,11 @@ Server rendered element contains more child nodes than client vdom.`
4622
4623
  remove(cur);
4623
4624
  }
4624
4625
  } else if (shapeFlag & 8) {
4625
- if (el.textContent !== vnode.children) {
4626
+ let clientText = vnode.children;
4627
+ if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
4628
+ clientText = clientText.slice(1);
4629
+ }
4630
+ if (el.textContent !== clientText) {
4626
4631
  if (!isMismatchAllowed(el, 0 /* TEXT */)) {
4627
4632
  (!!(process.env.NODE_ENV !== "production") || __VUE_PROD_HYDRATION_MISMATCH_DETAILS__) && warn$1(
4628
4633
  `Hydration text content mismatch on`,
@@ -4832,7 +4837,7 @@ Server rendered element contains fewer child nodes than client vdom.`
4832
4837
  }
4833
4838
  };
4834
4839
  const isTemplateNode = (node) => {
4835
- return node.nodeType === 1 && node.tagName.toLowerCase() === "template";
4840
+ return node.nodeType === 1 && node.tagName === "TEMPLATE";
4836
4841
  };
4837
4842
  return [hydrate, hydrateNode];
4838
4843
  }
@@ -5184,7 +5189,7 @@ function defineAsyncComponent(source) {
5184
5189
  load().then(() => {
5185
5190
  loaded.value = true;
5186
5191
  if (instance.parent && isKeepAlive(instance.parent.vnode)) {
5187
- queueJob(instance.parent.update);
5192
+ instance.parent.update();
5188
5193
  }
5189
5194
  }).catch((err) => {
5190
5195
  onError(err);
@@ -5876,13 +5881,15 @@ function renderList(source, renderItem, cache, index) {
5876
5881
  const sourceIsArray = isArray(source);
5877
5882
  if (sourceIsArray || isString(source)) {
5878
5883
  const sourceIsReactiveArray = sourceIsArray && isReactive(source);
5884
+ let needsWrap = false;
5879
5885
  if (sourceIsReactiveArray) {
5886
+ needsWrap = !isShallow(source);
5880
5887
  source = shallowReadArray(source);
5881
5888
  }
5882
5889
  ret = new Array(source.length);
5883
5890
  for (let i = 0, l = source.length; i < l; i++) {
5884
5891
  ret[i] = renderItem(
5885
- sourceIsReactiveArray ? toReactive(source[i]) : source[i],
5892
+ needsWrap ? toReactive(source[i]) : source[i],
5886
5893
  i,
5887
5894
  void 0,
5888
5895
  cached && cached[i]
@@ -7135,7 +7142,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7135
7142
  return vm;
7136
7143
  }
7137
7144
  }
7138
- Vue.version = `2.6.14-compat:${"3.5.3"}`;
7145
+ Vue.version = `2.6.14-compat:${"3.5.5"}`;
7139
7146
  Vue.config = singletonApp.config;
7140
7147
  Vue.use = (plugin, ...options) => {
7141
7148
  if (plugin && isFunction(plugin.install)) {
@@ -8997,6 +9004,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8997
9004
  }
8998
9005
  }
8999
9006
  if (instance.asyncDep) {
9007
+ if (!!(process.env.NODE_ENV !== "production") && isHmrUpdating) initialVNode.el = null;
9000
9008
  parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
9001
9009
  if (!initialVNode.el) {
9002
9010
  const placeholder = instance.subTree = createVNode(Comment);
@@ -12302,7 +12310,7 @@ function isMemoSame(cached, memo) {
12302
12310
  return true;
12303
12311
  }
12304
12312
 
12305
- const version = "3.5.3";
12313
+ const version = "3.5.5";
12306
12314
  const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
12307
12315
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12308
12316
  const devtools = !!(process.env.NODE_ENV !== "production") || true ? devtools$1 : void 0;
@@ -13290,6 +13298,7 @@ class VueElement extends BaseClass {
13290
13298
  }
13291
13299
  }
13292
13300
  connectedCallback() {
13301
+ if (!this.isConnected) return;
13293
13302
  if (!this.shadowRoot) {
13294
13303
  this._parseSlots();
13295
13304
  }
@@ -13332,7 +13341,7 @@ class VueElement extends BaseClass {
13332
13341
  this._ob = null;
13333
13342
  }
13334
13343
  this._app && this._app.unmount();
13335
- this._instance.ce = void 0;
13344
+ if (this._instance) this._instance.ce = void 0;
13336
13345
  this._app = this._instance = null;
13337
13346
  }
13338
13347
  });
@@ -13551,7 +13560,7 @@ class VueElement extends BaseClass {
13551
13560
  }
13552
13561
  }
13553
13562
  /**
13554
- * Only called when shaddowRoot is false
13563
+ * Only called when shadowRoot is false
13555
13564
  */
13556
13565
  _parseSlots() {
13557
13566
  const slots = this._slots = {};
@@ -13563,10 +13572,10 @@ class VueElement extends BaseClass {
13563
13572
  }
13564
13573
  }
13565
13574
  /**
13566
- * Only called when shaddowRoot is false
13575
+ * Only called when shadowRoot is false
13567
13576
  */
13568
13577
  _renderSlots() {
13569
- const outlets = this.querySelectorAll("slot");
13578
+ const outlets = (this._teleportTarget || this).querySelectorAll("slot");
13570
13579
  const scopeId = this._instance.type.__scopeId;
13571
13580
  for (let i = 0; i < outlets.length; i++) {
13572
13581
  const o = outlets[i];
@@ -13754,7 +13763,7 @@ const TransitionGroupImpl = /* @__PURE__ */ decorate({
13754
13763
  child,
13755
13764
  resolveTransitionHooks(child, cssTransitionProps, state, instance)
13756
13765
  );
13757
- } else if (!!(process.env.NODE_ENV !== "production")) {
13766
+ } else if (!!(process.env.NODE_ENV !== "production") && child.type !== Text) {
13758
13767
  warn(`<TransitionGroup> children must be keyed.`);
13759
13768
  }
13760
13769
  }
@@ -14990,7 +14999,7 @@ class Tokenizer {
14990
14999
  this.sequenceIndex += 1;
14991
15000
  } else if (this.sequenceIndex === 0) {
14992
15001
  if (this.currentSequence === Sequences.TitleEnd || this.currentSequence === Sequences.TextareaEnd && !this.inSFCRoot) {
14993
- if (c === this.delimiterOpen[0]) {
15002
+ if (!this.inVPre && c === this.delimiterOpen[0]) {
14994
15003
  this.state = 2;
14995
15004
  this.delimiterIndex = 0;
14996
15005
  this.stateInterpolationOpen(c);
@@ -15960,6 +15969,7 @@ const defaultParserOptions = {
15960
15969
  getNamespace: () => 0,
15961
15970
  isVoidTag: NO,
15962
15971
  isPreTag: NO,
15972
+ isIgnoreNewlineTag: NO,
15963
15973
  isCustomElement: NO,
15964
15974
  onError: defaultOnError,
15965
15975
  onWarn: defaultOnWarn,
@@ -16402,7 +16412,7 @@ function onCloseTag(el, end, isImplied = false) {
16402
16412
  el.innerLoc.end.offset
16403
16413
  );
16404
16414
  }
16405
- const { tag, ns } = el;
16415
+ const { tag, ns, children } = el;
16406
16416
  if (!inVPre) {
16407
16417
  if (tag === "slot") {
16408
16418
  el.tagType = 2;
@@ -16413,7 +16423,13 @@ function onCloseTag(el, end, isImplied = false) {
16413
16423
  }
16414
16424
  }
16415
16425
  if (!tokenizer.inRCDATA) {
16416
- el.children = condenseWhitespace(el.children, el.tag);
16426
+ el.children = condenseWhitespace(children);
16427
+ }
16428
+ if (ns === 0 && currentOptions.isIgnoreNewlineTag(tag)) {
16429
+ const first = children[0];
16430
+ if (first && first.type === 2) {
16431
+ first.content = first.content.replace(/^\r?\n/, "");
16432
+ }
16417
16433
  }
16418
16434
  if (ns === 0 && currentOptions.isPreTag(tag)) {
16419
16435
  inPre--;
@@ -16565,12 +16581,6 @@ function condenseWhitespace(nodes, tag) {
16565
16581
  }
16566
16582
  }
16567
16583
  }
16568
- if (inPre && tag && currentOptions.isPreTag(tag)) {
16569
- const first = nodes[0];
16570
- if (first && first.type === 2) {
16571
- first.content = first.content.replace(/^\r?\n/, "");
16572
- }
16573
- }
16574
16584
  return removedWhitespace ? nodes.filter(Boolean) : nodes;
16575
16585
  }
16576
16586
  function isAllWhitespace(str) {
@@ -17179,10 +17189,8 @@ function createRootCodegen(root, context) {
17179
17189
  }
17180
17190
  } else if (children.length > 1) {
17181
17191
  let patchFlag = 64;
17182
- let patchFlagText = PatchFlagNames[64];
17183
17192
  if (!!(process.env.NODE_ENV !== "production") && children.filter((c) => c.type !== 3).length === 1) {
17184
17193
  patchFlag |= 2048;
17185
- patchFlagText += `, ${PatchFlagNames[2048]}`;
17186
17194
  }
17187
17195
  root.codegenNode = createVNodeCall(
17188
17196
  context,
@@ -18092,10 +18100,8 @@ function createChildrenCodegenNode(branch, keyIndex, context) {
18092
18100
  return vnodeCall;
18093
18101
  } else {
18094
18102
  let patchFlag = 64;
18095
- let patchFlagText = PatchFlagNames[64];
18096
18103
  if (!!(process.env.NODE_ENV !== "production") && !branch.isTemplateIf && children.filter((c) => c.type !== 3).length === 1) {
18097
18104
  patchFlag |= 2048;
18098
- patchFlagText += `, ${PatchFlagNames[2048]}`;
18099
18105
  }
18100
18106
  return createVNodeCall(
18101
18107
  context,
@@ -19843,6 +19849,7 @@ const parserOptions = {
19843
19849
  isVoidTag,
19844
19850
  isNativeTag: (tag) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
19845
19851
  isPreTag: (tag) => tag === "pre",
19852
+ isIgnoreNewlineTag: (tag) => tag === "pre" || tag === "textarea",
19846
19853
  decodeEntities: decodeHtmlBrowser ,
19847
19854
  isBuiltInComponent: (tag) => {
19848
19855
  if (tag === "Transition" || tag === "transition") {
@@ -20070,10 +20077,7 @@ const isNonKeyModifier = /* @__PURE__ */ makeMap(
20070
20077
  `stop,prevent,self,ctrl,shift,alt,meta,exact,middle`
20071
20078
  );
20072
20079
  const maybeKeyModifier = /* @__PURE__ */ makeMap("left,right");
20073
- const isKeyboardEvent = /* @__PURE__ */ makeMap(
20074
- `onkeyup,onkeydown,onkeypress`,
20075
- true
20076
- );
20080
+ const isKeyboardEvent = /* @__PURE__ */ makeMap(`onkeyup,onkeydown,onkeypress`);
20077
20081
  const resolveModifiers = (key, modifiers, context, loc) => {
20078
20082
  const keyModifiers = [];
20079
20083
  const nonKeyModifiers = [];
@@ -20091,7 +20095,7 @@ const resolveModifiers = (key, modifiers, context, loc) => {
20091
20095
  } else {
20092
20096
  if (maybeKeyModifier(modifier)) {
20093
20097
  if (isStaticExp(key)) {
20094
- if (isKeyboardEvent(key.content)) {
20098
+ if (isKeyboardEvent(key.content.toLowerCase())) {
20095
20099
  keyModifiers.push(modifier);
20096
20100
  } else {
20097
20101
  nonKeyModifiers.push(modifier);
@@ -20144,7 +20148,7 @@ const transformOn = (dir, node, context) => {
20144
20148
  ]);
20145
20149
  }
20146
20150
  if (keyModifiers.length && // if event name is dynamic, always wrap with keys guard
20147
- (!isStaticExp(key) || isKeyboardEvent(key.content))) {
20151
+ (!isStaticExp(key) || isKeyboardEvent(key.content.toLowerCase()))) {
20148
20152
  handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
20149
20153
  handlerExp,
20150
20154
  JSON.stringify(keyModifiers)