@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
  });
@@ -1715,8 +1715,13 @@ function findInsertionIndex(id) {
1715
1715
  let end = queue.length;
1716
1716
  while (start < end) {
1717
1717
  const middle = start + end >>> 1;
1718
- const middleJobId = getId(queue[middle]);
1719
- middleJobId < id ? start = middle + 1 : end = middle;
1718
+ const middleJob = queue[middle];
1719
+ const middleJobId = getId(middleJob);
1720
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
1721
+ start = middle + 1;
1722
+ } else {
1723
+ end = middle;
1724
+ }
1720
1725
  }
1721
1726
  return start;
1722
1727
  }
@@ -2994,6 +2999,65 @@ function updateHOCHostEl({ vnode, parent }, el) {
2994
2999
  }
2995
3000
  }
2996
3001
 
3002
+ const COMPONENTS = "components";
3003
+ const DIRECTIVES = "directives";
3004
+ const FILTERS = "filters";
3005
+ function resolveComponent(name, maybeSelfReference) {
3006
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
3007
+ }
3008
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
3009
+ function resolveDynamicComponent(component) {
3010
+ if (isString(component)) {
3011
+ return resolveAsset(COMPONENTS, component, false) || component;
3012
+ } else {
3013
+ return component || NULL_DYNAMIC_COMPONENT;
3014
+ }
3015
+ }
3016
+ function resolveDirective(name) {
3017
+ return resolveAsset(DIRECTIVES, name);
3018
+ }
3019
+ function resolveFilter$1(name) {
3020
+ return resolveAsset(FILTERS, name);
3021
+ }
3022
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
3023
+ const instance = currentRenderingInstance || currentInstance;
3024
+ if (instance) {
3025
+ const Component = instance.type;
3026
+ if (type === COMPONENTS) {
3027
+ const selfName = getComponentName(
3028
+ Component,
3029
+ false
3030
+ /* do not include inferred name to avoid breaking existing code */
3031
+ );
3032
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
3033
+ return Component;
3034
+ }
3035
+ }
3036
+ const res = (
3037
+ // local registration
3038
+ // check instance[type] first which is resolved for options API
3039
+ resolve(instance[type] || Component[type], name) || // global registration
3040
+ resolve(instance.appContext[type], name)
3041
+ );
3042
+ if (!res && maybeSelfReference) {
3043
+ return Component;
3044
+ }
3045
+ if (!!(process.env.NODE_ENV !== "production") && warnMissing && !res) {
3046
+ const extra = type === COMPONENTS ? `
3047
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
3048
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
3049
+ }
3050
+ return res;
3051
+ } else if (!!(process.env.NODE_ENV !== "production")) {
3052
+ warn(
3053
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
3054
+ );
3055
+ }
3056
+ }
3057
+ function resolve(registry, name) {
3058
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3059
+ }
3060
+
2997
3061
  const isSuspense = (type) => type.__isSuspense;
2998
3062
  const SuspenseImpl = {
2999
3063
  name: "Suspense",
@@ -3307,14 +3371,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3307
3371
  parentComponent: parentComponent2,
3308
3372
  container: container2
3309
3373
  } = suspense;
3374
+ let delayEnter = false;
3310
3375
  if (suspense.isHydrating) {
3311
3376
  suspense.isHydrating = false;
3312
3377
  } else if (!resume) {
3313
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3378
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
3314
3379
  if (delayEnter) {
3315
3380
  activeBranch.transition.afterLeave = () => {
3316
3381
  if (pendingId === suspense.pendingId) {
3317
3382
  move(pendingBranch, container2, anchor2, 0);
3383
+ queuePostFlushCb(effects);
3318
3384
  }
3319
3385
  };
3320
3386
  }
@@ -3340,7 +3406,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
3340
3406
  }
3341
3407
  parent = parent.parent;
3342
3408
  }
3343
- if (!hasUnresolvedAncestor) {
3409
+ if (!hasUnresolvedAncestor && !delayEnter) {
3344
3410
  queuePostFlushCb(effects);
3345
3411
  }
3346
3412
  suspense.effects = [];
@@ -3526,7 +3592,7 @@ function normalizeSuspenseSlot(s) {
3526
3592
  }
3527
3593
  if (isArray(s)) {
3528
3594
  const singleChild = filterSingleRoot(s);
3529
- if (!!(process.env.NODE_ENV !== "production") && !singleChild) {
3595
+ if (!!(process.env.NODE_ENV !== "production") && !singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3530
3596
  warn(`<Suspense> slots expect a single root node.`);
3531
3597
  }
3532
3598
  s = singleChild;
@@ -4732,65 +4798,6 @@ function getCompatListeners(instance) {
4732
4798
  return listeners;
4733
4799
  }
4734
4800
 
4735
- const COMPONENTS = "components";
4736
- const DIRECTIVES = "directives";
4737
- const FILTERS = "filters";
4738
- function resolveComponent(name, maybeSelfReference) {
4739
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4740
- }
4741
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4742
- function resolveDynamicComponent(component) {
4743
- if (isString(component)) {
4744
- return resolveAsset(COMPONENTS, component, false) || component;
4745
- } else {
4746
- return component || NULL_DYNAMIC_COMPONENT;
4747
- }
4748
- }
4749
- function resolveDirective(name) {
4750
- return resolveAsset(DIRECTIVES, name);
4751
- }
4752
- function resolveFilter$1(name) {
4753
- return resolveAsset(FILTERS, name);
4754
- }
4755
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4756
- const instance = currentRenderingInstance || currentInstance;
4757
- if (instance) {
4758
- const Component = instance.type;
4759
- if (type === COMPONENTS) {
4760
- const selfName = getComponentName(
4761
- Component,
4762
- false
4763
- /* do not include inferred name to avoid breaking existing code */
4764
- );
4765
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4766
- return Component;
4767
- }
4768
- }
4769
- const res = (
4770
- // local registration
4771
- // check instance[type] first which is resolved for options API
4772
- resolve(instance[type] || Component[type], name) || // global registration
4773
- resolve(instance.appContext[type], name)
4774
- );
4775
- if (!res && maybeSelfReference) {
4776
- return Component;
4777
- }
4778
- if (!!(process.env.NODE_ENV !== "production") && warnMissing && !res) {
4779
- const extra = type === COMPONENTS ? `
4780
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4781
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4782
- }
4783
- return res;
4784
- } else if (!!(process.env.NODE_ENV !== "production")) {
4785
- warn(
4786
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4787
- );
4788
- }
4789
- }
4790
- function resolve(registry, name) {
4791
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4792
- }
4793
-
4794
4801
  function convertLegacyRenderFn(instance) {
4795
4802
  const Component2 = instance.type;
4796
4803
  const render = Component2.render;
@@ -6295,7 +6302,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
6295
6302
  return vm;
6296
6303
  }
6297
6304
  }
6298
- Vue.version = `2.6.14-compat:${"3.3.6"}`;
6305
+ Vue.version = `2.6.14-compat:${"3.3.8"}`;
6299
6306
  Vue.config = singletonApp.config;
6300
6307
  Vue.use = (p, ...options) => {
6301
6308
  if (p && isFunction(p.install)) {
@@ -7627,7 +7634,14 @@ function createHydrationFunctions(rendererInternals) {
7627
7634
  }
7628
7635
  break;
7629
7636
  case Comment:
7630
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7637
+ if (isTemplateNode(node)) {
7638
+ nextNode = nextSibling(node);
7639
+ replaceNode(
7640
+ vnode.el = node.content.firstChild,
7641
+ node,
7642
+ parentComponent
7643
+ );
7644
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
7631
7645
  nextNode = onMismatch();
7632
7646
  } else {
7633
7647
  nextNode = nextSibling(node);
@@ -7670,7 +7684,7 @@ function createHydrationFunctions(rendererInternals) {
7670
7684
  break;
7671
7685
  default:
7672
7686
  if (shapeFlag & 1) {
7673
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
7687
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
7674
7688
  nextNode = onMismatch();
7675
7689
  } else {
7676
7690
  nextNode = hydrateElement(
@@ -7685,6 +7699,13 @@ function createHydrationFunctions(rendererInternals) {
7685
7699
  } else if (shapeFlag & 6) {
7686
7700
  vnode.slotScopeIds = slotScopeIds;
7687
7701
  const container = parentNode(node);
7702
+ if (isFragmentStart) {
7703
+ nextNode = locateClosingAnchor(node);
7704
+ } else if (isComment(node) && node.data === "teleport start") {
7705
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
7706
+ } else {
7707
+ nextNode = nextSibling(node);
7708
+ }
7688
7709
  mountComponent(
7689
7710
  vnode,
7690
7711
  container,
@@ -7694,10 +7715,6 @@ function createHydrationFunctions(rendererInternals) {
7694
7715
  isSVGContainer(container),
7695
7716
  optimized
7696
7717
  );
7697
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
7698
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
7699
- nextNode = nextSibling(nextNode);
7700
- }
7701
7718
  if (isAsyncWrapper(vnode)) {
7702
7719
  let subTree;
7703
7720
  if (isFragmentStart) {
@@ -7747,7 +7764,7 @@ function createHydrationFunctions(rendererInternals) {
7747
7764
  };
7748
7765
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
7749
7766
  optimized = optimized || !!vnode.dynamicChildren;
7750
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
7767
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
7751
7768
  const forcePatchValue = type === "input" && dirs || type === "option";
7752
7769
  if (!!(process.env.NODE_ENV !== "production") || forcePatchValue || patchFlag !== -1) {
7753
7770
  if (dirs) {
@@ -7784,12 +7801,23 @@ function createHydrationFunctions(rendererInternals) {
7784
7801
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
7785
7802
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7786
7803
  }
7804
+ let needCallTransitionHooks = false;
7805
+ if (isTemplateNode(el)) {
7806
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
7807
+ const content = el.content.firstChild;
7808
+ if (needCallTransitionHooks) {
7809
+ transition.beforeEnter(content);
7810
+ }
7811
+ replaceNode(content, el, parentComponent);
7812
+ vnode.el = el = content;
7813
+ }
7787
7814
  if (dirs) {
7788
7815
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
7789
7816
  }
7790
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
7817
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
7791
7818
  queueEffectWithSuspense(() => {
7792
7819
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
7820
+ needCallTransitionHooks && transition.enter(el);
7793
7821
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
7794
7822
  }, parentSuspense);
7795
7823
  }
@@ -7907,7 +7935,7 @@ function createHydrationFunctions(rendererInternals) {
7907
7935
  );
7908
7936
  vnode.el = null;
7909
7937
  if (isFragment) {
7910
- const end = locateClosingAsyncAnchor(node);
7938
+ const end = locateClosingAnchor(node);
7911
7939
  while (true) {
7912
7940
  const next2 = nextSibling(node);
7913
7941
  if (next2 && next2 !== end) {
@@ -7932,14 +7960,14 @@ function createHydrationFunctions(rendererInternals) {
7932
7960
  );
7933
7961
  return next;
7934
7962
  };
7935
- const locateClosingAsyncAnchor = (node) => {
7963
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
7936
7964
  let match = 0;
7937
7965
  while (node) {
7938
7966
  node = nextSibling(node);
7939
7967
  if (node && isComment(node)) {
7940
- if (node.data === "[")
7968
+ if (node.data === open)
7941
7969
  match++;
7942
- if (node.data === "]") {
7970
+ if (node.data === close) {
7943
7971
  if (match === 0) {
7944
7972
  return nextSibling(node);
7945
7973
  } else {
@@ -7950,6 +7978,22 @@ function createHydrationFunctions(rendererInternals) {
7950
7978
  }
7951
7979
  return node;
7952
7980
  };
7981
+ const replaceNode = (newNode, oldNode, parentComponent) => {
7982
+ const parentNode2 = oldNode.parentNode;
7983
+ if (parentNode2) {
7984
+ parentNode2.replaceChild(newNode, oldNode);
7985
+ }
7986
+ let parent = parentComponent;
7987
+ while (parent) {
7988
+ if (parent.vnode.el === oldNode) {
7989
+ parent.vnode.el = parent.subTree.el = newNode;
7990
+ }
7991
+ parent = parent.parent;
7992
+ }
7993
+ };
7994
+ const isTemplateNode = (node) => {
7995
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
7996
+ };
7953
7997
  return [hydrate, hydrateNode];
7954
7998
  }
7955
7999
 
@@ -8300,7 +8344,7 @@ function baseCreateRenderer(options, createHydrationFns) {
8300
8344
  if (dirs) {
8301
8345
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
8302
8346
  }
8303
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
8347
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
8304
8348
  if (needCallTransitionHooks) {
8305
8349
  transition.beforeEnter(el);
8306
8350
  }
@@ -9228,8 +9272,8 @@ function baseCreateRenderer(options, createHydrationFns) {
9228
9272
  moveStaticNode(vnode, container, anchor);
9229
9273
  return;
9230
9274
  }
9231
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
9232
- if (needTransition) {
9275
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
9276
+ if (needTransition2) {
9233
9277
  if (moveType === 0) {
9234
9278
  transition.beforeEnter(el);
9235
9279
  hostInsert(el, container, anchor);
@@ -9458,6 +9502,9 @@ function baseCreateRenderer(options, createHydrationFns) {
9458
9502
  function toggleRecurse({ effect, update }, allowed) {
9459
9503
  effect.allowRecurse = update.allowRecurse = allowed;
9460
9504
  }
9505
+ function needTransition(parentSuspense, transition) {
9506
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
9507
+ }
9461
9508
  function traverseStaticChildren(n1, n2, shallow = false) {
9462
9509
  const ch1 = n1.children;
9463
9510
  const ch2 = n2.children;
@@ -10894,7 +10941,7 @@ function isMemoSame(cached, memo) {
10894
10941
  return true;
10895
10942
  }
10896
10943
 
10897
- const version = "3.3.6";
10944
+ const version = "3.3.8";
10898
10945
  const _ssrUtils = {
10899
10946
  createComponentInstance,
10900
10947
  setupComponent,
@@ -14246,9 +14293,13 @@ function walk(node, context, doNotHoistNode = false) {
14246
14293
  context.transformHoist(children, context, node);
14247
14294
  }
14248
14295
  if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
14249
- node.codegenNode.children = context.hoist(
14296
+ const hoisted = context.hoist(
14250
14297
  createArrayExpression(node.codegenNode.children)
14251
14298
  );
14299
+ if (context.hmr) {
14300
+ hoisted.content = `[...${hoisted.content}]`;
14301
+ }
14302
+ node.codegenNode.children = hoisted;
14252
14303
  }
14253
14304
  }
14254
14305
  function getConstantType(node, context) {
@@ -14422,6 +14473,7 @@ function createTransformContext(root, {
14422
14473
  filename = "",
14423
14474
  prefixIdentifiers = false,
14424
14475
  hoistStatic: hoistStatic2 = false,
14476
+ hmr = false,
14425
14477
  cacheHandlers = false,
14426
14478
  nodeTransforms = [],
14427
14479
  directiveTransforms = {},
@@ -14447,6 +14499,7 @@ function createTransformContext(root, {
14447
14499
  selfName: nameMatch && capitalize(camelize(nameMatch[1])),
14448
14500
  prefixIdentifiers,
14449
14501
  hoistStatic: hoistStatic2,
14502
+ hmr,
14450
14503
  cacheHandlers,
14451
14504
  nodeTransforms,
14452
14505
  directiveTransforms,
@@ -15830,7 +15883,7 @@ const trackSlotScopes = (node, context) => {
15830
15883
  }
15831
15884
  }
15832
15885
  };
15833
- const buildClientSlotFn = (props, children, loc) => createFunctionExpression(
15886
+ const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
15834
15887
  props,
15835
15888
  children,
15836
15889
  false,
@@ -15852,7 +15905,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15852
15905
  slotsProperties.push(
15853
15906
  createObjectProperty(
15854
15907
  arg || createSimpleExpression("default", true),
15855
- buildSlotFn(exp, children, loc)
15908
+ buildSlotFn(exp, void 0, children, loc)
15856
15909
  )
15857
15910
  );
15858
15911
  }
@@ -15889,10 +15942,15 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15889
15942
  } else {
15890
15943
  hasDynamicSlots = true;
15891
15944
  }
15892
- const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
15945
+ const vFor = findDir(slotElement, "for");
15946
+ const slotFunction = buildSlotFn(
15947
+ slotProps,
15948
+ vFor == null ? void 0 : vFor.exp,
15949
+ slotChildren,
15950
+ slotLoc
15951
+ );
15893
15952
  let vIf;
15894
15953
  let vElse;
15895
- let vFor;
15896
15954
  if (vIf = findDir(slotElement, "if")) {
15897
15955
  hasDynamicSlots = true;
15898
15956
  dynamicSlots.push(
@@ -15937,7 +15995,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15937
15995
  createCompilerError(30, vElse.loc)
15938
15996
  );
15939
15997
  }
15940
- } else if (vFor = findDir(slotElement, "for")) {
15998
+ } else if (vFor) {
15941
15999
  hasDynamicSlots = true;
15942
16000
  const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
15943
16001
  if (parseResult) {
@@ -15978,7 +16036,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
15978
16036
  }
15979
16037
  if (!onComponentSlot) {
15980
16038
  const buildDefaultSlotProperty = (props, children2) => {
15981
- const fn = buildSlotFn(props, children2, loc);
16039
+ const fn = buildSlotFn(props, void 0, children2, loc);
15982
16040
  if (context.compatConfig) {
15983
16041
  fn.isNonScopedSlot = true;
15984
16042
  }