@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.
@@ -2022,12 +2022,6 @@ var Vue = (function () {
2022
2022
  // components to be unmounted and re-mounted. Queue the update so that we
2023
2023
  // don't end up forcing the same parent to re-render multiple times.
2024
2024
  queueJob(instance.parent.update);
2025
- // instance is the inner component of an async custom element
2026
- // invoke to reset styles
2027
- if (instance.parent.type.__asyncLoader &&
2028
- instance.parent.ceReload) {
2029
- instance.parent.ceReload(newComp.styles);
2030
- }
2031
2025
  }
2032
2026
  else if (instance.appContext.reload) {
2033
2027
  // root instance mounted via createApp() has a reload method
@@ -2258,8 +2252,8 @@ var Vue = (function () {
2258
2252
  },
2259
2253
  ["INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */]: {
2260
2254
  message: event => `"${event}" lifecycle events are no longer supported. From templates, ` +
2261
- `use the "vnode" prefix instead of "hook:". For example, @${event} ` +
2262
- `should be changed to @vnode-${event.slice(5)}. ` +
2255
+ `use the "vue:" prefix instead of "hook:". For example, @${event} ` +
2256
+ `should be changed to @vue:${event.slice(5)}. ` +
2263
2257
  `From JavaScript, use Composition API to dynamically register lifecycle ` +
2264
2258
  `hooks.`,
2265
2259
  link: `https://v3-migration.vuejs.org/breaking-changes/vnode-lifecycle-events.html`
@@ -3836,10 +3830,11 @@ var Vue = (function () {
3836
3830
  callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
3837
3831
  newValue,
3838
3832
  // pass undefined as the old value when it's changed for the first time
3839
- oldValue === INITIAL_WATCHER_VALUE ||
3840
- (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3841
- ? []
3842
- : oldValue,
3833
+ oldValue === INITIAL_WATCHER_VALUE
3834
+ ? undefined
3835
+ : (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3836
+ ? []
3837
+ : oldValue,
3843
3838
  onCleanup
3844
3839
  ]);
3845
3840
  oldValue = newValue;
@@ -4439,10 +4434,15 @@ var Vue = (function () {
4439
4434
  }
4440
4435
  });
4441
4436
  }
4442
- function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
4437
+ function createInnerComp(comp, parent) {
4438
+ const { ref, props, children, ce } = parent.vnode;
4443
4439
  const vnode = createVNode(comp, props, children);
4444
4440
  // ensure inner component inherits the async wrapper's ref owner
4445
4441
  vnode.ref = ref;
4442
+ // pass the custom element callback on to the inner comp
4443
+ // and remove it from the async wrapper
4444
+ vnode.ce = ce;
4445
+ delete parent.vnode.ce;
4446
4446
  return vnode;
4447
4447
  }
4448
4448
 
@@ -4600,8 +4600,7 @@ var Vue = (function () {
4600
4600
  : comp);
4601
4601
  const { include, exclude, max } = props;
4602
4602
  if ((include && (!name || !matches(include, name))) ||
4603
- (exclude && name && matches(exclude, name)) ||
4604
- (hmrDirtyComponents.has(comp))) {
4603
+ (exclude && name && matches(exclude, name))) {
4605
4604
  current = vnode;
4606
4605
  return rawVNode;
4607
4606
  }
@@ -4714,14 +4713,9 @@ var Vue = (function () {
4714
4713
  }, target);
4715
4714
  }
4716
4715
  function resetShapeFlag(vnode) {
4717
- let shapeFlag = vnode.shapeFlag;
4718
- if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
4719
- shapeFlag -= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4720
- }
4721
- if (shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
4722
- shapeFlag -= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4723
- }
4724
- vnode.shapeFlag = shapeFlag;
4716
+ // bitwise operations to remove keep alive flags
4717
+ vnode.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4718
+ vnode.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4725
4719
  }
4726
4720
  function getInnerChild(vnode) {
4727
4721
  return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
@@ -5349,7 +5343,9 @@ var Vue = (function () {
5349
5343
  (currentRenderingInstance.parent &&
5350
5344
  isAsyncWrapper(currentRenderingInstance.parent) &&
5351
5345
  currentRenderingInstance.parent.isCE)) {
5352
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
5346
+ if (name !== 'default')
5347
+ props.name = name;
5348
+ return createVNode('slot', props, fallback && fallback());
5353
5349
  }
5354
5350
  let slot = slots[name];
5355
5351
  if (slot && slot.length > 1) {
@@ -5669,6 +5665,7 @@ var Vue = (function () {
5669
5665
  installCompatInstanceProperties(publicPropertiesMap);
5670
5666
  }
5671
5667
  const isReservedPrefix = (key) => key === '_' || key === '$';
5668
+ const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
5672
5669
  const PublicInstanceProxyHandlers = {
5673
5670
  get({ _: instance }, key) {
5674
5671
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
@@ -5676,15 +5673,6 @@ var Vue = (function () {
5676
5673
  if (key === '__isVue') {
5677
5674
  return true;
5678
5675
  }
5679
- // prioritize <script setup> bindings during dev.
5680
- // this allows even properties that start with _ or $ to be used - so that
5681
- // it aligns with the production behavior where the render fn is inlined and
5682
- // indeed has access to all declared variables.
5683
- if (setupState !== EMPTY_OBJ &&
5684
- setupState.__isScriptSetup &&
5685
- hasOwn(setupState, key)) {
5686
- return setupState[key];
5687
- }
5688
5676
  // data / props / ctx
5689
5677
  // This getter gets called for every property access on the render context
5690
5678
  // during render and is a major hotspot. The most expensive part of this
@@ -5707,7 +5695,7 @@ var Vue = (function () {
5707
5695
  // default: just fallthrough
5708
5696
  }
5709
5697
  }
5710
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5698
+ else if (hasSetupBinding(setupState, key)) {
5711
5699
  accessCache[key] = 1 /* AccessTypes.SETUP */;
5712
5700
  return setupState[key];
5713
5701
  }
@@ -5786,21 +5774,26 @@ var Vue = (function () {
5786
5774
  },
5787
5775
  set({ _: instance }, key, value) {
5788
5776
  const { data, setupState, ctx } = instance;
5789
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5777
+ if (hasSetupBinding(setupState, key)) {
5790
5778
  setupState[key] = value;
5791
5779
  return true;
5792
5780
  }
5781
+ else if (setupState.__isScriptSetup &&
5782
+ hasOwn(setupState, key)) {
5783
+ warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
5784
+ return false;
5785
+ }
5793
5786
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
5794
5787
  data[key] = value;
5795
5788
  return true;
5796
5789
  }
5797
5790
  else if (hasOwn(instance.props, key)) {
5798
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
5791
+ warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
5799
5792
  return false;
5800
5793
  }
5801
5794
  if (key[0] === '$' && key.slice(1) in instance) {
5802
5795
  warn$1(`Attempting to mutate public property "${key}". ` +
5803
- `Properties starting with $ are reserved and readonly.`, instance);
5796
+ `Properties starting with $ are reserved and readonly.`);
5804
5797
  return false;
5805
5798
  }
5806
5799
  else {
@@ -5821,7 +5814,7 @@ var Vue = (function () {
5821
5814
  let normalizedProps;
5822
5815
  return (!!accessCache[key] ||
5823
5816
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
5824
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
5817
+ hasSetupBinding(setupState, key) ||
5825
5818
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
5826
5819
  hasOwn(ctx, key) ||
5827
5820
  hasOwn(publicPropertiesMap, key) ||
@@ -7096,7 +7089,7 @@ var Vue = (function () {
7096
7089
  return vm;
7097
7090
  }
7098
7091
  }
7099
- Vue.version = `2.6.14-compat:${"3.2.43"}`;
7092
+ Vue.version = `2.6.14-compat:${"3.2.45"}`;
7100
7093
  Vue.config = singletonApp.config;
7101
7094
  Vue.use = (p, ...options) => {
7102
7095
  if (p && isFunction(p.install)) {
@@ -9483,6 +9476,10 @@ var Vue = (function () {
9483
9476
  if (!shallow)
9484
9477
  traverseStaticChildren(c1, c2);
9485
9478
  }
9479
+ // #6852 also inherit for text nodes
9480
+ if (c2.type === Text) {
9481
+ c2.el = c1.el;
9482
+ }
9486
9483
  // also inherit for comment nodes, but not placeholders (e.g. v-if which
9487
9484
  // would have received .el during block patch)
9488
9485
  if (c2.type === Comment && !c2.el) {
@@ -9653,6 +9650,7 @@ var Vue = (function () {
9653
9650
  }
9654
9651
  }
9655
9652
  }
9653
+ updateCssVars(n2);
9656
9654
  },
9657
9655
  remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
9658
9656
  const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
@@ -9731,11 +9729,26 @@ var Vue = (function () {
9731
9729
  hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
9732
9730
  }
9733
9731
  }
9732
+ updateCssVars(vnode);
9734
9733
  }
9735
9734
  return vnode.anchor && nextSibling(vnode.anchor);
9736
9735
  }
9737
9736
  // Force-casted public typing for h and TSX props inference
9738
9737
  const Teleport = TeleportImpl;
9738
+ function updateCssVars(vnode) {
9739
+ // presence of .ut method indicates owner component uses css vars.
9740
+ // code path here can assume browser environment.
9741
+ const ctx = vnode.ctx;
9742
+ if (ctx && ctx.ut) {
9743
+ let node = vnode.children[0].el;
9744
+ while (node !== vnode.targetAnchor) {
9745
+ if (node.nodeType === 1)
9746
+ node.setAttribute('data-v-owner', ctx.uid);
9747
+ node = node.nextSibling;
9748
+ }
9749
+ ctx.ut();
9750
+ }
9751
+ }
9739
9752
 
9740
9753
  const normalizedAsyncComponentMap = new Map();
9741
9754
  function convertLegacyAsyncComponent(comp) {
@@ -9890,6 +9903,10 @@ var Vue = (function () {
9890
9903
  function isSameVNodeType(n1, n2) {
9891
9904
  if (n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
9892
9905
  hmrDirtyComponents.has(n2.type)) {
9906
+ // #7042, ensure the vnode being unmounted during HMR
9907
+ // bitwise operations to remove keep alive flags
9908
+ n1.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
9909
+ n2.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
9893
9910
  // HMR only: if the component has been hot-updated, force a reload.
9894
9911
  return false;
9895
9912
  }
@@ -9945,7 +9962,8 @@ var Vue = (function () {
9945
9962
  patchFlag,
9946
9963
  dynamicProps,
9947
9964
  dynamicChildren: null,
9948
- appContext: null
9965
+ appContext: null,
9966
+ ctx: currentRenderingInstance
9949
9967
  };
9950
9968
  if (needFullChildrenNormalization) {
9951
9969
  normalizeChildren(vnode, children);
@@ -10120,7 +10138,8 @@ var Vue = (function () {
10120
10138
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
10121
10139
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
10122
10140
  el: vnode.el,
10123
- anchor: vnode.anchor
10141
+ anchor: vnode.anchor,
10142
+ ctx: vnode.ctx
10124
10143
  };
10125
10144
  {
10126
10145
  defineLegacyVNodeProperties(cloned);
@@ -11103,7 +11122,7 @@ var Vue = (function () {
11103
11122
  }
11104
11123
 
11105
11124
  // Core API ------------------------------------------------------------------
11106
- const version = "3.2.43";
11125
+ const version = "3.2.45";
11107
11126
  /**
11108
11127
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
11109
11128
  * @internal
@@ -11256,6 +11275,7 @@ var Vue = (function () {
11256
11275
  }
11257
11276
  }
11258
11277
  }
11278
+ const semicolonRE = /[^\\];\s*$/;
11259
11279
  const importantRE = /\s*!important$/;
11260
11280
  function setStyle(style, name, val) {
11261
11281
  if (isArray(val)) {
@@ -11264,6 +11284,11 @@ var Vue = (function () {
11264
11284
  else {
11265
11285
  if (val == null)
11266
11286
  val = '';
11287
+ {
11288
+ if (semicolonRE.test(val)) {
11289
+ warn$1(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
11290
+ }
11291
+ }
11267
11292
  if (name.startsWith('--')) {
11268
11293
  // custom property definition
11269
11294
  style.setProperty(name, val);
@@ -11631,12 +11656,21 @@ var Vue = (function () {
11631
11656
  `defined as hydratable. Use \`defineSSRCustomElement\`.`);
11632
11657
  }
11633
11658
  this.attachShadow({ mode: 'open' });
11659
+ if (!this._def.__asyncLoader) {
11660
+ // for sync component defs we can immediately resolve props
11661
+ this._resolveProps(this._def);
11662
+ }
11634
11663
  }
11635
11664
  }
11636
11665
  connectedCallback() {
11637
11666
  this._connected = true;
11638
11667
  if (!this._instance) {
11639
- this._resolveDef();
11668
+ if (this._resolved) {
11669
+ this._update();
11670
+ }
11671
+ else {
11672
+ this._resolveDef();
11673
+ }
11640
11674
  }
11641
11675
  }
11642
11676
  disconnectedCallback() {
@@ -11652,9 +11686,6 @@ var Vue = (function () {
11652
11686
  * resolve inner component definition (handle possible async component)
11653
11687
  */
11654
11688
  _resolveDef() {
11655
- if (this._resolved) {
11656
- return;
11657
- }
11658
11689
  this._resolved = true;
11659
11690
  // set initial attrs
11660
11691
  for (let i = 0; i < this.attributes.length; i++) {
@@ -11666,38 +11697,26 @@ var Vue = (function () {
11666
11697
  this._setAttr(m.attributeName);
11667
11698
  }
11668
11699
  }).observe(this, { attributes: true });
11669
- const resolve = (def) => {
11670
- const { props = {}, styles } = def;
11671
- const hasOptions = !isArray(props);
11672
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11700
+ const resolve = (def, isAsync = false) => {
11701
+ const { props, styles } = def;
11673
11702
  // cast Number-type props set before resolve
11674
11703
  let numberProps;
11675
- if (hasOptions) {
11676
- for (const key in this._props) {
11704
+ if (props && !isArray(props)) {
11705
+ for (const key in props) {
11677
11706
  const opt = props[key];
11678
11707
  if (opt === Number || (opt && opt.type === Number)) {
11679
- this._props[key] = toNumber(this._props[key]);
11680
- (numberProps || (numberProps = Object.create(null)))[key] = true;
11708
+ if (key in this._props) {
11709
+ this._props[key] = toNumber(this._props[key]);
11710
+ }
11711
+ (numberProps || (numberProps = Object.create(null)))[camelize(key)] = true;
11681
11712
  }
11682
11713
  }
11683
11714
  }
11684
11715
  this._numberProps = numberProps;
11685
- // check if there are props set pre-upgrade or connect
11686
- for (const key of Object.keys(this)) {
11687
- if (key[0] !== '_') {
11688
- this._setProp(key, this[key], true, false);
11689
- }
11690
- }
11691
- // defining getter/setters on prototype
11692
- for (const key of rawKeys.map(camelize)) {
11693
- Object.defineProperty(this, key, {
11694
- get() {
11695
- return this._getProp(key);
11696
- },
11697
- set(val) {
11698
- this._setProp(key, val);
11699
- }
11700
- });
11716
+ if (isAsync) {
11717
+ // defining getter/setters on prototype
11718
+ // for sync defs, this already happened in the constructor
11719
+ this._resolveProps(def);
11701
11720
  }
11702
11721
  // apply CSS
11703
11722
  this._applyStyles(styles);
@@ -11706,12 +11725,33 @@ var Vue = (function () {
11706
11725
  };
11707
11726
  const asyncDef = this._def.__asyncLoader;
11708
11727
  if (asyncDef) {
11709
- asyncDef().then(resolve);
11728
+ asyncDef().then(def => resolve(def, true));
11710
11729
  }
11711
11730
  else {
11712
11731
  resolve(this._def);
11713
11732
  }
11714
11733
  }
11734
+ _resolveProps(def) {
11735
+ const { props } = def;
11736
+ const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
11737
+ // check if there are props set pre-upgrade or connect
11738
+ for (const key of Object.keys(this)) {
11739
+ if (key[0] !== '_' && declaredPropKeys.includes(key)) {
11740
+ this._setProp(key, this[key], true, false);
11741
+ }
11742
+ }
11743
+ // defining getter/setters on prototype
11744
+ for (const key of declaredPropKeys.map(camelize)) {
11745
+ Object.defineProperty(this, key, {
11746
+ get() {
11747
+ return this._getProp(key);
11748
+ },
11749
+ set(val) {
11750
+ this._setProp(key, val);
11751
+ }
11752
+ });
11753
+ }
11754
+ }
11715
11755
  _setAttr(key) {
11716
11756
  let value = this.getAttribute(key);
11717
11757
  const camelKey = camelize(key);
@@ -11767,27 +11807,31 @@ var Vue = (function () {
11767
11807
  this._styles.length = 0;
11768
11808
  }
11769
11809
  this._applyStyles(newStyles);
11770
- // if this is an async component, ceReload is called from the inner
11771
- // component so no need to reload the async wrapper
11772
- if (!this._def.__asyncLoader) {
11773
- // reload
11774
- this._instance = null;
11775
- this._update();
11776
- }
11810
+ this._instance = null;
11811
+ this._update();
11777
11812
  };
11778
11813
  }
11779
- // intercept emit
11780
- instance.emit = (event, ...args) => {
11814
+ const dispatch = (event, args) => {
11781
11815
  this.dispatchEvent(new CustomEvent(event, {
11782
11816
  detail: args
11783
11817
  }));
11784
11818
  };
11819
+ // intercept emit
11820
+ instance.emit = (event, ...args) => {
11821
+ // dispatch both the raw and hyphenated versions of an event
11822
+ // to match Vue behavior
11823
+ dispatch(event, args);
11824
+ if (hyphenate(event) !== event) {
11825
+ dispatch(hyphenate(event), args);
11826
+ }
11827
+ };
11785
11828
  // locate nearest Vue custom element parent for provide/inject
11786
11829
  let parent = this;
11787
11830
  while ((parent =
11788
11831
  parent && (parent.parentNode || parent.host))) {
11789
11832
  if (parent instanceof VueElement) {
11790
11833
  instance.parent = parent._instance;
11834
+ instance.provides = parent._instance.provides;
11791
11835
  break;
11792
11836
  }
11793
11837
  }
@@ -11831,7 +11875,14 @@ var Vue = (function () {
11831
11875
  warn$1(`useCssVars is called without current active component instance.`);
11832
11876
  return;
11833
11877
  }
11834
- const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
11878
+ const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
11879
+ Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach(node => setVarsOnNode(node, vars));
11880
+ });
11881
+ const setVars = () => {
11882
+ const vars = getter(instance.proxy);
11883
+ setVarsOnVNode(instance.subTree, vars);
11884
+ updateTeleports(vars);
11885
+ };
11835
11886
  watchPostEffect(setVars);
11836
11887
  onMounted(() => {
11837
11888
  const ob = new MutationObserver(setVars);