@vue/compat 3.3.6 → 3.3.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.
package/dist/vue.cjs.js CHANGED
@@ -678,7 +678,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
678
678
  } else if (key === "length" && isArray(target)) {
679
679
  const newLength = Number(newValue);
680
680
  depsMap.forEach((dep, key2) => {
681
- if (key2 === "length" || key2 >= newLength) {
681
+ if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
682
682
  deps.push(dep);
683
683
  }
684
684
  });
@@ -1774,8 +1774,13 @@ function findInsertionIndex(id) {
1774
1774
  let end = queue.length;
1775
1775
  while (start < end) {
1776
1776
  const middle = start + end >>> 1;
1777
- const middleJobId = getId(queue[middle]);
1778
- middleJobId < id ? start = middle + 1 : end = middle;
1777
+ const middleJob = queue[middle];
1778
+ const middleJobId = getId(middleJob);
1779
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
1780
+ start = middle + 1;
1781
+ } else {
1782
+ end = middle;
1783
+ }
1779
1784
  }
1780
1785
  return start;
1781
1786
  }
@@ -3050,6 +3055,65 @@ function updateHOCHostEl({ vnode, parent }, el) {
3050
3055
  }
3051
3056
  }
3052
3057
 
3058
+ const COMPONENTS = "components";
3059
+ const DIRECTIVES = "directives";
3060
+ const FILTERS = "filters";
3061
+ function resolveComponent(name, maybeSelfReference) {
3062
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
3063
+ }
3064
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
3065
+ function resolveDynamicComponent(component) {
3066
+ if (isString(component)) {
3067
+ return resolveAsset(COMPONENTS, component, false) || component;
3068
+ } else {
3069
+ return component || NULL_DYNAMIC_COMPONENT;
3070
+ }
3071
+ }
3072
+ function resolveDirective(name) {
3073
+ return resolveAsset(DIRECTIVES, name);
3074
+ }
3075
+ function resolveFilter$1(name) {
3076
+ return resolveAsset(FILTERS, name);
3077
+ }
3078
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
3079
+ const instance = currentRenderingInstance || currentInstance;
3080
+ if (instance) {
3081
+ const Component = instance.type;
3082
+ if (type === COMPONENTS) {
3083
+ const selfName = getComponentName(
3084
+ Component,
3085
+ false
3086
+ /* do not include inferred name to avoid breaking existing code */
3087
+ );
3088
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
3089
+ return Component;
3090
+ }
3091
+ }
3092
+ const res = (
3093
+ // local registration
3094
+ // check instance[type] first which is resolved for options API
3095
+ resolve(instance[type] || Component[type], name) || // global registration
3096
+ resolve(instance.appContext[type], name)
3097
+ );
3098
+ if (!res && maybeSelfReference) {
3099
+ return Component;
3100
+ }
3101
+ if (warnMissing && !res) {
3102
+ const extra = type === COMPONENTS ? `
3103
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
3104
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
3105
+ }
3106
+ return res;
3107
+ } else {
3108
+ warn(
3109
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
3110
+ );
3111
+ }
3112
+ }
3113
+ function resolve(registry, name) {
3114
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3115
+ }
3116
+
3053
3117
  const isSuspense = (type) => type.__isSuspense;
3054
3118
  const SuspenseImpl = {
3055
3119
  name: "Suspense",
@@ -3363,14 +3427,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3363
3427
  parentComponent: parentComponent2,
3364
3428
  container: container2
3365
3429
  } = suspense;
3430
+ let delayEnter = false;
3366
3431
  if (suspense.isHydrating) {
3367
3432
  suspense.isHydrating = false;
3368
3433
  } else if (!resume) {
3369
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3434
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3370
3435
  if (delayEnter) {
3371
3436
  activeBranch.transition.afterLeave = () => {
3372
3437
  if (pendingId === suspense.pendingId) {
3373
3438
  move(pendingBranch, container2, anchor2, 0);
3439
+ queuePostFlushCb(effects);
3374
3440
  }
3375
3441
  };
3376
3442
  }
@@ -3396,7 +3462,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3396
3462
  }
3397
3463
  parent = parent.parent;
3398
3464
  }
3399
- if (!hasUnresolvedAncestor) {
3465
+ if (!hasUnresolvedAncestor && !delayEnter) {
3400
3466
  queuePostFlushCb(effects);
3401
3467
  }
3402
3468
  suspense.effects = [];
@@ -3582,7 +3648,7 @@ function normalizeSuspenseSlot(s) {
3582
3648
  }
3583
3649
  if (isArray(s)) {
3584
3650
  const singleChild = filterSingleRoot(s);
3585
- if (!singleChild) {
3651
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3586
3652
  warn(`<Suspense> slots expect a single root node.`);
3587
3653
  }
3588
3654
  s = singleChild;
@@ -4786,65 +4852,6 @@ function getCompatListeners(instance) {
4786
4852
  return listeners;
4787
4853
  }
4788
4854
 
4789
- const COMPONENTS = "components";
4790
- const DIRECTIVES = "directives";
4791
- const FILTERS = "filters";
4792
- function resolveComponent(name, maybeSelfReference) {
4793
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4794
- }
4795
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4796
- function resolveDynamicComponent(component) {
4797
- if (isString(component)) {
4798
- return resolveAsset(COMPONENTS, component, false) || component;
4799
- } else {
4800
- return component || NULL_DYNAMIC_COMPONENT;
4801
- }
4802
- }
4803
- function resolveDirective(name) {
4804
- return resolveAsset(DIRECTIVES, name);
4805
- }
4806
- function resolveFilter$1(name) {
4807
- return resolveAsset(FILTERS, name);
4808
- }
4809
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4810
- const instance = currentRenderingInstance || currentInstance;
4811
- if (instance) {
4812
- const Component = instance.type;
4813
- if (type === COMPONENTS) {
4814
- const selfName = getComponentName(
4815
- Component,
4816
- false
4817
- /* do not include inferred name to avoid breaking existing code */
4818
- );
4819
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4820
- return Component;
4821
- }
4822
- }
4823
- const res = (
4824
- // local registration
4825
- // check instance[type] first which is resolved for options API
4826
- resolve(instance[type] || Component[type], name) || // global registration
4827
- resolve(instance.appContext[type], name)
4828
- );
4829
- if (!res && maybeSelfReference) {
4830
- return Component;
4831
- }
4832
- if (warnMissing && !res) {
4833
- const extra = type === COMPONENTS ? `
4834
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4835
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4836
- }
4837
- return res;
4838
- } else {
4839
- warn(
4840
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4841
- );
4842
- }
4843
- }
4844
- function resolve(registry, name) {
4845
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4846
- }
4847
-
4848
4855
  function convertLegacyRenderFn(instance) {
4849
4856
  const Component2 = instance.type;
4850
4857
  const render = Component2.render;
@@ -6347,7 +6354,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6347
6354
  return vm;
6348
6355
  }
6349
6356
  }
6350
- Vue.version = `2.6.14-compat:${"3.3.6"}`;
6357
+ Vue.version = `2.6.14-compat:${"3.3.8"}`;
6351
6358
  Vue.config = singletonApp.config;
6352
6359
  Vue.use = (p, ...options) => {
6353
6360
  if (p && isFunction(p.install)) {
@@ -7676,7 +7683,14 @@ function createHydrationFunctions(rendererInternals) {
7676
7683
  }
7677
7684
  break;
7678
7685
  case Comment:
7679
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7686
+ if (isTemplateNode(node)) {
7687
+ nextNode = nextSibling(node);
7688
+ replaceNode(
7689
+ vnode.el = node.content.firstChild,
7690
+ node,
7691
+ parentComponent
7692
+ );
7693
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7680
7694
  nextNode = onMismatch();
7681
7695
  } else {
7682
7696
  nextNode = nextSibling(node);
@@ -7719,7 +7733,7 @@ function createHydrationFunctions(rendererInternals) {
7719
7733
  break;
7720
7734
  default:
7721
7735
  if (shapeFlag & 1) {
7722
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
7736
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
7723
7737
  nextNode = onMismatch();
7724
7738
  } else {
7725
7739
  nextNode = hydrateElement(
@@ -7734,6 +7748,13 @@ function createHydrationFunctions(rendererInternals) {
7734
7748
  } else if (shapeFlag & 6) {
7735
7749
  vnode.slotScopeIds = slotScopeIds;
7736
7750
  const container = parentNode(node);
7751
+ if (isFragmentStart) {
7752
+ nextNode = locateClosingAnchor(node);
7753
+ } else if (isComment(node) && node.data === "teleport start") {
7754
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
7755
+ } else {
7756
+ nextNode = nextSibling(node);
7757
+ }
7737
7758
  mountComponent(
7738
7759
  vnode,
7739
7760
  container,
@@ -7743,10 +7764,6 @@ function createHydrationFunctions(rendererInternals) {
7743
7764
  isSVGContainer(container),
7744
7765
  optimized
7745
7766
  );
7746
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
7747
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
7748
- nextNode = nextSibling(nextNode);
7749
- }
7750
7767
  if (isAsyncWrapper(vnode)) {
7751
7768
  let subTree;
7752
7769
  if (isFragmentStart) {
@@ -7796,7 +7813,7 @@ function createHydrationFunctions(rendererInternals) {
7796
7813
  };
7797
7814
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7798
7815
  optimized = optimized || !!vnode.dynamicChildren;
7799
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
7816
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7800
7817
  const forcePatchValue = type === "input" && dirs || type === "option";
7801
7818
  {
7802
7819
  if (dirs) {
@@ -7833,12 +7850,23 @@ function createHydrationFunctions(rendererInternals) {
7833
7850
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
7834
7851
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7835
7852
  }
7853
+ let needCallTransitionHooks = false;
7854
+ if (isTemplateNode(el)) {
7855
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
7856
+ const content = el.content.firstChild;
7857
+ if (needCallTransitionHooks) {
7858
+ transition.beforeEnter(content);
7859
+ }
7860
+ replaceNode(content, el, parentComponent);
7861
+ vnode.el = el = content;
7862
+ }
7836
7863
  if (dirs) {
7837
7864
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
7838
7865
  }
7839
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
7866
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
7840
7867
  queueEffectWithSuspense(() => {
7841
7868
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7869
+ needCallTransitionHooks && transition.enter(el);
7842
7870
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7843
7871
  }, parentSuspense);
7844
7872
  }
@@ -7956,7 +7984,7 @@ function createHydrationFunctions(rendererInternals) {
7956
7984
  );
7957
7985
  vnode.el = null;
7958
7986
  if (isFragment) {
7959
- const end = locateClosingAsyncAnchor(node);
7987
+ const end = locateClosingAnchor(node);
7960
7988
  while (true) {
7961
7989
  const next2 = nextSibling(node);
7962
7990
  if (next2 && next2 !== end) {
@@ -7981,14 +8009,14 @@ function createHydrationFunctions(rendererInternals) {
7981
8009
  );
7982
8010
  return next;
7983
8011
  };
7984
- const locateClosingAsyncAnchor = (node) => {
8012
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
7985
8013
  let match = 0;
7986
8014
  while (node) {
7987
8015
  node = nextSibling(node);
7988
8016
  if (node && isComment(node)) {
7989
- if (node.data === "[")
8017
+ if (node.data === open)
7990
8018
  match++;
7991
- if (node.data === "]") {
8019
+ if (node.data === close) {
7992
8020
  if (match === 0) {
7993
8021
  return nextSibling(node);
7994
8022
  } else {
@@ -7999,6 +8027,22 @@ function createHydrationFunctions(rendererInternals) {
7999
8027
  }
8000
8028
  return node;
8001
8029
  };
8030
+ const replaceNode = (newNode, oldNode, parentComponent) => {
8031
+ const parentNode2 = oldNode.parentNode;
8032
+ if (parentNode2) {
8033
+ parentNode2.replaceChild(newNode, oldNode);
8034
+ }
8035
+ let parent = parentComponent;
8036
+ while (parent) {
8037
+ if (parent.vnode.el === oldNode) {
8038
+ parent.vnode.el = parent.subTree.el = newNode;
8039
+ }
8040
+ parent = parent.parent;
8041
+ }
8042
+ };
8043
+ const isTemplateNode = (node) => {
8044
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
8045
+ };
8002
8046
  return [hydrate, hydrateNode];
8003
8047
  }
8004
8048
 
@@ -8326,7 +8370,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8326
8370
  if (dirs) {
8327
8371
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
8328
8372
  }
8329
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
8373
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
8330
8374
  if (needCallTransitionHooks) {
8331
8375
  transition.beforeEnter(el);
8332
8376
  }
@@ -9243,8 +9287,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9243
9287
  moveStaticNode(vnode, container, anchor);
9244
9288
  return;
9245
9289
  }
9246
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
9247
- if (needTransition) {
9290
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
9291
+ if (needTransition2) {
9248
9292
  if (moveType === 0) {
9249
9293
  transition.beforeEnter(el);
9250
9294
  hostInsert(el, container, anchor);
@@ -9473,6 +9517,9 @@ function baseCreateRenderer(options, createHydrationFns) {
9473
9517
  function toggleRecurse({ effect, update }, allowed) {
9474
9518
  effect.allowRecurse = update.allowRecurse = allowed;
9475
9519
  }
9520
+ function needTransition(parentSuspense, transition) {
9521
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
9522
+ }
9476
9523
  function traverseStaticChildren(n1, n2, shallow = false) {
9477
9524
  const ch1 = n1.children;
9478
9525
  const ch2 = n2.children;
@@ -10893,7 +10940,7 @@ function isMemoSame(cached, memo) {
10893
10940
  return true;
10894
10941
  }
10895
10942
 
10896
- const version = "3.3.6";
10943
+ const version = "3.3.8";
10897
10944
  const _ssrUtils = {
10898
10945
  createComponentInstance,
10899
10946
  setupComponent,
@@ -14168,9 +14215,13 @@ function walk(node, context, doNotHoistNode = false) {
14168
14215
  context.transformHoist(children, context, node);
14169
14216
  }
14170
14217
  if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
14171
- node.codegenNode.children = context.hoist(
14218
+ const hoisted = context.hoist(
14172
14219
  createArrayExpression(node.codegenNode.children)
14173
14220
  );
14221
+ if (context.hmr) {
14222
+ hoisted.content = `[...${hoisted.content}]`;
14223
+ }
14224
+ node.codegenNode.children = hoisted;
14174
14225
  }
14175
14226
  }
14176
14227
  function getConstantType(node, context) {
@@ -14343,6 +14394,7 @@ function createTransformContext(root, {
14343
14394
  filename = "",
14344
14395
  prefixIdentifiers = false,
14345
14396
  hoistStatic: hoistStatic2 = false,
14397
+ hmr = false,
14346
14398
  cacheHandlers = false,
14347
14399
  nodeTransforms = [],
14348
14400
  directiveTransforms = {},
@@ -14368,6 +14420,7 @@ function createTransformContext(root, {
14368
14420
  selfName: nameMatch && capitalize(camelize(nameMatch[1])),
14369
14421
  prefixIdentifiers,
14370
14422
  hoistStatic: hoistStatic2,
14423
+ hmr,
14371
14424
  cacheHandlers,
14372
14425
  nodeTransforms,
14373
14426
  directiveTransforms,
@@ -15750,8 +15803,8 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
15750
15803
  const isScopeVarReference = context.identifiers[rawExp];
15751
15804
  const isAllowedGlobal = isGloballyAllowed(rawExp);
15752
15805
  const isLiteral = isLiteralWhitelisted(rawExp);
15753
- if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
15754
- if (isConst(bindingMetadata[node.content])) {
15806
+ if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
15807
+ if (isConst(bindingMetadata[rawExp])) {
15755
15808
  node.constType = 1;
15756
15809
  }
15757
15810
  node.content = rewriteIdentifier(rawExp);
@@ -16412,7 +16465,7 @@ const trackVForSlotScopes = (node, context) => {
16412
16465
  }
16413
16466
  }
16414
16467
  };
16415
- const buildClientSlotFn = (props, children, loc) => createFunctionExpression(
16468
+ const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
16416
16469
  props,
16417
16470
  children,
16418
16471
  false,
@@ -16437,7 +16490,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16437
16490
  slotsProperties.push(
16438
16491
  createObjectProperty(
16439
16492
  arg || createSimpleExpression("default", true),
16440
- buildSlotFn(exp, children, loc)
16493
+ buildSlotFn(exp, void 0, children, loc)
16441
16494
  )
16442
16495
  );
16443
16496
  }
@@ -16474,10 +16527,15 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16474
16527
  } else {
16475
16528
  hasDynamicSlots = true;
16476
16529
  }
16477
- const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
16530
+ const vFor = findDir(slotElement, "for");
16531
+ const slotFunction = buildSlotFn(
16532
+ slotProps,
16533
+ vFor == null ? void 0 : vFor.exp,
16534
+ slotChildren,
16535
+ slotLoc
16536
+ );
16478
16537
  let vIf;
16479
16538
  let vElse;
16480
- let vFor;
16481
16539
  if (vIf = findDir(slotElement, "if")) {
16482
16540
  hasDynamicSlots = true;
16483
16541
  dynamicSlots.push(
@@ -16522,7 +16580,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16522
16580
  createCompilerError(30, vElse.loc)
16523
16581
  );
16524
16582
  }
16525
- } else if (vFor = findDir(slotElement, "for")) {
16583
+ } else if (vFor) {
16526
16584
  hasDynamicSlots = true;
16527
16585
  const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
16528
16586
  if (parseResult) {
@@ -16563,7 +16621,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
16563
16621
  }
16564
16622
  if (!onComponentSlot) {
16565
16623
  const buildDefaultSlotProperty = (props, children2) => {
16566
- const fn = buildSlotFn(props, children2, loc);
16624
+ const fn = buildSlotFn(props, void 0, children2, loc);
16567
16625
  if (context.compatConfig) {
16568
16626
  fn.isNonScopedSlot = true;
16569
16627
  }