@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.
@@ -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
@@ -4440,10 +4434,15 @@ var Vue = (function () {
4440
4434
  }
4441
4435
  });
4442
4436
  }
4443
- function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
4437
+ function createInnerComp(comp, parent) {
4438
+ const { ref, props, children, ce } = parent.vnode;
4444
4439
  const vnode = createVNode(comp, props, children);
4445
4440
  // ensure inner component inherits the async wrapper's ref owner
4446
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;
4447
4446
  return vnode;
4448
4447
  }
4449
4448
 
@@ -4601,8 +4600,7 @@ var Vue = (function () {
4601
4600
  : comp);
4602
4601
  const { include, exclude, max } = props;
4603
4602
  if ((include && (!name || !matches(include, name))) ||
4604
- (exclude && name && matches(exclude, name)) ||
4605
- (hmrDirtyComponents.has(comp))) {
4603
+ (exclude && name && matches(exclude, name))) {
4606
4604
  current = vnode;
4607
4605
  return rawVNode;
4608
4606
  }
@@ -4715,14 +4713,9 @@ var Vue = (function () {
4715
4713
  }, target);
4716
4714
  }
4717
4715
  function resetShapeFlag(vnode) {
4718
- let shapeFlag = vnode.shapeFlag;
4719
- if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
4720
- shapeFlag -= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4721
- }
4722
- if (shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
4723
- shapeFlag -= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4724
- }
4725
- 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 */;
4726
4719
  }
4727
4720
  function getInnerChild(vnode) {
4728
4721
  return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
@@ -5350,7 +5343,9 @@ var Vue = (function () {
5350
5343
  (currentRenderingInstance.parent &&
5351
5344
  isAsyncWrapper(currentRenderingInstance.parent) &&
5352
5345
  currentRenderingInstance.parent.isCE)) {
5353
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
5346
+ if (name !== 'default')
5347
+ props.name = name;
5348
+ return createVNode('slot', props, fallback && fallback());
5354
5349
  }
5355
5350
  let slot = slots[name];
5356
5351
  if (slot && slot.length > 1) {
@@ -5670,6 +5665,7 @@ var Vue = (function () {
5670
5665
  installCompatInstanceProperties(publicPropertiesMap);
5671
5666
  }
5672
5667
  const isReservedPrefix = (key) => key === '_' || key === '$';
5668
+ const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
5673
5669
  const PublicInstanceProxyHandlers = {
5674
5670
  get({ _: instance }, key) {
5675
5671
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
@@ -5677,15 +5673,6 @@ var Vue = (function () {
5677
5673
  if (key === '__isVue') {
5678
5674
  return true;
5679
5675
  }
5680
- // prioritize <script setup> bindings during dev.
5681
- // this allows even properties that start with _ or $ to be used - so that
5682
- // it aligns with the production behavior where the render fn is inlined and
5683
- // indeed has access to all declared variables.
5684
- if (setupState !== EMPTY_OBJ &&
5685
- setupState.__isScriptSetup &&
5686
- hasOwn(setupState, key)) {
5687
- return setupState[key];
5688
- }
5689
5676
  // data / props / ctx
5690
5677
  // This getter gets called for every property access on the render context
5691
5678
  // during render and is a major hotspot. The most expensive part of this
@@ -5708,7 +5695,7 @@ var Vue = (function () {
5708
5695
  // default: just fallthrough
5709
5696
  }
5710
5697
  }
5711
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5698
+ else if (hasSetupBinding(setupState, key)) {
5712
5699
  accessCache[key] = 1 /* AccessTypes.SETUP */;
5713
5700
  return setupState[key];
5714
5701
  }
@@ -5787,21 +5774,26 @@ var Vue = (function () {
5787
5774
  },
5788
5775
  set({ _: instance }, key, value) {
5789
5776
  const { data, setupState, ctx } = instance;
5790
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5777
+ if (hasSetupBinding(setupState, key)) {
5791
5778
  setupState[key] = value;
5792
5779
  return true;
5793
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
+ }
5794
5786
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
5795
5787
  data[key] = value;
5796
5788
  return true;
5797
5789
  }
5798
5790
  else if (hasOwn(instance.props, key)) {
5799
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
5791
+ warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
5800
5792
  return false;
5801
5793
  }
5802
5794
  if (key[0] === '$' && key.slice(1) in instance) {
5803
5795
  warn$1(`Attempting to mutate public property "${key}". ` +
5804
- `Properties starting with $ are reserved and readonly.`, instance);
5796
+ `Properties starting with $ are reserved and readonly.`);
5805
5797
  return false;
5806
5798
  }
5807
5799
  else {
@@ -5822,7 +5814,7 @@ var Vue = (function () {
5822
5814
  let normalizedProps;
5823
5815
  return (!!accessCache[key] ||
5824
5816
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
5825
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
5817
+ hasSetupBinding(setupState, key) ||
5826
5818
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
5827
5819
  hasOwn(ctx, key) ||
5828
5820
  hasOwn(publicPropertiesMap, key) ||
@@ -7097,7 +7089,7 @@ var Vue = (function () {
7097
7089
  return vm;
7098
7090
  }
7099
7091
  }
7100
- Vue.version = `2.6.14-compat:${"3.2.44"}`;
7092
+ Vue.version = `2.6.14-compat:${"3.2.45"}`;
7101
7093
  Vue.config = singletonApp.config;
7102
7094
  Vue.use = (p, ...options) => {
7103
7095
  if (p && isFunction(p.install)) {
@@ -9484,6 +9476,10 @@ var Vue = (function () {
9484
9476
  if (!shallow)
9485
9477
  traverseStaticChildren(c1, c2);
9486
9478
  }
9479
+ // #6852 also inherit for text nodes
9480
+ if (c2.type === Text) {
9481
+ c2.el = c1.el;
9482
+ }
9487
9483
  // also inherit for comment nodes, but not placeholders (e.g. v-if which
9488
9484
  // would have received .el during block patch)
9489
9485
  if (c2.type === Comment && !c2.el) {
@@ -9654,6 +9650,7 @@ var Vue = (function () {
9654
9650
  }
9655
9651
  }
9656
9652
  }
9653
+ updateCssVars(n2);
9657
9654
  },
9658
9655
  remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
9659
9656
  const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
@@ -9732,11 +9729,26 @@ var Vue = (function () {
9732
9729
  hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
9733
9730
  }
9734
9731
  }
9732
+ updateCssVars(vnode);
9735
9733
  }
9736
9734
  return vnode.anchor && nextSibling(vnode.anchor);
9737
9735
  }
9738
9736
  // Force-casted public typing for h and TSX props inference
9739
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
+ }
9740
9752
 
9741
9753
  const normalizedAsyncComponentMap = new Map();
9742
9754
  function convertLegacyAsyncComponent(comp) {
@@ -9891,6 +9903,10 @@ var Vue = (function () {
9891
9903
  function isSameVNodeType(n1, n2) {
9892
9904
  if (n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
9893
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 */;
9894
9910
  // HMR only: if the component has been hot-updated, force a reload.
9895
9911
  return false;
9896
9912
  }
@@ -9946,7 +9962,8 @@ var Vue = (function () {
9946
9962
  patchFlag,
9947
9963
  dynamicProps,
9948
9964
  dynamicChildren: null,
9949
- appContext: null
9965
+ appContext: null,
9966
+ ctx: currentRenderingInstance
9950
9967
  };
9951
9968
  if (needFullChildrenNormalization) {
9952
9969
  normalizeChildren(vnode, children);
@@ -10121,7 +10138,8 @@ var Vue = (function () {
10121
10138
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
10122
10139
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
10123
10140
  el: vnode.el,
10124
- anchor: vnode.anchor
10141
+ anchor: vnode.anchor,
10142
+ ctx: vnode.ctx
10125
10143
  };
10126
10144
  {
10127
10145
  defineLegacyVNodeProperties(cloned);
@@ -11104,7 +11122,7 @@ var Vue = (function () {
11104
11122
  }
11105
11123
 
11106
11124
  // Core API ------------------------------------------------------------------
11107
- const version = "3.2.44";
11125
+ const version = "3.2.45";
11108
11126
  /**
11109
11127
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
11110
11128
  * @internal
@@ -11638,12 +11656,21 @@ var Vue = (function () {
11638
11656
  `defined as hydratable. Use \`defineSSRCustomElement\`.`);
11639
11657
  }
11640
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
+ }
11641
11663
  }
11642
11664
  }
11643
11665
  connectedCallback() {
11644
11666
  this._connected = true;
11645
11667
  if (!this._instance) {
11646
- this._resolveDef();
11668
+ if (this._resolved) {
11669
+ this._update();
11670
+ }
11671
+ else {
11672
+ this._resolveDef();
11673
+ }
11647
11674
  }
11648
11675
  }
11649
11676
  disconnectedCallback() {
@@ -11659,9 +11686,6 @@ var Vue = (function () {
11659
11686
  * resolve inner component definition (handle possible async component)
11660
11687
  */
11661
11688
  _resolveDef() {
11662
- if (this._resolved) {
11663
- return;
11664
- }
11665
11689
  this._resolved = true;
11666
11690
  // set initial attrs
11667
11691
  for (let i = 0; i < this.attributes.length; i++) {
@@ -11673,38 +11697,26 @@ var Vue = (function () {
11673
11697
  this._setAttr(m.attributeName);
11674
11698
  }
11675
11699
  }).observe(this, { attributes: true });
11676
- const resolve = (def) => {
11677
- const { props = {}, styles } = def;
11678
- const hasOptions = !isArray(props);
11679
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11700
+ const resolve = (def, isAsync = false) => {
11701
+ const { props, styles } = def;
11680
11702
  // cast Number-type props set before resolve
11681
11703
  let numberProps;
11682
- if (hasOptions) {
11683
- for (const key in this._props) {
11704
+ if (props && !isArray(props)) {
11705
+ for (const key in props) {
11684
11706
  const opt = props[key];
11685
11707
  if (opt === Number || (opt && opt.type === Number)) {
11686
- this._props[key] = toNumber(this._props[key]);
11687
- (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;
11688
11712
  }
11689
11713
  }
11690
11714
  }
11691
11715
  this._numberProps = numberProps;
11692
- // check if there are props set pre-upgrade or connect
11693
- for (const key of Object.keys(this)) {
11694
- if (key[0] !== '_') {
11695
- this._setProp(key, this[key], true, false);
11696
- }
11697
- }
11698
- // defining getter/setters on prototype
11699
- for (const key of rawKeys.map(camelize)) {
11700
- Object.defineProperty(this, key, {
11701
- get() {
11702
- return this._getProp(key);
11703
- },
11704
- set(val) {
11705
- this._setProp(key, val);
11706
- }
11707
- });
11716
+ if (isAsync) {
11717
+ // defining getter/setters on prototype
11718
+ // for sync defs, this already happened in the constructor
11719
+ this._resolveProps(def);
11708
11720
  }
11709
11721
  // apply CSS
11710
11722
  this._applyStyles(styles);
@@ -11713,12 +11725,33 @@ var Vue = (function () {
11713
11725
  };
11714
11726
  const asyncDef = this._def.__asyncLoader;
11715
11727
  if (asyncDef) {
11716
- asyncDef().then(resolve);
11728
+ asyncDef().then(def => resolve(def, true));
11717
11729
  }
11718
11730
  else {
11719
11731
  resolve(this._def);
11720
11732
  }
11721
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
+ }
11722
11755
  _setAttr(key) {
11723
11756
  let value = this.getAttribute(key);
11724
11757
  const camelKey = camelize(key);
@@ -11774,27 +11807,31 @@ var Vue = (function () {
11774
11807
  this._styles.length = 0;
11775
11808
  }
11776
11809
  this._applyStyles(newStyles);
11777
- // if this is an async component, ceReload is called from the inner
11778
- // component so no need to reload the async wrapper
11779
- if (!this._def.__asyncLoader) {
11780
- // reload
11781
- this._instance = null;
11782
- this._update();
11783
- }
11810
+ this._instance = null;
11811
+ this._update();
11784
11812
  };
11785
11813
  }
11786
- // intercept emit
11787
- instance.emit = (event, ...args) => {
11814
+ const dispatch = (event, args) => {
11788
11815
  this.dispatchEvent(new CustomEvent(event, {
11789
11816
  detail: args
11790
11817
  }));
11791
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
+ };
11792
11828
  // locate nearest Vue custom element parent for provide/inject
11793
11829
  let parent = this;
11794
11830
  while ((parent =
11795
11831
  parent && (parent.parentNode || parent.host))) {
11796
11832
  if (parent instanceof VueElement) {
11797
11833
  instance.parent = parent._instance;
11834
+ instance.provides = parent._instance.provides;
11798
11835
  break;
11799
11836
  }
11800
11837
  }
@@ -11838,7 +11875,14 @@ var Vue = (function () {
11838
11875
  warn$1(`useCssVars is called without current active component instance.`);
11839
11876
  return;
11840
11877
  }
11841
- 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
+ };
11842
11886
  watchPostEffect(setVars);
11843
11887
  onMounted(() => {
11844
11888
  const ob = new MutationObserver(setVars);