vue 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
  }
@@ -2504,6 +2509,61 @@ function updateHOCHostEl({ vnode, parent }, el) {
2504
2509
  }
2505
2510
  }
2506
2511
 
2512
+ const COMPONENTS = "components";
2513
+ const DIRECTIVES = "directives";
2514
+ function resolveComponent(name, maybeSelfReference) {
2515
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2516
+ }
2517
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2518
+ function resolveDynamicComponent(component) {
2519
+ if (isString(component)) {
2520
+ return resolveAsset(COMPONENTS, component, false) || component;
2521
+ } else {
2522
+ return component || NULL_DYNAMIC_COMPONENT;
2523
+ }
2524
+ }
2525
+ function resolveDirective(name) {
2526
+ return resolveAsset(DIRECTIVES, name);
2527
+ }
2528
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2529
+ const instance = currentRenderingInstance || currentInstance;
2530
+ if (instance) {
2531
+ const Component = instance.type;
2532
+ if (type === COMPONENTS) {
2533
+ const selfName = getComponentName(
2534
+ Component,
2535
+ false
2536
+ /* do not include inferred name to avoid breaking existing code */
2537
+ );
2538
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
2539
+ return Component;
2540
+ }
2541
+ }
2542
+ const res = (
2543
+ // local registration
2544
+ // check instance[type] first which is resolved for options API
2545
+ resolve(instance[type] || Component[type], name) || // global registration
2546
+ resolve(instance.appContext[type], name)
2547
+ );
2548
+ if (!res && maybeSelfReference) {
2549
+ return Component;
2550
+ }
2551
+ if (warnMissing && !res) {
2552
+ const extra = type === COMPONENTS ? `
2553
+ If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
2554
+ warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
2555
+ }
2556
+ return res;
2557
+ } else {
2558
+ warn(
2559
+ `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
2560
+ );
2561
+ }
2562
+ }
2563
+ function resolve(registry, name) {
2564
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
2565
+ }
2566
+
2507
2567
  const isSuspense = (type) => type.__isSuspense;
2508
2568
  const SuspenseImpl = {
2509
2569
  name: "Suspense",
@@ -2817,14 +2877,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2817
2877
  parentComponent: parentComponent2,
2818
2878
  container: container2
2819
2879
  } = suspense;
2880
+ let delayEnter = false;
2820
2881
  if (suspense.isHydrating) {
2821
2882
  suspense.isHydrating = false;
2822
2883
  } else if (!resume) {
2823
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
2884
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
2824
2885
  if (delayEnter) {
2825
2886
  activeBranch.transition.afterLeave = () => {
2826
2887
  if (pendingId === suspense.pendingId) {
2827
2888
  move(pendingBranch, container2, anchor2, 0);
2889
+ queuePostFlushCb(effects);
2828
2890
  }
2829
2891
  };
2830
2892
  }
@@ -2850,7 +2912,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2850
2912
  }
2851
2913
  parent = parent.parent;
2852
2914
  }
2853
- if (!hasUnresolvedAncestor) {
2915
+ if (!hasUnresolvedAncestor && !delayEnter) {
2854
2916
  queuePostFlushCb(effects);
2855
2917
  }
2856
2918
  suspense.effects = [];
@@ -3036,7 +3098,7 @@ function normalizeSuspenseSlot(s) {
3036
3098
  }
3037
3099
  if (isArray(s)) {
3038
3100
  const singleChild = filterSingleRoot(s);
3039
- if (!singleChild) {
3101
+ if (!singleChild && s.filter((child) => child !== NULL_DYNAMIC_COMPONENT).length > 0) {
3040
3102
  warn(`<Suspense> slots expect a single root node.`);
3041
3103
  }
3042
3104
  s = singleChild;
@@ -4121,61 +4183,6 @@ function onErrorCaptured(hook, target = currentInstance) {
4121
4183
  injectHook("ec", hook, target);
4122
4184
  }
4123
4185
 
4124
- const COMPONENTS = "components";
4125
- const DIRECTIVES = "directives";
4126
- function resolveComponent(name, maybeSelfReference) {
4127
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
4128
- }
4129
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
4130
- function resolveDynamicComponent(component) {
4131
- if (isString(component)) {
4132
- return resolveAsset(COMPONENTS, component, false) || component;
4133
- } else {
4134
- return component || NULL_DYNAMIC_COMPONENT;
4135
- }
4136
- }
4137
- function resolveDirective(name) {
4138
- return resolveAsset(DIRECTIVES, name);
4139
- }
4140
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
4141
- const instance = currentRenderingInstance || currentInstance;
4142
- if (instance) {
4143
- const Component = instance.type;
4144
- if (type === COMPONENTS) {
4145
- const selfName = getComponentName(
4146
- Component,
4147
- false
4148
- /* do not include inferred name to avoid breaking existing code */
4149
- );
4150
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
4151
- return Component;
4152
- }
4153
- }
4154
- const res = (
4155
- // local registration
4156
- // check instance[type] first which is resolved for options API
4157
- resolve(instance[type] || Component[type], name) || // global registration
4158
- resolve(instance.appContext[type], name)
4159
- );
4160
- if (!res && maybeSelfReference) {
4161
- return Component;
4162
- }
4163
- if (warnMissing && !res) {
4164
- const extra = type === COMPONENTS ? `
4165
- If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.` : ``;
4166
- warn(`Failed to resolve ${type.slice(0, -1)}: ${name}${extra}`);
4167
- }
4168
- return res;
4169
- } else {
4170
- warn(
4171
- `resolve${capitalize(type.slice(0, -1))} can only be used in render() or setup().`
4172
- );
4173
- }
4174
- }
4175
- function resolve(registry, name) {
4176
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
4177
- }
4178
-
4179
4186
  function renderList(source, renderItem, cache, index) {
4180
4187
  let ret;
4181
4188
  const cached = cache && cache[index];
@@ -5991,7 +5998,14 @@ function createHydrationFunctions(rendererInternals) {
5991
5998
  }
5992
5999
  break;
5993
6000
  case Comment:
5994
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
6001
+ if (isTemplateNode(node)) {
6002
+ nextNode = nextSibling(node);
6003
+ replaceNode(
6004
+ vnode.el = node.content.firstChild,
6005
+ node,
6006
+ parentComponent
6007
+ );
6008
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
5995
6009
  nextNode = onMismatch();
5996
6010
  } else {
5997
6011
  nextNode = nextSibling(node);
@@ -6034,7 +6048,7 @@ function createHydrationFunctions(rendererInternals) {
6034
6048
  break;
6035
6049
  default:
6036
6050
  if (shapeFlag & 1) {
6037
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
6051
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
6038
6052
  nextNode = onMismatch();
6039
6053
  } else {
6040
6054
  nextNode = hydrateElement(
@@ -6049,6 +6063,13 @@ function createHydrationFunctions(rendererInternals) {
6049
6063
  } else if (shapeFlag & 6) {
6050
6064
  vnode.slotScopeIds = slotScopeIds;
6051
6065
  const container = parentNode(node);
6066
+ if (isFragmentStart) {
6067
+ nextNode = locateClosingAnchor(node);
6068
+ } else if (isComment(node) && node.data === "teleport start") {
6069
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
6070
+ } else {
6071
+ nextNode = nextSibling(node);
6072
+ }
6052
6073
  mountComponent(
6053
6074
  vnode,
6054
6075
  container,
@@ -6058,10 +6079,6 @@ function createHydrationFunctions(rendererInternals) {
6058
6079
  isSVGContainer(container),
6059
6080
  optimized
6060
6081
  );
6061
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
6062
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
6063
- nextNode = nextSibling(nextNode);
6064
- }
6065
6082
  if (isAsyncWrapper(vnode)) {
6066
6083
  let subTree;
6067
6084
  if (isFragmentStart) {
@@ -6111,7 +6128,7 @@ function createHydrationFunctions(rendererInternals) {
6111
6128
  };
6112
6129
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
6113
6130
  optimized = optimized || !!vnode.dynamicChildren;
6114
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
6131
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
6115
6132
  const forcePatchValue = type === "input" && dirs || type === "option";
6116
6133
  {
6117
6134
  if (dirs) {
@@ -6148,12 +6165,23 @@ function createHydrationFunctions(rendererInternals) {
6148
6165
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
6149
6166
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
6150
6167
  }
6168
+ let needCallTransitionHooks = false;
6169
+ if (isTemplateNode(el)) {
6170
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
6171
+ const content = el.content.firstChild;
6172
+ if (needCallTransitionHooks) {
6173
+ transition.beforeEnter(content);
6174
+ }
6175
+ replaceNode(content, el, parentComponent);
6176
+ vnode.el = el = content;
6177
+ }
6151
6178
  if (dirs) {
6152
6179
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
6153
6180
  }
6154
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
6181
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
6155
6182
  queueEffectWithSuspense(() => {
6156
6183
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
6184
+ needCallTransitionHooks && transition.enter(el);
6157
6185
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
6158
6186
  }, parentSuspense);
6159
6187
  }
@@ -6271,7 +6299,7 @@ function createHydrationFunctions(rendererInternals) {
6271
6299
  );
6272
6300
  vnode.el = null;
6273
6301
  if (isFragment) {
6274
- const end = locateClosingAsyncAnchor(node);
6302
+ const end = locateClosingAnchor(node);
6275
6303
  while (true) {
6276
6304
  const next2 = nextSibling(node);
6277
6305
  if (next2 && next2 !== end) {
@@ -6296,14 +6324,14 @@ function createHydrationFunctions(rendererInternals) {
6296
6324
  );
6297
6325
  return next;
6298
6326
  };
6299
- const locateClosingAsyncAnchor = (node) => {
6327
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
6300
6328
  let match = 0;
6301
6329
  while (node) {
6302
6330
  node = nextSibling(node);
6303
6331
  if (node && isComment(node)) {
6304
- if (node.data === "[")
6332
+ if (node.data === open)
6305
6333
  match++;
6306
- if (node.data === "]") {
6334
+ if (node.data === close) {
6307
6335
  if (match === 0) {
6308
6336
  return nextSibling(node);
6309
6337
  } else {
@@ -6314,6 +6342,22 @@ function createHydrationFunctions(rendererInternals) {
6314
6342
  }
6315
6343
  return node;
6316
6344
  };
6345
+ const replaceNode = (newNode, oldNode, parentComponent) => {
6346
+ const parentNode2 = oldNode.parentNode;
6347
+ if (parentNode2) {
6348
+ parentNode2.replaceChild(newNode, oldNode);
6349
+ }
6350
+ let parent = parentComponent;
6351
+ while (parent) {
6352
+ if (parent.vnode.el === oldNode) {
6353
+ parent.vnode.el = parent.subTree.el = newNode;
6354
+ }
6355
+ parent = parent.parent;
6356
+ }
6357
+ };
6358
+ const isTemplateNode = (node) => {
6359
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
6360
+ };
6317
6361
  return [hydrate, hydrateNode];
6318
6362
  }
6319
6363
 
@@ -6641,7 +6685,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6641
6685
  if (dirs) {
6642
6686
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
6643
6687
  }
6644
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
6688
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
6645
6689
  if (needCallTransitionHooks) {
6646
6690
  transition.beforeEnter(el);
6647
6691
  }
@@ -7533,8 +7577,8 @@ function baseCreateRenderer(options, createHydrationFns) {
7533
7577
  moveStaticNode(vnode, container, anchor);
7534
7578
  return;
7535
7579
  }
7536
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
7537
- if (needTransition) {
7580
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
7581
+ if (needTransition2) {
7538
7582
  if (moveType === 0) {
7539
7583
  transition.beforeEnter(el);
7540
7584
  hostInsert(el, container, anchor);
@@ -7754,6 +7798,9 @@ function baseCreateRenderer(options, createHydrationFns) {
7754
7798
  function toggleRecurse({ effect, update }, allowed) {
7755
7799
  effect.allowRecurse = update.allowRecurse = allowed;
7756
7800
  }
7801
+ function needTransition(parentSuspense, transition) {
7802
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
7803
+ }
7757
7804
  function traverseStaticChildren(n1, n2, shallow = false) {
7758
7805
  const ch1 = n1.children;
7759
7806
  const ch2 = n2.children;
@@ -9089,7 +9136,7 @@ function isMemoSame(cached, memo) {
9089
9136
  return true;
9090
9137
  }
9091
9138
 
9092
- const version = "3.3.6";
9139
+ const version = "3.3.8";
9093
9140
  const ssrUtils = null;
9094
9141
  const resolveFilter = null;
9095
9142
  const compatUtils = null;
@@ -12072,9 +12119,13 @@ function walk(node, context, doNotHoistNode = false) {
12072
12119
  context.transformHoist(children, context, node);
12073
12120
  }
12074
12121
  if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
12075
- node.codegenNode.children = context.hoist(
12122
+ const hoisted = context.hoist(
12076
12123
  createArrayExpression(node.codegenNode.children)
12077
12124
  );
12125
+ if (context.hmr) {
12126
+ hoisted.content = `[...${hoisted.content}]`;
12127
+ }
12128
+ node.codegenNode.children = hoisted;
12078
12129
  }
12079
12130
  }
12080
12131
  function getConstantType(node, context) {
@@ -12247,6 +12298,7 @@ function createTransformContext(root, {
12247
12298
  filename = "",
12248
12299
  prefixIdentifiers = false,
12249
12300
  hoistStatic: hoistStatic2 = false,
12301
+ hmr = false,
12250
12302
  cacheHandlers = false,
12251
12303
  nodeTransforms = [],
12252
12304
  directiveTransforms = {},
@@ -12272,6 +12324,7 @@ function createTransformContext(root, {
12272
12324
  selfName: nameMatch && capitalize(camelize(nameMatch[1])),
12273
12325
  prefixIdentifiers,
12274
12326
  hoistStatic: hoistStatic2,
12327
+ hmr,
12275
12328
  cacheHandlers,
12276
12329
  nodeTransforms,
12277
12330
  directiveTransforms,
@@ -13641,7 +13694,7 @@ const trackSlotScopes = (node, context) => {
13641
13694
  }
13642
13695
  }
13643
13696
  };
13644
- const buildClientSlotFn = (props, children, loc) => createFunctionExpression(
13697
+ const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
13645
13698
  props,
13646
13699
  children,
13647
13700
  false,
@@ -13663,7 +13716,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
13663
13716
  slotsProperties.push(
13664
13717
  createObjectProperty(
13665
13718
  arg || createSimpleExpression("default", true),
13666
- buildSlotFn(exp, children, loc)
13719
+ buildSlotFn(exp, void 0, children, loc)
13667
13720
  )
13668
13721
  );
13669
13722
  }
@@ -13700,10 +13753,15 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
13700
13753
  } else {
13701
13754
  hasDynamicSlots = true;
13702
13755
  }
13703
- const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
13756
+ const vFor = findDir(slotElement, "for");
13757
+ const slotFunction = buildSlotFn(
13758
+ slotProps,
13759
+ vFor == null ? void 0 : vFor.exp,
13760
+ slotChildren,
13761
+ slotLoc
13762
+ );
13704
13763
  let vIf;
13705
13764
  let vElse;
13706
- let vFor;
13707
13765
  if (vIf = findDir(slotElement, "if")) {
13708
13766
  hasDynamicSlots = true;
13709
13767
  dynamicSlots.push(
@@ -13748,7 +13806,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
13748
13806
  createCompilerError(30, vElse.loc)
13749
13807
  );
13750
13808
  }
13751
- } else if (vFor = findDir(slotElement, "for")) {
13809
+ } else if (vFor) {
13752
13810
  hasDynamicSlots = true;
13753
13811
  const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
13754
13812
  if (parseResult) {
@@ -13789,7 +13847,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
13789
13847
  }
13790
13848
  if (!onComponentSlot) {
13791
13849
  const buildDefaultSlotProperty = (props, children2) => {
13792
- const fn = buildSlotFn(props, children2, loc);
13850
+ const fn = buildSlotFn(props, void 0, children2, loc);
13793
13851
  return createObjectProperty(`default`, fn);
13794
13852
  };
13795
13853
  if (!hasTemplateSlots) {