@vue/compat 3.2.34-beta.1 → 3.2.36

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.
@@ -4510,11 +4510,6 @@ const KeepAliveImpl = {
4510
4510
  // The whole point of this is to avoid importing KeepAlive directly in the
4511
4511
  // renderer to facilitate tree-shaking.
4512
4512
  const sharedContext = instance.ctx;
4513
- // if the internal renderer is not registered, it indicates that this is server-side rendering,
4514
- // for KeepAlive, we just need to render its children
4515
- if (!sharedContext.renderer) {
4516
- return slots.default;
4517
- }
4518
4513
  const cache = new Map();
4519
4514
  const keys = new Set();
4520
4515
  let current = null;
@@ -7113,7 +7108,7 @@ function createCompatVue(createApp, createSingletonApp) {
7113
7108
  return vm;
7114
7109
  }
7115
7110
  }
7116
- Vue.version = `2.6.14-compat:${"3.2.34-beta.1"}`;
7111
+ Vue.version = `2.6.14-compat:${"3.2.36"}`;
7117
7112
  Vue.config = singletonApp.config;
7118
7113
  Vue.use = (p, ...options) => {
7119
7114
  if (p && isFunction(p.install)) {
@@ -7279,9 +7274,11 @@ function installLegacyAPIs(app) {
7279
7274
  });
7280
7275
  }
7281
7276
  function applySingletonAppMutations(app) {
7282
- ['mixins', 'components', 'directives', 'filters', 'deopt'].forEach(key => {
7277
+ // copy over asset registries and deopt flag
7278
+ app._context.mixins = [...singletonApp._context.mixins];
7279
+ ['components', 'directives', 'filters'].forEach(key => {
7283
7280
  // @ts-ignore
7284
- app._context[key] = singletonApp._context[key];
7281
+ app._context[key] = Object.create(singletonApp._context[key]);
7285
7282
  });
7286
7283
  // copy over global config mutations
7287
7284
  isCopyingConfig = true;
@@ -7294,7 +7291,7 @@ function applySingletonAppMutations(app) {
7294
7291
  }
7295
7292
  const val = singletonApp.config[key];
7296
7293
  // @ts-ignore
7297
- app.config[key] = val;
7294
+ app.config[key] = isObject(val) ? Object.create(val) : val;
7298
7295
  // compat for runtime ignoredElements -> isCustomElement
7299
7296
  if (key === 'ignoredElements' &&
7300
7297
  isCompatEnabled("CONFIG_IGNORED_ELEMENTS" /* CONFIG_IGNORED_ELEMENTS */, null) &&
@@ -7799,7 +7796,7 @@ const isComment = (node) => node.nodeType === 8 /* COMMENT */;
7799
7796
  // Hydration also depends on some renderer internal logic which needs to be
7800
7797
  // passed in via arguments.
7801
7798
  function createHydrationFunctions(rendererInternals) {
7802
- const { mt: mountComponent, p: patch, o: { patchProp, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
7799
+ const { mt: mountComponent, p: patch, o: { patchProp, createText, nextSibling, parentNode, remove, insert, createComment } } = rendererInternals;
7803
7800
  const hydrate = (vnode, container) => {
7804
7801
  if (!container.hasChildNodes()) {
7805
7802
  warn$1(`Attempting to hydrate existing markup but container is empty. ` +
@@ -7830,7 +7827,15 @@ function createHydrationFunctions(rendererInternals) {
7830
7827
  switch (type) {
7831
7828
  case Text:
7832
7829
  if (domType !== 3 /* TEXT */) {
7833
- nextNode = onMismatch();
7830
+ // #5728 empty text node inside a slot can cause hydration failure
7831
+ // because the server rendered HTML won't contain a text node
7832
+ if (vnode.children === '') {
7833
+ insert((vnode.el = createText('')), parentNode(node), node);
7834
+ nextNode = node;
7835
+ }
7836
+ else {
7837
+ nextNode = onMismatch();
7838
+ }
7834
7839
  }
7835
7840
  else {
7836
7841
  if (node.data !== vnode.children) {
@@ -7904,6 +7909,12 @@ function createHydrationFunctions(rendererInternals) {
7904
7909
  nextNode = isFragmentStart
7905
7910
  ? locateClosingAsyncAnchor(node)
7906
7911
  : nextSibling(node);
7912
+ // #4293 teleport as component root
7913
+ if (nextNode &&
7914
+ isComment(nextNode) &&
7915
+ nextNode.data === 'teleport end') {
7916
+ nextNode = nextSibling(nextNode);
7917
+ }
7907
7918
  // #3787
7908
7919
  // if component is async, it may get moved / unmounted before its
7909
7920
  // inner component is loaded, so we need to give it a placeholder
@@ -8567,8 +8578,9 @@ function baseCreateRenderer(options, createHydrationFns) {
8567
8578
  const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''));
8568
8579
  const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''));
8569
8580
  let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
8570
- if (isHmrUpdating) {
8571
- // HMR updated, force full diff
8581
+ if (// #5523 dev root fragment may inherit directives
8582
+ (isHmrUpdating || patchFlag & 2048 /* DEV_ROOT_FRAGMENT */)) {
8583
+ // HMR updated / Dev root fragment (w/ comments), force full diff
8572
8584
  patchFlag = 0;
8573
8585
  optimized = false;
8574
8586
  dynamicChildren = null;
@@ -8590,8 +8602,6 @@ function baseCreateRenderer(options, createHydrationFns) {
8590
8602
  else {
8591
8603
  if (patchFlag > 0 &&
8592
8604
  patchFlag & 64 /* STABLE_FRAGMENT */ &&
8593
- // #5523 dev root fragment may inherit directives so always force update
8594
- !(patchFlag & 2048 /* DEV_ROOT_FRAGMENT */) &&
8595
8605
  dynamicChildren &&
8596
8606
  // #2715 the previous fragment could've been a BAILed one as a result
8597
8607
  // of renderSlot() with no valid children
@@ -9702,10 +9712,23 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
9702
9712
  }
9703
9713
  else {
9704
9714
  vnode.anchor = nextSibling(node);
9705
- vnode.targetAnchor = hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
9715
+ // lookahead until we find the target anchor
9716
+ // we cannot rely on return value of hydrateChildren() because there
9717
+ // could be nested teleports
9718
+ let targetAnchor = targetNode;
9719
+ while (targetAnchor) {
9720
+ targetAnchor = nextSibling(targetAnchor);
9721
+ if (targetAnchor &&
9722
+ targetAnchor.nodeType === 8 &&
9723
+ targetAnchor.data === 'teleport anchor') {
9724
+ vnode.targetAnchor = targetAnchor;
9725
+ target._lpa =
9726
+ vnode.targetAnchor && nextSibling(vnode.targetAnchor);
9727
+ break;
9728
+ }
9729
+ }
9730
+ hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
9706
9731
  }
9707
- target._lpa =
9708
- vnode.targetAnchor && nextSibling(vnode.targetAnchor);
9709
9732
  }
9710
9733
  }
9711
9734
  return vnode.anchor && nextSibling(vnode.anchor);
@@ -11076,7 +11099,7 @@ function isMemoSame(cached, memo) {
11076
11099
  }
11077
11100
 
11078
11101
  // Core API ------------------------------------------------------------------
11079
- const version = "3.2.34-beta.1";
11102
+ const version = "3.2.36";
11080
11103
  /**
11081
11104
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
11082
11105
  * @internal
@@ -11432,7 +11455,7 @@ const [_getNow, skipTimestampCheck] = /*#__PURE__*/ (() => {
11432
11455
  // if the low-res timestamp which is bigger than the event timestamp
11433
11456
  // (which is evaluated AFTER) it means the event is using a hi-res timestamp,
11434
11457
  // and we need to use the hi-res version for event listeners as well.
11435
- _getNow = () => performance.now();
11458
+ _getNow = performance.now.bind(performance);
11436
11459
  }
11437
11460
  // #3485: Firefox <= 53 has incorrect Event.timeStamp implementation
11438
11461
  // and does not fire microtasks in between event propagation, so safe to exclude.
@@ -11982,9 +12005,8 @@ function resolveTransitionProps(rawProps) {
11982
12005
  removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
11983
12006
  done && done();
11984
12007
  };
11985
- let isLeaving = false;
11986
12008
  const finishLeave = (el, done) => {
11987
- isLeaving = false;
12009
+ el._isLeaving = false;
11988
12010
  removeTransitionClass(el, leaveFromClass);
11989
12011
  removeTransitionClass(el, leaveToClass);
11990
12012
  removeTransitionClass(el, leaveActiveClass);
@@ -12027,7 +12049,7 @@ function resolveTransitionProps(rawProps) {
12027
12049
  onEnter: makeEnterHook(false),
12028
12050
  onAppear: makeEnterHook(true),
12029
12051
  onLeave(el, done) {
12030
- isLeaving = true;
12052
+ el._isLeaving = true;
12031
12053
  const resolve = () => finishLeave(el, done);
12032
12054
  addTransitionClass(el, leaveFromClass);
12033
12055
  if (legacyClassEnabled) {
@@ -12037,7 +12059,7 @@ function resolveTransitionProps(rawProps) {
12037
12059
  forceReflow();
12038
12060
  addTransitionClass(el, leaveActiveClass);
12039
12061
  nextFrame(() => {
12040
- if (!isLeaving) {
12062
+ if (!el._isLeaving) {
12041
12063
  // cancelled
12042
12064
  return;
12043
12065
  }
@@ -12568,27 +12590,25 @@ const vModelDynamic = {
12568
12590
  callModelHook(el, binding, vnode, prevVNode, 'updated');
12569
12591
  }
12570
12592
  };
12571
- function callModelHook(el, binding, vnode, prevVNode, hook) {
12572
- let modelToUse;
12573
- switch (el.tagName) {
12593
+ function resolveDynamicModel(tagName, type) {
12594
+ switch (tagName) {
12574
12595
  case 'SELECT':
12575
- modelToUse = vModelSelect;
12576
- break;
12596
+ return vModelSelect;
12577
12597
  case 'TEXTAREA':
12578
- modelToUse = vModelText;
12579
- break;
12598
+ return vModelText;
12580
12599
  default:
12581
- switch (vnode.props && vnode.props.type) {
12600
+ switch (type) {
12582
12601
  case 'checkbox':
12583
- modelToUse = vModelCheckbox;
12584
- break;
12602
+ return vModelCheckbox;
12585
12603
  case 'radio':
12586
- modelToUse = vModelRadio;
12587
- break;
12604
+ return vModelRadio;
12588
12605
  default:
12589
- modelToUse = vModelText;
12606
+ return vModelText;
12590
12607
  }
12591
12608
  }
12609
+ }
12610
+ function callModelHook(el, binding, vnode, prevVNode, hook) {
12611
+ const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
12592
12612
  const fn = modelToUse[hook];
12593
12613
  fn && fn(el, binding, vnode, prevVNode);
12594
12614
  }
@@ -14730,6 +14750,14 @@ function getConstantType(node, context) {
14730
14750
  // static then they don't need to be blocks since there will be no
14731
14751
  // nested updates.
14732
14752
  if (codegenNode.isBlock) {
14753
+ // except set custom directives.
14754
+ for (let i = 0; i < node.props.length; i++) {
14755
+ const p = node.props[i];
14756
+ if (p.type === 7 /* DIRECTIVE */) {
14757
+ constantCache.set(node, 0 /* NOT_CONSTANT */);
14758
+ return 0 /* NOT_CONSTANT */;
14759
+ }
14760
+ }
14733
14761
  context.removeHelper(OPEN_BLOCK);
14734
14762
  context.removeHelper(getVNodeBlockHelper(context.inSSR, codegenNode.isComponent));
14735
14763
  codegenNode.isBlock = false;
@@ -16485,7 +16513,7 @@ const transformElement = (node, context) => {
16485
16513
  (tag === 'svg' || tag === 'foreignObject'));
16486
16514
  // props
16487
16515
  if (props.length > 0) {
16488
- const propsBuildResult = buildProps(node, context);
16516
+ const propsBuildResult = buildProps(node, context, undefined, isComponent, isDynamicComponent);
16489
16517
  vnodeProps = propsBuildResult.props;
16490
16518
  patchFlag = propsBuildResult.patchFlag;
16491
16519
  dynamicPropNames = propsBuildResult.dynamicPropNames;
@@ -16624,9 +16652,8 @@ function resolveComponentType(node, context, ssr = false) {
16624
16652
  context.components.add(tag);
16625
16653
  return toValidAssetId(tag, `component`);
16626
16654
  }
16627
- function buildProps(node, context, props = node.props, ssr = false) {
16655
+ function buildProps(node, context, props = node.props, isComponent, isDynamicComponent, ssr = false) {
16628
16656
  const { tag, loc: elementLoc, children } = node;
16629
- const isComponent = node.tagType === 1 /* COMPONENT */;
16630
16657
  let properties = [];
16631
16658
  const mergeArgs = [];
16632
16659
  const runtimeDirectives = [];
@@ -16645,8 +16672,8 @@ function buildProps(node, context, props = node.props, ssr = false) {
16645
16672
  if (isStaticExp(key)) {
16646
16673
  const name = key.content;
16647
16674
  const isEventHandler = isOn(name);
16648
- if (!isComponent &&
16649
- isEventHandler &&
16675
+ if (isEventHandler &&
16676
+ (!isComponent || isDynamicComponent) &&
16650
16677
  // omit the flag for click handlers because hydration gives click
16651
16678
  // dedicated fast path.
16652
16679
  name.toLowerCase() !== 'onclick' &&
@@ -17084,7 +17111,7 @@ function processSlotOutlet(node, context) {
17084
17111
  }
17085
17112
  }
17086
17113
  if (nonNameProps.length > 0) {
17087
- const { props, directives } = buildProps(node, context, nonNameProps);
17114
+ const { props, directives } = buildProps(node, context, nonNameProps, false, false);
17088
17115
  slotProps = props;
17089
17116
  if (directives.length) {
17090
17117
  context.onError(createCompilerError(36 /* X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET */, directives[0].loc));