@vue/compat 3.2.44 → 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
@@ -4437,10 +4431,15 @@ function defineAsyncComponent(source) {
4437
4431
  }
4438
4432
  });
4439
4433
  }
4440
- function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
4434
+ function createInnerComp(comp, parent) {
4435
+ const { ref, props, children, ce } = parent.vnode;
4441
4436
  const vnode = createVNode(comp, props, children);
4442
4437
  // ensure inner component inherits the async wrapper's ref owner
4443
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;
4444
4443
  return vnode;
4445
4444
  }
4446
4445
 
@@ -4598,8 +4597,7 @@ const KeepAliveImpl = {
4598
4597
  : comp);
4599
4598
  const { include, exclude, max } = props;
4600
4599
  if ((include && (!name || !matches(include, name))) ||
4601
- (exclude && name && matches(exclude, name)) ||
4602
- (hmrDirtyComponents.has(comp))) {
4600
+ (exclude && name && matches(exclude, name))) {
4603
4601
  current = vnode;
4604
4602
  return rawVNode;
4605
4603
  }
@@ -4712,14 +4710,9 @@ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
4712
4710
  }, target);
4713
4711
  }
4714
4712
  function resetShapeFlag(vnode) {
4715
- let shapeFlag = vnode.shapeFlag;
4716
- if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
4717
- shapeFlag -= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4718
- }
4719
- if (shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
4720
- shapeFlag -= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4721
- }
4722
- 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 */;
4723
4716
  }
4724
4717
  function getInnerChild(vnode) {
4725
4718
  return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
@@ -5347,7 +5340,9 @@ fallback, noSlotted) {
5347
5340
  (currentRenderingInstance.parent &&
5348
5341
  isAsyncWrapper(currentRenderingInstance.parent) &&
5349
5342
  currentRenderingInstance.parent.isCE)) {
5350
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
5343
+ if (name !== 'default')
5344
+ props.name = name;
5345
+ return createVNode('slot', props, fallback && fallback());
5351
5346
  }
5352
5347
  let slot = slots[name];
5353
5348
  if (slot && slot.length > 1) {
@@ -5667,6 +5662,7 @@ const publicPropertiesMap =
5667
5662
  installCompatInstanceProperties(publicPropertiesMap);
5668
5663
  }
5669
5664
  const isReservedPrefix = (key) => key === '_' || key === '$';
5665
+ const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
5670
5666
  const PublicInstanceProxyHandlers = {
5671
5667
  get({ _: instance }, key) {
5672
5668
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
@@ -5674,15 +5670,6 @@ const PublicInstanceProxyHandlers = {
5674
5670
  if (key === '__isVue') {
5675
5671
  return true;
5676
5672
  }
5677
- // prioritize <script setup> bindings during dev.
5678
- // this allows even properties that start with _ or $ to be used - so that
5679
- // it aligns with the production behavior where the render fn is inlined and
5680
- // indeed has access to all declared variables.
5681
- if (setupState !== EMPTY_OBJ &&
5682
- setupState.__isScriptSetup &&
5683
- hasOwn(setupState, key)) {
5684
- return setupState[key];
5685
- }
5686
5673
  // data / props / ctx
5687
5674
  // This getter gets called for every property access on the render context
5688
5675
  // during render and is a major hotspot. The most expensive part of this
@@ -5705,7 +5692,7 @@ const PublicInstanceProxyHandlers = {
5705
5692
  // default: just fallthrough
5706
5693
  }
5707
5694
  }
5708
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5695
+ else if (hasSetupBinding(setupState, key)) {
5709
5696
  accessCache[key] = 1 /* AccessTypes.SETUP */;
5710
5697
  return setupState[key];
5711
5698
  }
@@ -5784,21 +5771,26 @@ const PublicInstanceProxyHandlers = {
5784
5771
  },
5785
5772
  set({ _: instance }, key, value) {
5786
5773
  const { data, setupState, ctx } = instance;
5787
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5774
+ if (hasSetupBinding(setupState, key)) {
5788
5775
  setupState[key] = value;
5789
5776
  return true;
5790
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
+ }
5791
5783
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
5792
5784
  data[key] = value;
5793
5785
  return true;
5794
5786
  }
5795
5787
  else if (hasOwn(instance.props, key)) {
5796
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
5788
+ warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
5797
5789
  return false;
5798
5790
  }
5799
5791
  if (key[0] === '$' && key.slice(1) in instance) {
5800
5792
  warn$1(`Attempting to mutate public property "${key}". ` +
5801
- `Properties starting with $ are reserved and readonly.`, instance);
5793
+ `Properties starting with $ are reserved and readonly.`);
5802
5794
  return false;
5803
5795
  }
5804
5796
  else {
@@ -5819,7 +5811,7 @@ const PublicInstanceProxyHandlers = {
5819
5811
  let normalizedProps;
5820
5812
  return (!!accessCache[key] ||
5821
5813
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
5822
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
5814
+ hasSetupBinding(setupState, key) ||
5823
5815
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
5824
5816
  hasOwn(ctx, key) ||
5825
5817
  hasOwn(publicPropertiesMap, key) ||
@@ -7094,7 +7086,7 @@ function createCompatVue(createApp, createSingletonApp) {
7094
7086
  return vm;
7095
7087
  }
7096
7088
  }
7097
- Vue.version = `2.6.14-compat:${"3.2.44"}`;
7089
+ Vue.version = `2.6.14-compat:${"3.2.45"}`;
7098
7090
  Vue.config = singletonApp.config;
7099
7091
  Vue.use = (p, ...options) => {
7100
7092
  if (p && isFunction(p.install)) {
@@ -9481,6 +9473,10 @@ function traverseStaticChildren(n1, n2, shallow = false) {
9481
9473
  if (!shallow)
9482
9474
  traverseStaticChildren(c1, c2);
9483
9475
  }
9476
+ // #6852 also inherit for text nodes
9477
+ if (c2.type === Text) {
9478
+ c2.el = c1.el;
9479
+ }
9484
9480
  // also inherit for comment nodes, but not placeholders (e.g. v-if which
9485
9481
  // would have received .el during block patch)
9486
9482
  if (c2.type === Comment && !c2.el) {
@@ -9651,6 +9647,7 @@ const TeleportImpl = {
9651
9647
  }
9652
9648
  }
9653
9649
  }
9650
+ updateCssVars(n2);
9654
9651
  },
9655
9652
  remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
9656
9653
  const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
@@ -9729,11 +9726,26 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
9729
9726
  hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
9730
9727
  }
9731
9728
  }
9729
+ updateCssVars(vnode);
9732
9730
  }
9733
9731
  return vnode.anchor && nextSibling(vnode.anchor);
9734
9732
  }
9735
9733
  // Force-casted public typing for h and TSX props inference
9736
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
+ }
9737
9749
 
9738
9750
  const normalizedAsyncComponentMap = new Map();
9739
9751
  function convertLegacyAsyncComponent(comp) {
@@ -9888,6 +9900,10 @@ function isVNode(value) {
9888
9900
  function isSameVNodeType(n1, n2) {
9889
9901
  if (n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
9890
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 */;
9891
9907
  // HMR only: if the component has been hot-updated, force a reload.
9892
9908
  return false;
9893
9909
  }
@@ -9943,7 +9959,8 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
9943
9959
  patchFlag,
9944
9960
  dynamicProps,
9945
9961
  dynamicChildren: null,
9946
- appContext: null
9962
+ appContext: null,
9963
+ ctx: currentRenderingInstance
9947
9964
  };
9948
9965
  if (needFullChildrenNormalization) {
9949
9966
  normalizeChildren(vnode, children);
@@ -10118,7 +10135,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
10118
10135
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
10119
10136
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
10120
10137
  el: vnode.el,
10121
- anchor: vnode.anchor
10138
+ anchor: vnode.anchor,
10139
+ ctx: vnode.ctx
10122
10140
  };
10123
10141
  {
10124
10142
  defineLegacyVNodeProperties(cloned);
@@ -11106,7 +11124,7 @@ function isMemoSame(cached, memo) {
11106
11124
  }
11107
11125
 
11108
11126
  // Core API ------------------------------------------------------------------
11109
- const version = "3.2.44";
11127
+ const version = "3.2.45";
11110
11128
  /**
11111
11129
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
11112
11130
  * @internal
@@ -11640,12 +11658,21 @@ class VueElement extends BaseClass {
11640
11658
  `defined as hydratable. Use \`defineSSRCustomElement\`.`);
11641
11659
  }
11642
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
+ }
11643
11665
  }
11644
11666
  }
11645
11667
  connectedCallback() {
11646
11668
  this._connected = true;
11647
11669
  if (!this._instance) {
11648
- this._resolveDef();
11670
+ if (this._resolved) {
11671
+ this._update();
11672
+ }
11673
+ else {
11674
+ this._resolveDef();
11675
+ }
11649
11676
  }
11650
11677
  }
11651
11678
  disconnectedCallback() {
@@ -11661,9 +11688,6 @@ class VueElement extends BaseClass {
11661
11688
  * resolve inner component definition (handle possible async component)
11662
11689
  */
11663
11690
  _resolveDef() {
11664
- if (this._resolved) {
11665
- return;
11666
- }
11667
11691
  this._resolved = true;
11668
11692
  // set initial attrs
11669
11693
  for (let i = 0; i < this.attributes.length; i++) {
@@ -11675,38 +11699,26 @@ class VueElement extends BaseClass {
11675
11699
  this._setAttr(m.attributeName);
11676
11700
  }
11677
11701
  }).observe(this, { attributes: true });
11678
- const resolve = (def) => {
11679
- const { props = {}, styles } = def;
11680
- const hasOptions = !isArray(props);
11681
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11702
+ const resolve = (def, isAsync = false) => {
11703
+ const { props, styles } = def;
11682
11704
  // cast Number-type props set before resolve
11683
11705
  let numberProps;
11684
- if (hasOptions) {
11685
- for (const key in this._props) {
11706
+ if (props && !isArray(props)) {
11707
+ for (const key in props) {
11686
11708
  const opt = props[key];
11687
11709
  if (opt === Number || (opt && opt.type === Number)) {
11688
- this._props[key] = toNumber(this._props[key]);
11689
- (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;
11690
11714
  }
11691
11715
  }
11692
11716
  }
11693
11717
  this._numberProps = numberProps;
11694
- // check if there are props set pre-upgrade or connect
11695
- for (const key of Object.keys(this)) {
11696
- if (key[0] !== '_') {
11697
- this._setProp(key, this[key], true, false);
11698
- }
11699
- }
11700
- // defining getter/setters on prototype
11701
- for (const key of rawKeys.map(camelize)) {
11702
- Object.defineProperty(this, key, {
11703
- get() {
11704
- return this._getProp(key);
11705
- },
11706
- set(val) {
11707
- this._setProp(key, val);
11708
- }
11709
- });
11718
+ if (isAsync) {
11719
+ // defining getter/setters on prototype
11720
+ // for sync defs, this already happened in the constructor
11721
+ this._resolveProps(def);
11710
11722
  }
11711
11723
  // apply CSS
11712
11724
  this._applyStyles(styles);
@@ -11715,12 +11727,33 @@ class VueElement extends BaseClass {
11715
11727
  };
11716
11728
  const asyncDef = this._def.__asyncLoader;
11717
11729
  if (asyncDef) {
11718
- asyncDef().then(resolve);
11730
+ asyncDef().then(def => resolve(def, true));
11719
11731
  }
11720
11732
  else {
11721
11733
  resolve(this._def);
11722
11734
  }
11723
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
+ }
11724
11757
  _setAttr(key) {
11725
11758
  let value = this.getAttribute(key);
11726
11759
  const camelKey = camelize(key);
@@ -11776,27 +11809,31 @@ class VueElement extends BaseClass {
11776
11809
  this._styles.length = 0;
11777
11810
  }
11778
11811
  this._applyStyles(newStyles);
11779
- // if this is an async component, ceReload is called from the inner
11780
- // component so no need to reload the async wrapper
11781
- if (!this._def.__asyncLoader) {
11782
- // reload
11783
- this._instance = null;
11784
- this._update();
11785
- }
11812
+ this._instance = null;
11813
+ this._update();
11786
11814
  };
11787
11815
  }
11788
- // intercept emit
11789
- instance.emit = (event, ...args) => {
11816
+ const dispatch = (event, args) => {
11790
11817
  this.dispatchEvent(new CustomEvent(event, {
11791
11818
  detail: args
11792
11819
  }));
11793
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
+ };
11794
11830
  // locate nearest Vue custom element parent for provide/inject
11795
11831
  let parent = this;
11796
11832
  while ((parent =
11797
11833
  parent && (parent.parentNode || parent.host))) {
11798
11834
  if (parent instanceof VueElement) {
11799
11835
  instance.parent = parent._instance;
11836
+ instance.provides = parent._instance.provides;
11800
11837
  break;
11801
11838
  }
11802
11839
  }
@@ -11852,7 +11889,14 @@ function useCssVars(getter) {
11852
11889
  warn$1(`useCssVars is called without current active component instance.`);
11853
11890
  return;
11854
11891
  }
11855
- 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
+ };
11856
11900
  watchPostEffect(setVars);
11857
11901
  onMounted(() => {
11858
11902
  const ob = new MutationObserver(setVars);