@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.
@@ -605,7 +605,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
605
605
  } else if (key === "length" && isArray(target)) {
606
606
  const newLength = Number(newValue);
607
607
  depsMap.forEach((dep, key2) => {
608
- if (key2 === "length" || key2 >= newLength) {
608
+ if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
609
609
  deps.push(dep);
610
610
  }
611
611
  });
@@ -1701,8 +1701,13 @@ function findInsertionIndex(id) {
1701
1701
  let end = queue.length;
1702
1702
  while (start < end) {
1703
1703
  const middle = start + end >>> 1;
1704
- const middleJobId = getId(queue[middle]);
1705
- middleJobId < id ? start = middle + 1 : end = middle;
1704
+ const middleJob = queue[middle];
1705
+ const middleJobId = getId(middleJob);
1706
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
1707
+ start = middle + 1;
1708
+ } else {
1709
+ end = middle;
1710
+ }
1706
1711
  }
1707
1712
  return start;
1708
1713
  }
@@ -2977,6 +2982,65 @@ function updateHOCHostEl({ vnode, parent }, el) {
2977
2982
  }
2978
2983
  }
2979
2984
 
2985
+ const COMPONENTS = "components";
2986
+ const DIRECTIVES = "directives";
2987
+ const FILTERS = "filters";
2988
+ function resolveComponent(name, maybeSelfReference) {
2989
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2990
+ }
2991
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2992
+ function resolveDynamicComponent(component) {
2993
+ if (isString(component)) {
2994
+ return resolveAsset(COMPONENTS, component, false) || component;
2995
+ } else {
2996
+ return component || NULL_DYNAMIC_COMPONENT;
2997
+ }
2998
+ }
2999
+ function resolveDirective(name) {
3000
+ return resolveAsset(DIRECTIVES, name);
3001
+ }
3002
+ function resolveFilter$1(name) {
3003
+ return resolveAsset(FILTERS, name);
3004
+ }
3005
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
3006
+ const instance = currentRenderingInstance || currentInstance;
3007
+ if (instance) {
3008
+ const Component = instance.type;
3009
+ if (type === COMPONENTS) {
3010
+ const selfName = getComponentName(
3011
+ Component,
3012
+ false
3013
+ /* do not include inferred name to avoid breaking existing code */
3014
+ );
3015
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
3016
+ return Component;
3017
+ }
3018
+ }
3019
+ const res = (
3020
+ // local registration
3021
+ // check instance[type] first which is resolved for options API
3022
+ resolve(instance[type] || Component[type], name) || // global registration
3023
+ resolve(instance.appContext[type], name)
3024
+ );
3025
+ if (!res && maybeSelfReference) {
3026
+ return Component;
3027
+ }
3028
+ if (warnMissing && !res) {
3029
+ const extra = type === COMPONENTS ? `
3030
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
3031
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
3032
+ }
3033
+ return res;
3034
+ } else {
3035
+ warn(
3036
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
3037
+ );
3038
+ }
3039
+ }
3040
+ function resolve(registry, name) {
3041
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3042
+ }
3043
+
2980
3044
  const isSuspense = (type) => type.__isSuspense;
2981
3045
  const SuspenseImpl = {
2982
3046
  name: "Suspense",
@@ -3290,14 +3354,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3290
3354
  parentComponent: parentComponent2,
3291
3355
  container: container2
3292
3356
  } = suspense;
3357
+ let delayEnter = false;
3293
3358
  if (suspense.isHydrating) {
3294
3359
  suspense.isHydrating = false;
3295
3360
  } else if (!resume) {
3296
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3361
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3297
3362
  if (delayEnter) {
3298
3363
  activeBranch.transition.afterLeave = () => {
3299
3364
  if (pendingId === suspense.pendingId) {
3300
3365
  move(pendingBranch, container2, anchor2, 0);
3366
+ queuePostFlushCb(effects);
3301
3367
  }
3302
3368
  };
3303
3369
  }
@@ -3323,7 +3389,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3323
3389
  }
3324
3390
  parent = parent.parent;
3325
3391
  }
3326
- if (!hasUnresolvedAncestor) {
3392
+ if (!hasUnresolvedAncestor && !delayEnter) {
3327
3393
  queuePostFlushCb(effects);
3328
3394
  }
3329
3395
  suspense.effects = [];
@@ -3509,7 +3575,7 @@ function normalizeSuspenseSlot(s) {
3509
3575
  }
3510
3576
  if (isArray(s)) {
3511
3577
  const singleChild = filterSingleRoot(s);
3512
- if (!singleChild) {
3578
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3513
3579
  warn(`<Suspense> slots expect a single root node.`);
3514
3580
  }
3515
3581
  s = singleChild;
@@ -4686,65 +4752,6 @@ function getCompatListeners(instance) {
4686
4752
  return listeners;
4687
4753
  }
4688
4754
 
4689
- const COMPONENTS = "components";
4690
- const DIRECTIVES = "directives";
4691
- const FILTERS = "filters";
4692
- function resolveComponent(name, maybeSelfReference) {
4693
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4694
- }
4695
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4696
- function resolveDynamicComponent(component) {
4697
- if (isString(component)) {
4698
- return resolveAsset(COMPONENTS, component, false) || component;
4699
- } else {
4700
- return component || NULL_DYNAMIC_COMPONENT;
4701
- }
4702
- }
4703
- function resolveDirective(name) {
4704
- return resolveAsset(DIRECTIVES, name);
4705
- }
4706
- function resolveFilter$1(name) {
4707
- return resolveAsset(FILTERS, name);
4708
- }
4709
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4710
- const instance = currentRenderingInstance || currentInstance;
4711
- if (instance) {
4712
- const Component = instance.type;
4713
- if (type === COMPONENTS) {
4714
- const selfName = getComponentName(
4715
- Component,
4716
- false
4717
- /* do not include inferred name to avoid breaking existing code */
4718
- );
4719
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4720
- return Component;
4721
- }
4722
- }
4723
- const res = (
4724
- // local registration
4725
- // check instance[type] first which is resolved for options API
4726
- resolve(instance[type] || Component[type], name) || // global registration
4727
- resolve(instance.appContext[type], name)
4728
- );
4729
- if (!res && maybeSelfReference) {
4730
- return Component;
4731
- }
4732
- if (warnMissing && !res) {
4733
- const extra = type === COMPONENTS ? `
4734
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4735
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4736
- }
4737
- return res;
4738
- } else {
4739
- warn(
4740
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4741
- );
4742
- }
4743
- }
4744
- function resolve(registry, name) {
4745
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4746
- }
4747
-
4748
4755
  function convertLegacyRenderFn(instance) {
4749
4756
  const Component2 = instance.type;
4750
4757
  const render = Component2.render;
@@ -6247,7 +6254,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6247
6254
  return vm;
6248
6255
  }
6249
6256
  }
6250
- Vue.version = `2.6.14-compat:${"3.3.6"}`;
6257
+ Vue.version = `2.6.14-compat:${"3.3.8"}`;
6251
6258
  Vue.config = singletonApp.config;
6252
6259
  Vue.use = (p, ...options) => {
6253
6260
  if (p && isFunction(p.install)) {
@@ -7576,7 +7583,14 @@ function createHydrationFunctions(rendererInternals) {
7576
7583
  }
7577
7584
  break;
7578
7585
  case Comment:
7579
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7586
+ if (isTemplateNode(node)) {
7587
+ nextNode = nextSibling(node);
7588
+ replaceNode(
7589
+ vnode.el = node.content.firstChild,
7590
+ node,
7591
+ parentComponent
7592
+ );
7593
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7580
7594
  nextNode = onMismatch();
7581
7595
  } else {
7582
7596
  nextNode = nextSibling(node);
@@ -7619,7 +7633,7 @@ function createHydrationFunctions(rendererInternals) {
7619
7633
  break;
7620
7634
  default:
7621
7635
  if (shapeFlag & 1) {
7622
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
7636
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
7623
7637
  nextNode = onMismatch();
7624
7638
  } else {
7625
7639
  nextNode = hydrateElement(
@@ -7634,6 +7648,13 @@ function createHydrationFunctions(rendererInternals) {
7634
7648
  } else if (shapeFlag & 6) {
7635
7649
  vnode.slotScopeIds = slotScopeIds;
7636
7650
  const container = parentNode(node);
7651
+ if (isFragmentStart) {
7652
+ nextNode = locateClosingAnchor(node);
7653
+ } else if (isComment(node) && node.data === "teleport start") {
7654
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
7655
+ } else {
7656
+ nextNode = nextSibling(node);
7657
+ }
7637
7658
  mountComponent(
7638
7659
  vnode,
7639
7660
  container,
@@ -7643,10 +7664,6 @@ function createHydrationFunctions(rendererInternals) {
7643
7664
  isSVGContainer(container),
7644
7665
  optimized
7645
7666
  );
7646
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
7647
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
7648
- nextNode = nextSibling(nextNode);
7649
- }
7650
7667
  if (isAsyncWrapper(vnode)) {
7651
7668
  let subTree;
7652
7669
  if (isFragmentStart) {
@@ -7696,7 +7713,7 @@ function createHydrationFunctions(rendererInternals) {
7696
7713
  };
7697
7714
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7698
7715
  optimized = optimized || !!vnode.dynamicChildren;
7699
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
7716
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7700
7717
  const forcePatchValue = type === "input" && dirs || type === "option";
7701
7718
  {
7702
7719
  if (dirs) {
@@ -7733,12 +7750,23 @@ function createHydrationFunctions(rendererInternals) {
7733
7750
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
7734
7751
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7735
7752
  }
7753
+ let needCallTransitionHooks = false;
7754
+ if (isTemplateNode(el)) {
7755
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
7756
+ const content = el.content.firstChild;
7757
+ if (needCallTransitionHooks) {
7758
+ transition.beforeEnter(content);
7759
+ }
7760
+ replaceNode(content, el, parentComponent);
7761
+ vnode.el = el = content;
7762
+ }
7736
7763
  if (dirs) {
7737
7764
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
7738
7765
  }
7739
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
7766
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
7740
7767
  queueEffectWithSuspense(() => {
7741
7768
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7769
+ needCallTransitionHooks && transition.enter(el);
7742
7770
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7743
7771
  }, parentSuspense);
7744
7772
  }
@@ -7856,7 +7884,7 @@ function createHydrationFunctions(rendererInternals) {
7856
7884
  );
7857
7885
  vnode.el = null;
7858
7886
  if (isFragment) {
7859
- const end = locateClosingAsyncAnchor(node);
7887
+ const end = locateClosingAnchor(node);
7860
7888
  while (true) {
7861
7889
  const next2 = nextSibling(node);
7862
7890
  if (next2 && next2 !== end) {
@@ -7881,14 +7909,14 @@ function createHydrationFunctions(rendererInternals) {
7881
7909
  );
7882
7910
  return next;
7883
7911
  };
7884
- const locateClosingAsyncAnchor = (node) => {
7912
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
7885
7913
  let match = 0;
7886
7914
  while (node) {
7887
7915
  node = nextSibling(node);
7888
7916
  if (node && isComment(node)) {
7889
- if (node.data === "[")
7917
+ if (node.data === open)
7890
7918
  match++;
7891
- if (node.data === "]") {
7919
+ if (node.data === close) {
7892
7920
  if (match === 0) {
7893
7921
  return nextSibling(node);
7894
7922
  } else {
@@ -7899,6 +7927,22 @@ function createHydrationFunctions(rendererInternals) {
7899
7927
  }
7900
7928
  return node;
7901
7929
  };
7930
+ const replaceNode = (newNode, oldNode, parentComponent) => {
7931
+ const parentNode2 = oldNode.parentNode;
7932
+ if (parentNode2) {
7933
+ parentNode2.replaceChild(newNode, oldNode);
7934
+ }
7935
+ let parent = parentComponent;
7936
+ while (parent) {
7937
+ if (parent.vnode.el === oldNode) {
7938
+ parent.vnode.el = parent.subTree.el = newNode;
7939
+ }
7940
+ parent = parent.parent;
7941
+ }
7942
+ };
7943
+ const isTemplateNode = (node) => {
7944
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
7945
+ };
7902
7946
  return [hydrate, hydrateNode];
7903
7947
  }
7904
7948
 
@@ -8226,7 +8270,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8226
8270
  if (dirs) {
8227
8271
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
8228
8272
  }
8229
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
8273
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
8230
8274
  if (needCallTransitionHooks) {
8231
8275
  transition.beforeEnter(el);
8232
8276
  }
@@ -9143,8 +9187,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9143
9187
  moveStaticNode(vnode, container, anchor);
9144
9188
  return;
9145
9189
  }
9146
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
9147
- if (needTransition) {
9190
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
9191
+ if (needTransition2) {
9148
9192
  if (moveType === 0) {
9149
9193
  transition.beforeEnter(el);
9150
9194
  hostInsert(el, container, anchor);
@@ -9373,6 +9417,9 @@ function baseCreateRenderer(options, createHydrationFns) {
9373
9417
  function toggleRecurse({ effect, update }, allowed) {
9374
9418
  effect.allowRecurse = update.allowRecurse = allowed;
9375
9419
  }
9420
+ function needTransition(parentSuspense, transition) {
9421
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
9422
+ }
9376
9423
  function traverseStaticChildren(n1, n2, shallow = false) {
9377
9424
  const ch1 = n1.children;
9378
9425
  const ch2 = n2.children;
@@ -10781,7 +10828,7 @@ function isMemoSame(cached, memo) {
10781
10828
  return true;
10782
10829
  }
10783
10830
 
10784
- const version = "3.3.6";
10831
+ const version = "3.3.8";
10785
10832
  const ssrUtils = null;
10786
10833
  const resolveFilter = resolveFilter$1 ;
10787
10834
  const _compatUtils = {
@@ -14083,9 +14130,13 @@ function walk(node, context, doNotHoistNode = false) {
14083
14130
  context.transformHoist(children, context, node);
14084
14131
  }
14085
14132
  if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
14086
- node.codegenNode.children = context.hoist(
14133
+ const hoisted = context.hoist(
14087
14134
  createArrayExpression(node.codegenNode.children)
14088
14135
  );
14136
+ if (context.hmr) {
14137
+ hoisted.content = `[...${hoisted.content}]`;
14138
+ }
14139
+ node.codegenNode.children = hoisted;
14089
14140
  }
14090
14141
  }
14091
14142
  function getConstantType(node, context) {
@@ -14258,6 +14309,7 @@ function createTransformContext(root, {
14258
14309
  filename = "",
14259
14310
  prefixIdentifiers = false,
14260
14311
  hoistStatic: hoistStatic2 = false,
14312
+ hmr = false,
14261
14313
  cacheHandlers = false,
14262
14314
  nodeTransforms = [],
14263
14315
  directiveTransforms = {},
@@ -14283,6 +14335,7 @@ function createTransformContext(root, {
14283
14335
  selfName: nameMatch && capitalize(camelize(nameMatch[1])),
14284
14336
  prefixIdentifiers,
14285
14337
  hoistStatic: hoistStatic2,
14338
+ hmr,
14286
14339
  cacheHandlers,
14287
14340
  nodeTransforms,
14288
14341
  directiveTransforms,
@@ -15666,7 +15719,7 @@ const trackSlotScopes = (node, context) => {
15666
15719
  }
15667
15720
  }
15668
15721
  };
15669
- const buildClientSlotFn = (props, children, loc) => createFunctionExpression(
15722
+ const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
15670
15723
  props,
15671
15724
  children,
15672
15725
  false,
@@ -15688,7 +15741,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15688
15741
  slotsProperties.push(
15689
15742
  createObjectProperty(
15690
15743
  arg || createSimpleExpression("default", true),
15691
- buildSlotFn(exp, children, loc)
15744
+ buildSlotFn(exp, void 0, children, loc)
15692
15745
  )
15693
15746
  );
15694
15747
  }
@@ -15725,10 +15778,15 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15725
15778
  } else {
15726
15779
  hasDynamicSlots = true;
15727
15780
  }
15728
- const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
15781
+ const vFor = findDir(slotElement, "for");
15782
+ const slotFunction = buildSlotFn(
15783
+ slotProps,
15784
+ vFor == null ? void 0 : vFor.exp,
15785
+ slotChildren,
15786
+ slotLoc
15787
+ );
15729
15788
  let vIf;
15730
15789
  let vElse;
15731
- let vFor;
15732
15790
  if (vIf = findDir(slotElement, "if")) {
15733
15791
  hasDynamicSlots = true;
15734
15792
  dynamicSlots.push(
@@ -15773,7 +15831,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15773
15831
  createCompilerError(30, vElse.loc)
15774
15832
  );
15775
15833
  }
15776
- } else if (vFor = findDir(slotElement, "for")) {
15834
+ } else if (vFor) {
15777
15835
  hasDynamicSlots = true;
15778
15836
  const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
15779
15837
  if (parseResult) {
@@ -15814,7 +15872,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15814
15872
  }
15815
15873
  if (!onComponentSlot) {
15816
15874
  const buildDefaultSlotProperty = (props, children2) => {
15817
- const fn = buildSlotFn(props, children2, loc);
15875
+ const fn = buildSlotFn(props, void 0, children2, loc);
15818
15876
  if (context.compatConfig) {
15819
15877
  fn.isNonScopedSlot = true;
15820
15878
  }