@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.
@@ -594,7 +594,7 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
594
594
  } else if (key === "length" && isArray(target)) {
595
595
  const newLength = Number(newValue);
596
596
  depsMap.forEach((dep, key2) => {
597
- if (key2 === "length" || key2 >= newLength) {
597
+ if (key2 === "length" || !isSymbol(key2) && key2 >= newLength) {
598
598
  deps.push(dep);
599
599
  }
600
600
  });
@@ -1481,8 +1481,13 @@ function findInsertionIndex(id) {
1481
1481
  let end = queue.length;
1482
1482
  while (start < end) {
1483
1483
  const middle = start + end >>> 1;
1484
- const middleJobId = getId(queue[middle]);
1485
- middleJobId < id ? start = middle + 1 : end = middle;
1484
+ const middleJob = queue[middle];
1485
+ const middleJobId = getId(middleJob);
1486
+ if (middleJobId < id || middleJobId === id && middleJob.pre) {
1487
+ start = middle + 1;
1488
+ } else {
1489
+ end = middle;
1490
+ }
1486
1491
  }
1487
1492
  return start;
1488
1493
  }
@@ -2144,6 +2149,56 @@ function updateHOCHostEl({ vnode, parent }, el) {
2144
2149
  }
2145
2150
  }
2146
2151
 
2152
+ const COMPONENTS = "components";
2153
+ const DIRECTIVES = "directives";
2154
+ const FILTERS = "filters";
2155
+ function resolveComponent(name, maybeSelfReference) {
2156
+ return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
2157
+ }
2158
+ const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
2159
+ function resolveDynamicComponent(component) {
2160
+ if (isString(component)) {
2161
+ return resolveAsset(COMPONENTS, component, false) || component;
2162
+ } else {
2163
+ return component || NULL_DYNAMIC_COMPONENT;
2164
+ }
2165
+ }
2166
+ function resolveDirective(name) {
2167
+ return resolveAsset(DIRECTIVES, name);
2168
+ }
2169
+ function resolveFilter$1(name) {
2170
+ return resolveAsset(FILTERS, name);
2171
+ }
2172
+ function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
2173
+ const instance = currentRenderingInstance || currentInstance;
2174
+ if (instance) {
2175
+ const Component = instance.type;
2176
+ if (type === COMPONENTS) {
2177
+ const selfName = getComponentName(
2178
+ Component,
2179
+ false
2180
+ /* do not include inferred name to avoid breaking existing code */
2181
+ );
2182
+ if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
2183
+ return Component;
2184
+ }
2185
+ }
2186
+ const res = (
2187
+ // local registration
2188
+ // check instance[type] first which is resolved for options API
2189
+ resolve(instance[type] || Component[type], name) || // global registration
2190
+ resolve(instance.appContext[type], name)
2191
+ );
2192
+ if (!res && maybeSelfReference) {
2193
+ return Component;
2194
+ }
2195
+ return res;
2196
+ }
2197
+ }
2198
+ function resolve(registry, name) {
2199
+ return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
2200
+ }
2201
+
2147
2202
  const isSuspense = (type) => type.__isSuspense;
2148
2203
  const SuspenseImpl = {
2149
2204
  name: "Suspense",
@@ -2435,14 +2490,16 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2435
2490
  parentComponent: parentComponent2,
2436
2491
  container: container2
2437
2492
  } = suspense;
2493
+ let delayEnter = false;
2438
2494
  if (suspense.isHydrating) {
2439
2495
  suspense.isHydrating = false;
2440
2496
  } else if (!resume) {
2441
- const delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
2497
+ delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
2442
2498
  if (delayEnter) {
2443
2499
  activeBranch.transition.afterLeave = () => {
2444
2500
  if (pendingId === suspense.pendingId) {
2445
2501
  move(pendingBranch, container2, anchor2, 0);
2502
+ queuePostFlushCb(effects);
2446
2503
  }
2447
2504
  };
2448
2505
  }
@@ -2468,7 +2525,7 @@ function createSuspenseBoundary(vnode, parentSuspense, parentComponent, containe
2468
2525
  }
2469
2526
  parent = parent.parent;
2470
2527
  }
2471
- if (!hasUnresolvedAncestor) {
2528
+ if (!hasUnresolvedAncestor && !delayEnter) {
2472
2529
  queuePostFlushCb(effects);
2473
2530
  }
2474
2531
  suspense.effects = [];
@@ -3777,56 +3834,6 @@ function getCompatListeners(instance) {
3777
3834
  return listeners;
3778
3835
  }
3779
3836
 
3780
- const COMPONENTS = "components";
3781
- const DIRECTIVES = "directives";
3782
- const FILTERS = "filters";
3783
- function resolveComponent(name, maybeSelfReference) {
3784
- return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
3785
- }
3786
- const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
3787
- function resolveDynamicComponent(component) {
3788
- if (isString(component)) {
3789
- return resolveAsset(COMPONENTS, component, false) || component;
3790
- } else {
3791
- return component || NULL_DYNAMIC_COMPONENT;
3792
- }
3793
- }
3794
- function resolveDirective(name) {
3795
- return resolveAsset(DIRECTIVES, name);
3796
- }
3797
- function resolveFilter$1(name) {
3798
- return resolveAsset(FILTERS, name);
3799
- }
3800
- function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
3801
- const instance = currentRenderingInstance || currentInstance;
3802
- if (instance) {
3803
- const Component = instance.type;
3804
- if (type === COMPONENTS) {
3805
- const selfName = getComponentName(
3806
- Component,
3807
- false
3808
- /* do not include inferred name to avoid breaking existing code */
3809
- );
3810
- if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
3811
- return Component;
3812
- }
3813
- }
3814
- const res = (
3815
- // local registration
3816
- // check instance[type] first which is resolved for options API
3817
- resolve(instance[type] || Component[type], name) || // global registration
3818
- resolve(instance.appContext[type], name)
3819
- );
3820
- if (!res && maybeSelfReference) {
3821
- return Component;
3822
- }
3823
- return res;
3824
- }
3825
- }
3826
- function resolve(registry, name) {
3827
- return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
3828
- }
3829
-
3830
3837
  function convertLegacyRenderFn(instance) {
3831
3838
  const Component2 = instance.type;
3832
3839
  const render = Component2.render;
@@ -5065,7 +5072,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
5065
5072
  return vm;
5066
5073
  }
5067
5074
  }
5068
- Vue.version = `2.6.14-compat:${"3.3.6"}`;
5075
+ Vue.version = `2.6.14-compat:${"3.3.8"}`;
5069
5076
  Vue.config = singletonApp.config;
5070
5077
  Vue.use = (p, ...options) => {
5071
5078
  if (p && isFunction(p.install)) {
@@ -6117,7 +6124,14 @@ function createHydrationFunctions(rendererInternals) {
6117
6124
  }
6118
6125
  break;
6119
6126
  case Comment:
6120
- if (domType !== 8 /* COMMENT */ || isFragmentStart) {
6127
+ if (isTemplateNode(node)) {
6128
+ nextNode = nextSibling(node);
6129
+ replaceNode(
6130
+ vnode.el = node.content.firstChild,
6131
+ node,
6132
+ parentComponent
6133
+ );
6134
+ } else if (domType !== 8 /* COMMENT */ || isFragmentStart) {
6121
6135
  nextNode = onMismatch();
6122
6136
  } else {
6123
6137
  nextNode = nextSibling(node);
@@ -6160,7 +6174,7 @@ function createHydrationFunctions(rendererInternals) {
6160
6174
  break;
6161
6175
  default:
6162
6176
  if (shapeFlag & 1) {
6163
- if (domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) {
6177
+ if ((domType !== 1 /* ELEMENT */ || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
6164
6178
  nextNode = onMismatch();
6165
6179
  } else {
6166
6180
  nextNode = hydrateElement(
@@ -6175,6 +6189,13 @@ function createHydrationFunctions(rendererInternals) {
6175
6189
  } else if (shapeFlag & 6) {
6176
6190
  vnode.slotScopeIds = slotScopeIds;
6177
6191
  const container = parentNode(node);
6192
+ if (isFragmentStart) {
6193
+ nextNode = locateClosingAnchor(node);
6194
+ } else if (isComment(node) && node.data === "teleport start") {
6195
+ nextNode = locateClosingAnchor(node, node.data, "teleport end");
6196
+ } else {
6197
+ nextNode = nextSibling(node);
6198
+ }
6178
6199
  mountComponent(
6179
6200
  vnode,
6180
6201
  container,
@@ -6184,10 +6205,6 @@ function createHydrationFunctions(rendererInternals) {
6184
6205
  isSVGContainer(container),
6185
6206
  optimized
6186
6207
  );
6187
- nextNode = isFragmentStart ? locateClosingAsyncAnchor(node) : nextSibling(node);
6188
- if (nextNode && isComment(nextNode) && nextNode.data === "teleport end") {
6189
- nextNode = nextSibling(nextNode);
6190
- }
6191
6208
  if (isAsyncWrapper(vnode)) {
6192
6209
  let subTree;
6193
6210
  if (isFragmentStart) {
@@ -6235,7 +6252,7 @@ function createHydrationFunctions(rendererInternals) {
6235
6252
  };
6236
6253
  const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
6237
6254
  optimized = optimized || !!vnode.dynamicChildren;
6238
- const { type, props, patchFlag, shapeFlag, dirs } = vnode;
6255
+ const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
6239
6256
  const forcePatchValue = type === "input" && dirs || type === "option";
6240
6257
  if (forcePatchValue || patchFlag !== -1) {
6241
6258
  if (dirs) {
@@ -6272,12 +6289,23 @@ function createHydrationFunctions(rendererInternals) {
6272
6289
  if (vnodeHooks = props && props.onVnodeBeforeMount) {
6273
6290
  invokeVNodeHook(vnodeHooks, parentComponent, vnode);
6274
6291
  }
6292
+ let needCallTransitionHooks = false;
6293
+ if (isTemplateNode(el)) {
6294
+ needCallTransitionHooks = needTransition(parentSuspense, transition) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
6295
+ const content = el.content.firstChild;
6296
+ if (needCallTransitionHooks) {
6297
+ transition.beforeEnter(content);
6298
+ }
6299
+ replaceNode(content, el, parentComponent);
6300
+ vnode.el = el = content;
6301
+ }
6275
6302
  if (dirs) {
6276
6303
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
6277
6304
  }
6278
- if ((vnodeHooks = props && props.onVnodeMounted) || dirs) {
6305
+ if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
6279
6306
  queueEffectWithSuspense(() => {
6280
6307
  vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
6308
+ needCallTransitionHooks && transition.enter(el);
6281
6309
  dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
6282
6310
  }, parentSuspense);
6283
6311
  }
@@ -6367,7 +6395,7 @@ function createHydrationFunctions(rendererInternals) {
6367
6395
  hasMismatch = true;
6368
6396
  vnode.el = null;
6369
6397
  if (isFragment) {
6370
- const end = locateClosingAsyncAnchor(node);
6398
+ const end = locateClosingAnchor(node);
6371
6399
  while (true) {
6372
6400
  const next2 = nextSibling(node);
6373
6401
  if (next2 && next2 !== end) {
@@ -6392,14 +6420,14 @@ function createHydrationFunctions(rendererInternals) {
6392
6420
  );
6393
6421
  return next;
6394
6422
  };
6395
- const locateClosingAsyncAnchor = (node) => {
6423
+ const locateClosingAnchor = (node, open = "[", close = "]") => {
6396
6424
  let match = 0;
6397
6425
  while (node) {
6398
6426
  node = nextSibling(node);
6399
6427
  if (node && isComment(node)) {
6400
- if (node.data === "[")
6428
+ if (node.data === open)
6401
6429
  match++;
6402
- if (node.data === "]") {
6430
+ if (node.data === close) {
6403
6431
  if (match === 0) {
6404
6432
  return nextSibling(node);
6405
6433
  } else {
@@ -6410,6 +6438,22 @@ function createHydrationFunctions(rendererInternals) {
6410
6438
  }
6411
6439
  return node;
6412
6440
  };
6441
+ const replaceNode = (newNode, oldNode, parentComponent) => {
6442
+ const parentNode2 = oldNode.parentNode;
6443
+ if (parentNode2) {
6444
+ parentNode2.replaceChild(newNode, oldNode);
6445
+ }
6446
+ let parent = parentComponent;
6447
+ while (parent) {
6448
+ if (parent.vnode.el === oldNode) {
6449
+ parent.vnode.el = parent.subTree.el = newNode;
6450
+ }
6451
+ parent = parent.parent;
6452
+ }
6453
+ };
6454
+ const isTemplateNode = (node) => {
6455
+ return node.nodeType === 1 /* ELEMENT */ && node.tagName.toLowerCase() === "template";
6456
+ };
6413
6457
  return [hydrate, hydrateNode];
6414
6458
  }
6415
6459
 
@@ -6665,7 +6709,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6665
6709
  if (dirs) {
6666
6710
  invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
6667
6711
  }
6668
- const needCallTransitionHooks = (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
6712
+ const needCallTransitionHooks = needTransition(parentSuspense, transition);
6669
6713
  if (needCallTransitionHooks) {
6670
6714
  transition.beforeEnter(el);
6671
6715
  }
@@ -7491,8 +7535,8 @@ function baseCreateRenderer(options, createHydrationFns) {
7491
7535
  moveStaticNode(vnode, container, anchor);
7492
7536
  return;
7493
7537
  }
7494
- const needTransition = moveType !== 2 && shapeFlag & 1 && transition;
7495
- if (needTransition) {
7538
+ const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
7539
+ if (needTransition2) {
7496
7540
  if (moveType === 0) {
7497
7541
  transition.beforeEnter(el);
7498
7542
  hostInsert(el, container, anchor);
@@ -7707,6 +7751,9 @@ function baseCreateRenderer(options, createHydrationFns) {
7707
7751
  function toggleRecurse({ effect, update }, allowed) {
7708
7752
  effect.allowRecurse = update.allowRecurse = allowed;
7709
7753
  }
7754
+ function needTransition(parentSuspense, transition) {
7755
+ return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
7756
+ }
7710
7757
  function traverseStaticChildren(n1, n2, shallow = false) {
7711
7758
  const ch1 = n1.children;
7712
7759
  const ch2 = n2.children;
@@ -8752,7 +8799,7 @@ function isMemoSame(cached, memo) {
8752
8799
  return true;
8753
8800
  }
8754
8801
 
8755
- const version = "3.3.6";
8802
+ const version = "3.3.8";
8756
8803
  const _ssrUtils = {
8757
8804
  createComponentInstance,
8758
8805
  setupComponent,
@@ -11811,9 +11858,13 @@ function walk(node, context, doNotHoistNode = false) {
11811
11858
  context.transformHoist(children, context, node);
11812
11859
  }
11813
11860
  if (hoistedCount && hoistedCount === originalCount && node.type === 1 && node.tagType === 0 && node.codegenNode && node.codegenNode.type === 13 && isArray(node.codegenNode.children)) {
11814
- node.codegenNode.children = context.hoist(
11861
+ const hoisted = context.hoist(
11815
11862
  createArrayExpression(node.codegenNode.children)
11816
11863
  );
11864
+ if (context.hmr) {
11865
+ hoisted.content = `[...${hoisted.content}]`;
11866
+ }
11867
+ node.codegenNode.children = hoisted;
11817
11868
  }
11818
11869
  }
11819
11870
  function getConstantType(node, context) {
@@ -11986,6 +12037,7 @@ function createTransformContext(root, {
11986
12037
  filename = "",
11987
12038
  prefixIdentifiers = false,
11988
12039
  hoistStatic: hoistStatic2 = false,
12040
+ hmr = false,
11989
12041
  cacheHandlers = false,
11990
12042
  nodeTransforms = [],
11991
12043
  directiveTransforms = {},
@@ -12011,6 +12063,7 @@ function createTransformContext(root, {
12011
12063
  selfName: nameMatch && capitalize(camelize(nameMatch[1])),
12012
12064
  prefixIdentifiers,
12013
12065
  hoistStatic: hoistStatic2,
12066
+ hmr,
12014
12067
  cacheHandlers,
12015
12068
  nodeTransforms,
12016
12069
  directiveTransforms,
@@ -13362,8 +13415,8 @@ function processExpression(node, context, asParams = false, asRawStatements = fa
13362
13415
  const isScopeVarReference = context.identifiers[rawExp];
13363
13416
  const isAllowedGlobal = isGloballyAllowed(rawExp);
13364
13417
  const isLiteral = isLiteralWhitelisted(rawExp);
13365
- if (!asParams && !isScopeVarReference && !isAllowedGlobal && !isLiteral) {
13366
- if (isConst(bindingMetadata[node.content])) {
13418
+ if (!asParams && !isScopeVarReference && !isLiteral && (!isAllowedGlobal || bindingMetadata[rawExp])) {
13419
+ if (isConst(bindingMetadata[rawExp])) {
13367
13420
  node.constType = 1;
13368
13421
  }
13369
13422
  node.content = rewriteIdentifier(rawExp);
@@ -14013,7 +14066,7 @@ const trackVForSlotScopes = (node, context) => {
14013
14066
  }
14014
14067
  }
14015
14068
  };
14016
- const buildClientSlotFn = (props, children, loc) => createFunctionExpression(
14069
+ const buildClientSlotFn = (props, _vForExp, children, loc) => createFunctionExpression(
14017
14070
  props,
14018
14071
  children,
14019
14072
  false,
@@ -14038,7 +14091,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
14038
14091
  slotsProperties.push(
14039
14092
  createObjectProperty(
14040
14093
  arg || createSimpleExpression("default", true),
14041
- buildSlotFn(exp, children, loc)
14094
+ buildSlotFn(exp, void 0, children, loc)
14042
14095
  )
14043
14096
  );
14044
14097
  }
@@ -14075,10 +14128,15 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
14075
14128
  } else {
14076
14129
  hasDynamicSlots = true;
14077
14130
  }
14078
- const slotFunction = buildSlotFn(slotProps, slotChildren, slotLoc);
14131
+ const vFor = findDir(slotElement, "for");
14132
+ const slotFunction = buildSlotFn(
14133
+ slotProps,
14134
+ vFor == null ? void 0 : vFor.exp,
14135
+ slotChildren,
14136
+ slotLoc
14137
+ );
14079
14138
  let vIf;
14080
14139
  let vElse;
14081
- let vFor;
14082
14140
  if (vIf = findDir(slotElement, "if")) {
14083
14141
  hasDynamicSlots = true;
14084
14142
  dynamicSlots.push(
@@ -14123,7 +14181,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
14123
14181
  createCompilerError(30, vElse.loc)
14124
14182
  );
14125
14183
  }
14126
- } else if (vFor = findDir(slotElement, "for")) {
14184
+ } else if (vFor) {
14127
14185
  hasDynamicSlots = true;
14128
14186
  const parseResult = vFor.parseResult || parseForExpression(vFor.exp, context);
14129
14187
  if (parseResult) {
@@ -14164,7 +14222,7 @@ function buildSlots(node, context, buildSlotFn = buildClientSlotFn) {
14164
14222
  }
14165
14223
  if (!onComponentSlot) {
14166
14224
  const buildDefaultSlotProperty = (props, children2) => {
14167
- const fn = buildSlotFn(props, children2, loc);
14225
+ const fn = buildSlotFn(props, void 0, children2, loc);
14168
14226
  if (context.compatConfig) {
14169
14227
  fn.isNonScopedSlot = true;
14170
14228
  }