@vue/compat 3.2.43 → 3.2.45

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.
@@ -2019,12 +2019,6 @@ function reload(id, newComp) {
2019
2019
  // components to be unmounted and re-mounted. Queue the update so that we
2020
2020
  // don't end up forcing the same parent to re-render multiple times.
2021
2021
  queueJob(instance.parent.update);
2022
- // instance is the inner component of an async custom element
2023
- // invoke to reset styles
2024
- if (instance.parent.type.__asyncLoader &&
2025
- instance.parent.ceReload) {
2026
- instance.parent.ceReload(newComp.styles);
2027
- }
2028
2022
  }
2029
2023
  else if (instance.appContext.reload) {
2030
2024
  // root instance mounted via createApp() has a reload method
@@ -2255,8 +2249,8 @@ const deprecationData = {
2255
2249
  },
2256
2250
  ["INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */]: {
2257
2251
  message: event => `"${event}" lifecycle events are no longer supported. From templates, ` +
2258
- `use the "vnode" prefix instead of "hook:". For example, @${event} ` +
2259
- `should be changed to @vnode-${event.slice(5)}. ` +
2252
+ `use the "vue:" prefix instead of "hook:". For example, @${event} ` +
2253
+ `should be changed to @vue:${event.slice(5)}. ` +
2260
2254
  `From JavaScript, use Composition API to dynamically register lifecycle ` +
2261
2255
  `hooks.`,
2262
2256
  link: `https://v3-migration.vuejs.org/breaking-changes/vnode-lifecycle-events.html`
@@ -3833,10 +3827,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3833
3827
  callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
3834
3828
  newValue,
3835
3829
  // pass undefined as the old value when it's changed for the first time
3836
- oldValue === INITIAL_WATCHER_VALUE ||
3837
- (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3838
- ? []
3839
- : oldValue,
3830
+ oldValue === INITIAL_WATCHER_VALUE
3831
+ ? undefined
3832
+ : (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3833
+ ? []
3834
+ : oldValue,
3840
3835
  onCleanup
3841
3836
  ]);
3842
3837
  oldValue = newValue;
@@ -4436,10 +4431,15 @@ function defineAsyncComponent(source) {
4436
4431
  }
4437
4432
  });
4438
4433
  }
4439
- function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
4434
+ function createInnerComp(comp, parent) {
4435
+ const { ref, props, children, ce } = parent.vnode;
4440
4436
  const vnode = createVNode(comp, props, children);
4441
4437
  // ensure inner component inherits the async wrapper's ref owner
4442
4438
  vnode.ref = ref;
4439
+ // pass the custom element callback on to the inner comp
4440
+ // and remove it from the async wrapper
4441
+ vnode.ce = ce;
4442
+ delete parent.vnode.ce;
4443
4443
  return vnode;
4444
4444
  }
4445
4445
 
@@ -4597,8 +4597,7 @@ const KeepAliveImpl = {
4597
4597
  : comp);
4598
4598
  const { include, exclude, max } = props;
4599
4599
  if ((include && (!name || !matches(include, name))) ||
4600
- (exclude && name && matches(exclude, name)) ||
4601
- (hmrDirtyComponents.has(comp))) {
4600
+ (exclude && name && matches(exclude, name))) {
4602
4601
  current = vnode;
4603
4602
  return rawVNode;
4604
4603
  }
@@ -4711,14 +4710,9 @@ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
4711
4710
  }, target);
4712
4711
  }
4713
4712
  function resetShapeFlag(vnode) {
4714
- let shapeFlag = vnode.shapeFlag;
4715
- if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
4716
- shapeFlag -= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4717
- }
4718
- if (shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
4719
- shapeFlag -= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4720
- }
4721
- vnode.shapeFlag = shapeFlag;
4713
+ // bitwise operations to remove keep alive flags
4714
+ vnode.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4715
+ vnode.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4722
4716
  }
4723
4717
  function getInnerChild(vnode) {
4724
4718
  return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
@@ -5346,7 +5340,9 @@ fallback, noSlotted) {
5346
5340
  (currentRenderingInstance.parent &&
5347
5341
  isAsyncWrapper(currentRenderingInstance.parent) &&
5348
5342
  currentRenderingInstance.parent.isCE)) {
5349
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
5343
+ if (name !== 'default')
5344
+ props.name = name;
5345
+ return createVNode('slot', props, fallback && fallback());
5350
5346
  }
5351
5347
  let slot = slots[name];
5352
5348
  if (slot && slot.length > 1) {
@@ -5666,6 +5662,7 @@ const publicPropertiesMap =
5666
5662
  installCompatInstanceProperties(publicPropertiesMap);
5667
5663
  }
5668
5664
  const isReservedPrefix = (key) => key === '_' || key === '$';
5665
+ const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
5669
5666
  const PublicInstanceProxyHandlers = {
5670
5667
  get({ _: instance }, key) {
5671
5668
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
@@ -5673,15 +5670,6 @@ const PublicInstanceProxyHandlers = {
5673
5670
  if (key === '__isVue') {
5674
5671
  return true;
5675
5672
  }
5676
- // prioritize <script setup> bindings during dev.
5677
- // this allows even properties that start with _ or $ to be used - so that
5678
- // it aligns with the production behavior where the render fn is inlined and
5679
- // indeed has access to all declared variables.
5680
- if (setupState !== EMPTY_OBJ &&
5681
- setupState.__isScriptSetup &&
5682
- hasOwn(setupState, key)) {
5683
- return setupState[key];
5684
- }
5685
5673
  // data / props / ctx
5686
5674
  // This getter gets called for every property access on the render context
5687
5675
  // during render and is a major hotspot. The most expensive part of this
@@ -5704,7 +5692,7 @@ const PublicInstanceProxyHandlers = {
5704
5692
  // default: just fallthrough
5705
5693
  }
5706
5694
  }
5707
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5695
+ else if (hasSetupBinding(setupState, key)) {
5708
5696
  accessCache[key] = 1 /* AccessTypes.SETUP */;
5709
5697
  return setupState[key];
5710
5698
  }
@@ -5783,21 +5771,26 @@ const PublicInstanceProxyHandlers = {
5783
5771
  },
5784
5772
  set({ _: instance }, key, value) {
5785
5773
  const { data, setupState, ctx } = instance;
5786
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5774
+ if (hasSetupBinding(setupState, key)) {
5787
5775
  setupState[key] = value;
5788
5776
  return true;
5789
5777
  }
5778
+ else if (setupState.__isScriptSetup &&
5779
+ hasOwn(setupState, key)) {
5780
+ warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
5781
+ return false;
5782
+ }
5790
5783
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
5791
5784
  data[key] = value;
5792
5785
  return true;
5793
5786
  }
5794
5787
  else if (hasOwn(instance.props, key)) {
5795
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
5788
+ warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
5796
5789
  return false;
5797
5790
  }
5798
5791
  if (key[0] === '$' && key.slice(1) in instance) {
5799
5792
  warn$1(`Attempting to mutate public property "${key}". ` +
5800
- `Properties starting with $ are reserved and readonly.`, instance);
5793
+ `Properties starting with $ are reserved and readonly.`);
5801
5794
  return false;
5802
5795
  }
5803
5796
  else {
@@ -5818,7 +5811,7 @@ const PublicInstanceProxyHandlers = {
5818
5811
  let normalizedProps;
5819
5812
  return (!!accessCache[key] ||
5820
5813
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
5821
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
5814
+ hasSetupBinding(setupState, key) ||
5822
5815
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
5823
5816
  hasOwn(ctx, key) ||
5824
5817
  hasOwn(publicPropertiesMap, key) ||
@@ -7093,7 +7086,7 @@ function createCompatVue(createApp, createSingletonApp) {
7093
7086
  return vm;
7094
7087
  }
7095
7088
  }
7096
- Vue.version = `2.6.14-compat:${"3.2.43"}`;
7089
+ Vue.version = `2.6.14-compat:${"3.2.45"}`;
7097
7090
  Vue.config = singletonApp.config;
7098
7091
  Vue.use = (p, ...options) => {
7099
7092
  if (p && isFunction(p.install)) {
@@ -9480,6 +9473,10 @@ function traverseStaticChildren(n1, n2, shallow = false) {
9480
9473
  if (!shallow)
9481
9474
  traverseStaticChildren(c1, c2);
9482
9475
  }
9476
+ // #6852 also inherit for text nodes
9477
+ if (c2.type === Text) {
9478
+ c2.el = c1.el;
9479
+ }
9483
9480
  // also inherit for comment nodes, but not placeholders (e.g. v-if which
9484
9481
  // would have received .el during block patch)
9485
9482
  if (c2.type === Comment && !c2.el) {
@@ -9650,6 +9647,7 @@ const TeleportImpl = {
9650
9647
  }
9651
9648
  }
9652
9649
  }
9650
+ updateCssVars(n2);
9653
9651
  },
9654
9652
  remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
9655
9653
  const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
@@ -9728,11 +9726,26 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
9728
9726
  hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
9729
9727
  }
9730
9728
  }
9729
+ updateCssVars(vnode);
9731
9730
  }
9732
9731
  return vnode.anchor && nextSibling(vnode.anchor);
9733
9732
  }
9734
9733
  // Force-casted public typing for h and TSX props inference
9735
9734
  const Teleport = TeleportImpl;
9735
+ function updateCssVars(vnode) {
9736
+ // presence of .ut method indicates owner component uses css vars.
9737
+ // code path here can assume browser environment.
9738
+ const ctx = vnode.ctx;
9739
+ if (ctx && ctx.ut) {
9740
+ let node = vnode.children[0].el;
9741
+ while (node !== vnode.targetAnchor) {
9742
+ if (node.nodeType === 1)
9743
+ node.setAttribute('data-v-owner', ctx.uid);
9744
+ node = node.nextSibling;
9745
+ }
9746
+ ctx.ut();
9747
+ }
9748
+ }
9736
9749
 
9737
9750
  const normalizedAsyncComponentMap = new Map();
9738
9751
  function convertLegacyAsyncComponent(comp) {
@@ -9887,6 +9900,10 @@ function isVNode(value) {
9887
9900
  function isSameVNodeType(n1, n2) {
9888
9901
  if (n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
9889
9902
  hmrDirtyComponents.has(n2.type)) {
9903
+ // #7042, ensure the vnode being unmounted during HMR
9904
+ // bitwise operations to remove keep alive flags
9905
+ n1.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
9906
+ n2.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
9890
9907
  // HMR only: if the component has been hot-updated, force a reload.
9891
9908
  return false;
9892
9909
  }
@@ -9942,7 +9959,8 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
9942
9959
  patchFlag,
9943
9960
  dynamicProps,
9944
9961
  dynamicChildren: null,
9945
- appContext: null
9962
+ appContext: null,
9963
+ ctx: currentRenderingInstance
9946
9964
  };
9947
9965
  if (needFullChildrenNormalization) {
9948
9966
  normalizeChildren(vnode, children);
@@ -10117,7 +10135,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
10117
10135
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
10118
10136
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
10119
10137
  el: vnode.el,
10120
- anchor: vnode.anchor
10138
+ anchor: vnode.anchor,
10139
+ ctx: vnode.ctx
10121
10140
  };
10122
10141
  {
10123
10142
  defineLegacyVNodeProperties(cloned);
@@ -11105,7 +11124,7 @@ function isMemoSame(cached, memo) {
11105
11124
  }
11106
11125
 
11107
11126
  // Core API ------------------------------------------------------------------
11108
- const version = "3.2.43";
11127
+ const version = "3.2.45";
11109
11128
  /**
11110
11129
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
11111
11130
  * @internal
@@ -11258,6 +11277,7 @@ function patchStyle(el, prev, next) {
11258
11277
  }
11259
11278
  }
11260
11279
  }
11280
+ const semicolonRE = /[^\\];\s*$/;
11261
11281
  const importantRE = /\s*!important$/;
11262
11282
  function setStyle(style, name, val) {
11263
11283
  if (isArray(val)) {
@@ -11266,6 +11286,11 @@ function setStyle(style, name, val) {
11266
11286
  else {
11267
11287
  if (val == null)
11268
11288
  val = '';
11289
+ {
11290
+ if (semicolonRE.test(val)) {
11291
+ warn$1(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
11292
+ }
11293
+ }
11269
11294
  if (name.startsWith('--')) {
11270
11295
  // custom property definition
11271
11296
  style.setProperty(name, val);
@@ -11633,12 +11658,21 @@ class VueElement extends BaseClass {
11633
11658
  `defined as hydratable. Use \`defineSSRCustomElement\`.`);
11634
11659
  }
11635
11660
  this.attachShadow({ mode: 'open' });
11661
+ if (!this._def.__asyncLoader) {
11662
+ // for sync component defs we can immediately resolve props
11663
+ this._resolveProps(this._def);
11664
+ }
11636
11665
  }
11637
11666
  }
11638
11667
  connectedCallback() {
11639
11668
  this._connected = true;
11640
11669
  if (!this._instance) {
11641
- this._resolveDef();
11670
+ if (this._resolved) {
11671
+ this._update();
11672
+ }
11673
+ else {
11674
+ this._resolveDef();
11675
+ }
11642
11676
  }
11643
11677
  }
11644
11678
  disconnectedCallback() {
@@ -11654,9 +11688,6 @@ class VueElement extends BaseClass {
11654
11688
  * resolve inner component definition (handle possible async component)
11655
11689
  */
11656
11690
  _resolveDef() {
11657
- if (this._resolved) {
11658
- return;
11659
- }
11660
11691
  this._resolved = true;
11661
11692
  // set initial attrs
11662
11693
  for (let i = 0; i < this.attributes.length; i++) {
@@ -11668,38 +11699,26 @@ class VueElement extends BaseClass {
11668
11699
  this._setAttr(m.attributeName);
11669
11700
  }
11670
11701
  }).observe(this, { attributes: true });
11671
- const resolve = (def) => {
11672
- const { props = {}, styles } = def;
11673
- const hasOptions = !isArray(props);
11674
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11702
+ const resolve = (def, isAsync = false) => {
11703
+ const { props, styles } = def;
11675
11704
  // cast Number-type props set before resolve
11676
11705
  let numberProps;
11677
- if (hasOptions) {
11678
- for (const key in this._props) {
11706
+ if (props && !isArray(props)) {
11707
+ for (const key in props) {
11679
11708
  const opt = props[key];
11680
11709
  if (opt === Number || (opt && opt.type === Number)) {
11681
- this._props[key] = toNumber(this._props[key]);
11682
- (numberProps || (numberProps = Object.create(null)))[key] = true;
11710
+ if (key in this._props) {
11711
+ this._props[key] = toNumber(this._props[key]);
11712
+ }
11713
+ (numberProps || (numberProps = Object.create(null)))[camelize(key)] = true;
11683
11714
  }
11684
11715
  }
11685
11716
  }
11686
11717
  this._numberProps = numberProps;
11687
- // check if there are props set pre-upgrade or connect
11688
- for (const key of Object.keys(this)) {
11689
- if (key[0] !== '_') {
11690
- this._setProp(key, this[key], true, false);
11691
- }
11692
- }
11693
- // defining getter/setters on prototype
11694
- for (const key of rawKeys.map(camelize)) {
11695
- Object.defineProperty(this, key, {
11696
- get() {
11697
- return this._getProp(key);
11698
- },
11699
- set(val) {
11700
- this._setProp(key, val);
11701
- }
11702
- });
11718
+ if (isAsync) {
11719
+ // defining getter/setters on prototype
11720
+ // for sync defs, this already happened in the constructor
11721
+ this._resolveProps(def);
11703
11722
  }
11704
11723
  // apply CSS
11705
11724
  this._applyStyles(styles);
@@ -11708,12 +11727,33 @@ class VueElement extends BaseClass {
11708
11727
  };
11709
11728
  const asyncDef = this._def.__asyncLoader;
11710
11729
  if (asyncDef) {
11711
- asyncDef().then(resolve);
11730
+ asyncDef().then(def => resolve(def, true));
11712
11731
  }
11713
11732
  else {
11714
11733
  resolve(this._def);
11715
11734
  }
11716
11735
  }
11736
+ _resolveProps(def) {
11737
+ const { props } = def;
11738
+ const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
11739
+ // check if there are props set pre-upgrade or connect
11740
+ for (const key of Object.keys(this)) {
11741
+ if (key[0] !== '_' && declaredPropKeys.includes(key)) {
11742
+ this._setProp(key, this[key], true, false);
11743
+ }
11744
+ }
11745
+ // defining getter/setters on prototype
11746
+ for (const key of declaredPropKeys.map(camelize)) {
11747
+ Object.defineProperty(this, key, {
11748
+ get() {
11749
+ return this._getProp(key);
11750
+ },
11751
+ set(val) {
11752
+ this._setProp(key, val);
11753
+ }
11754
+ });
11755
+ }
11756
+ }
11717
11757
  _setAttr(key) {
11718
11758
  let value = this.getAttribute(key);
11719
11759
  const camelKey = camelize(key);
@@ -11769,27 +11809,31 @@ class VueElement extends BaseClass {
11769
11809
  this._styles.length = 0;
11770
11810
  }
11771
11811
  this._applyStyles(newStyles);
11772
- // if this is an async component, ceReload is called from the inner
11773
- // component so no need to reload the async wrapper
11774
- if (!this._def.__asyncLoader) {
11775
- // reload
11776
- this._instance = null;
11777
- this._update();
11778
- }
11812
+ this._instance = null;
11813
+ this._update();
11779
11814
  };
11780
11815
  }
11781
- // intercept emit
11782
- instance.emit = (event, ...args) => {
11816
+ const dispatch = (event, args) => {
11783
11817
  this.dispatchEvent(new CustomEvent(event, {
11784
11818
  detail: args
11785
11819
  }));
11786
11820
  };
11821
+ // intercept emit
11822
+ instance.emit = (event, ...args) => {
11823
+ // dispatch both the raw and hyphenated versions of an event
11824
+ // to match Vue behavior
11825
+ dispatch(event, args);
11826
+ if (hyphenate(event) !== event) {
11827
+ dispatch(hyphenate(event), args);
11828
+ }
11829
+ };
11787
11830
  // locate nearest Vue custom element parent for provide/inject
11788
11831
  let parent = this;
11789
11832
  while ((parent =
11790
11833
  parent && (parent.parentNode || parent.host))) {
11791
11834
  if (parent instanceof VueElement) {
11792
11835
  instance.parent = parent._instance;
11836
+ instance.provides = parent._instance.provides;
11793
11837
  break;
11794
11838
  }
11795
11839
  }
@@ -11845,7 +11889,14 @@ function useCssVars(getter) {
11845
11889
  warn$1(`useCssVars is called without current active component instance.`);
11846
11890
  return;
11847
11891
  }
11848
- const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
11892
+ const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
11893
+ Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach(node => setVarsOnNode(node, vars));
11894
+ });
11895
+ const setVars = () => {
11896
+ const vars = getter(instance.proxy);
11897
+ setVarsOnVNode(instance.subTree, vars);
11898
+ updateTeleports(vars);
11899
+ };
11849
11900
  watchPostEffect(setVars);
11850
11901
  onMounted(() => {
11851
11902
  const ob = new MutationObserver(setVars);