@vue/runtime-dom 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
@@ -3873,10 +3867,15 @@ function defineAsyncComponent(source) {
3873
3867
  }
3874
3868
  });
3875
3869
  }
3876
- function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
3870
+ function createInnerComp(comp, parent) {
3871
+ const { ref, props, children, ce } = parent.vnode;
3877
3872
  const vnode = createVNode(comp, props, children);
3878
3873
  // ensure inner component inherits the async wrapper's ref owner
3879
3874
  vnode.ref = ref;
3875
+ // pass the custom element callback on to the inner comp
3876
+ // and remove it from the async wrapper
3877
+ vnode.ce = ce;
3878
+ delete parent.vnode.ce;
3880
3879
  return vnode;
3881
3880
  }
3882
3881
 
@@ -4034,8 +4033,7 @@ const KeepAliveImpl = {
4034
4033
  : comp);
4035
4034
  const { include, exclude, max } = props;
4036
4035
  if ((include && (!name || !matches(include, name))) ||
4037
- (exclude && name && matches(exclude, name)) ||
4038
- (hmrDirtyComponents.has(comp))) {
4036
+ (exclude && name && matches(exclude, name))) {
4039
4037
  current = vnode;
4040
4038
  return rawVNode;
4041
4039
  }
@@ -4145,14 +4143,9 @@ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
4145
4143
  }, target);
4146
4144
  }
4147
4145
  function resetShapeFlag(vnode) {
4148
- let shapeFlag = vnode.shapeFlag;
4149
- if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
4150
- shapeFlag -= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4151
- }
4152
- if (shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
4153
- shapeFlag -= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4154
- }
4155
- vnode.shapeFlag = shapeFlag;
4146
+ // bitwise operations to remove keep alive flags
4147
+ vnode.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4148
+ vnode.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4156
4149
  }
4157
4150
  function getInnerChild(vnode) {
4158
4151
  return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
@@ -4451,7 +4444,9 @@ fallback, noSlotted) {
4451
4444
  (currentRenderingInstance.parent &&
4452
4445
  isAsyncWrapper(currentRenderingInstance.parent) &&
4453
4446
  currentRenderingInstance.parent.isCE)) {
4454
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
4447
+ if (name !== 'default')
4448
+ props.name = name;
4449
+ return createVNode('slot', props, fallback && fallback());
4455
4450
  }
4456
4451
  let slot = slots[name];
4457
4452
  if (slot && slot.length > 1) {
@@ -4551,6 +4546,7 @@ const publicPropertiesMap =
4551
4546
  $watch: i => (instanceWatch.bind(i) )
4552
4547
  });
4553
4548
  const isReservedPrefix = (key) => key === '_' || key === '$';
4549
+ const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
4554
4550
  const PublicInstanceProxyHandlers = {
4555
4551
  get({ _: instance }, key) {
4556
4552
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
@@ -4558,15 +4554,6 @@ const PublicInstanceProxyHandlers = {
4558
4554
  if (key === '__isVue') {
4559
4555
  return true;
4560
4556
  }
4561
- // prioritize <script setup> bindings during dev.
4562
- // this allows even properties that start with _ or $ to be used - so that
4563
- // it aligns with the production behavior where the render fn is inlined and
4564
- // indeed has access to all declared variables.
4565
- if (setupState !== EMPTY_OBJ &&
4566
- setupState.__isScriptSetup &&
4567
- hasOwn(setupState, key)) {
4568
- return setupState[key];
4569
- }
4570
4557
  // data / props / ctx
4571
4558
  // This getter gets called for every property access on the render context
4572
4559
  // during render and is a major hotspot. The most expensive part of this
@@ -4589,7 +4576,7 @@ const PublicInstanceProxyHandlers = {
4589
4576
  // default: just fallthrough
4590
4577
  }
4591
4578
  }
4592
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4579
+ else if (hasSetupBinding(setupState, key)) {
4593
4580
  accessCache[key] = 1 /* AccessTypes.SETUP */;
4594
4581
  return setupState[key];
4595
4582
  }
@@ -4659,21 +4646,26 @@ const PublicInstanceProxyHandlers = {
4659
4646
  },
4660
4647
  set({ _: instance }, key, value) {
4661
4648
  const { data, setupState, ctx } = instance;
4662
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4649
+ if (hasSetupBinding(setupState, key)) {
4663
4650
  setupState[key] = value;
4664
4651
  return true;
4665
4652
  }
4653
+ else if (setupState.__isScriptSetup &&
4654
+ hasOwn(setupState, key)) {
4655
+ warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
4656
+ return false;
4657
+ }
4666
4658
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4667
4659
  data[key] = value;
4668
4660
  return true;
4669
4661
  }
4670
4662
  else if (hasOwn(instance.props, key)) {
4671
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
4663
+ warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
4672
4664
  return false;
4673
4665
  }
4674
4666
  if (key[0] === '$' && key.slice(1) in instance) {
4675
4667
  warn$1(`Attempting to mutate public property "${key}". ` +
4676
- `Properties starting with $ are reserved and readonly.`, instance);
4668
+ `Properties starting with $ are reserved and readonly.`);
4677
4669
  return false;
4678
4670
  }
4679
4671
  else {
@@ -4694,7 +4686,7 @@ const PublicInstanceProxyHandlers = {
4694
4686
  let normalizedProps;
4695
4687
  return (!!accessCache[key] ||
4696
4688
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
4697
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
4689
+ hasSetupBinding(setupState, key) ||
4698
4690
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
4699
4691
  hasOwn(ctx, key) ||
4700
4692
  hasOwn(publicPropertiesMap, key) ||
@@ -7733,6 +7725,10 @@ function traverseStaticChildren(n1, n2, shallow = false) {
7733
7725
  if (!shallow)
7734
7726
  traverseStaticChildren(c1, c2);
7735
7727
  }
7728
+ // #6852 also inherit for text nodes
7729
+ if (c2.type === Text) {
7730
+ c2.el = c1.el;
7731
+ }
7736
7732
  // also inherit for comment nodes, but not placeholders (e.g. v-if which
7737
7733
  // would have received .el during block patch)
7738
7734
  if (c2.type === Comment && !c2.el) {
@@ -7903,6 +7899,7 @@ const TeleportImpl = {
7903
7899
  }
7904
7900
  }
7905
7901
  }
7902
+ updateCssVars(n2);
7906
7903
  },
7907
7904
  remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
7908
7905
  const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
@@ -7981,11 +7978,26 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
7981
7978
  hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
7982
7979
  }
7983
7980
  }
7981
+ updateCssVars(vnode);
7984
7982
  }
7985
7983
  return vnode.anchor && nextSibling(vnode.anchor);
7986
7984
  }
7987
7985
  // Force-casted public typing for h and TSX props inference
7988
7986
  const Teleport = TeleportImpl;
7987
+ function updateCssVars(vnode) {
7988
+ // presence of .ut method indicates owner component uses css vars.
7989
+ // code path here can assume browser environment.
7990
+ const ctx = vnode.ctx;
7991
+ if (ctx && ctx.ut) {
7992
+ let node = vnode.children[0].el;
7993
+ while (node !== vnode.targetAnchor) {
7994
+ if (node.nodeType === 1)
7995
+ node.setAttribute('data-v-owner', ctx.uid);
7996
+ node = node.nextSibling;
7997
+ }
7998
+ ctx.ut();
7999
+ }
8000
+ }
7989
8001
 
7990
8002
  const Fragment = Symbol('Fragment' );
7991
8003
  const Text = Symbol('Text' );
@@ -8080,6 +8092,10 @@ function isVNode(value) {
8080
8092
  function isSameVNodeType(n1, n2) {
8081
8093
  if (n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
8082
8094
  hmrDirtyComponents.has(n2.type)) {
8095
+ // #7042, ensure the vnode being unmounted during HMR
8096
+ // bitwise operations to remove keep alive flags
8097
+ n1.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
8098
+ n2.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
8083
8099
  // HMR only: if the component has been hot-updated, force a reload.
8084
8100
  return false;
8085
8101
  }
@@ -8135,7 +8151,8 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
8135
8151
  patchFlag,
8136
8152
  dynamicProps,
8137
8153
  dynamicChildren: null,
8138
- appContext: null
8154
+ appContext: null,
8155
+ ctx: currentRenderingInstance
8139
8156
  };
8140
8157
  if (needFullChildrenNormalization) {
8141
8158
  normalizeChildren(vnode, children);
@@ -8302,7 +8319,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
8302
8319
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
8303
8320
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
8304
8321
  el: vnode.el,
8305
- anchor: vnode.anchor
8322
+ anchor: vnode.anchor,
8323
+ ctx: vnode.ctx
8306
8324
  };
8307
8325
  return cloned;
8308
8326
  }
@@ -9271,7 +9289,7 @@ function isMemoSame(cached, memo) {
9271
9289
  }
9272
9290
 
9273
9291
  // Core API ------------------------------------------------------------------
9274
- const version = "3.2.44";
9292
+ const version = "3.2.45";
9275
9293
  /**
9276
9294
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
9277
9295
  * @internal
@@ -9760,12 +9778,21 @@ class VueElement extends BaseClass {
9760
9778
  `defined as hydratable. Use \`defineSSRCustomElement\`.`);
9761
9779
  }
9762
9780
  this.attachShadow({ mode: 'open' });
9781
+ if (!this._def.__asyncLoader) {
9782
+ // for sync component defs we can immediately resolve props
9783
+ this._resolveProps(this._def);
9784
+ }
9763
9785
  }
9764
9786
  }
9765
9787
  connectedCallback() {
9766
9788
  this._connected = true;
9767
9789
  if (!this._instance) {
9768
- this._resolveDef();
9790
+ if (this._resolved) {
9791
+ this._update();
9792
+ }
9793
+ else {
9794
+ this._resolveDef();
9795
+ }
9769
9796
  }
9770
9797
  }
9771
9798
  disconnectedCallback() {
@@ -9781,9 +9808,6 @@ class VueElement extends BaseClass {
9781
9808
  * resolve inner component definition (handle possible async component)
9782
9809
  */
9783
9810
  _resolveDef() {
9784
- if (this._resolved) {
9785
- return;
9786
- }
9787
9811
  this._resolved = true;
9788
9812
  // set initial attrs
9789
9813
  for (let i = 0; i < this.attributes.length; i++) {
@@ -9795,38 +9819,26 @@ class VueElement extends BaseClass {
9795
9819
  this._setAttr(m.attributeName);
9796
9820
  }
9797
9821
  }).observe(this, { attributes: true });
9798
- const resolve = (def) => {
9799
- const { props = {}, styles } = def;
9800
- const hasOptions = !isArray(props);
9801
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
9822
+ const resolve = (def, isAsync = false) => {
9823
+ const { props, styles } = def;
9802
9824
  // cast Number-type props set before resolve
9803
9825
  let numberProps;
9804
- if (hasOptions) {
9805
- for (const key in this._props) {
9826
+ if (props && !isArray(props)) {
9827
+ for (const key in props) {
9806
9828
  const opt = props[key];
9807
9829
  if (opt === Number || (opt && opt.type === Number)) {
9808
- this._props[key] = toNumber(this._props[key]);
9809
- (numberProps || (numberProps = Object.create(null)))[key] = true;
9830
+ if (key in this._props) {
9831
+ this._props[key] = toNumber(this._props[key]);
9832
+ }
9833
+ (numberProps || (numberProps = Object.create(null)))[camelize(key)] = true;
9810
9834
  }
9811
9835
  }
9812
9836
  }
9813
9837
  this._numberProps = numberProps;
9814
- // check if there are props set pre-upgrade or connect
9815
- for (const key of Object.keys(this)) {
9816
- if (key[0] !== '_') {
9817
- this._setProp(key, this[key], true, false);
9818
- }
9819
- }
9820
- // defining getter/setters on prototype
9821
- for (const key of rawKeys.map(camelize)) {
9822
- Object.defineProperty(this, key, {
9823
- get() {
9824
- return this._getProp(key);
9825
- },
9826
- set(val) {
9827
- this._setProp(key, val);
9828
- }
9829
- });
9838
+ if (isAsync) {
9839
+ // defining getter/setters on prototype
9840
+ // for sync defs, this already happened in the constructor
9841
+ this._resolveProps(def);
9830
9842
  }
9831
9843
  // apply CSS
9832
9844
  this._applyStyles(styles);
@@ -9835,12 +9847,33 @@ class VueElement extends BaseClass {
9835
9847
  };
9836
9848
  const asyncDef = this._def.__asyncLoader;
9837
9849
  if (asyncDef) {
9838
- asyncDef().then(resolve);
9850
+ asyncDef().then(def => resolve(def, true));
9839
9851
  }
9840
9852
  else {
9841
9853
  resolve(this._def);
9842
9854
  }
9843
9855
  }
9856
+ _resolveProps(def) {
9857
+ const { props } = def;
9858
+ const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
9859
+ // check if there are props set pre-upgrade or connect
9860
+ for (const key of Object.keys(this)) {
9861
+ if (key[0] !== '_' && declaredPropKeys.includes(key)) {
9862
+ this._setProp(key, this[key], true, false);
9863
+ }
9864
+ }
9865
+ // defining getter/setters on prototype
9866
+ for (const key of declaredPropKeys.map(camelize)) {
9867
+ Object.defineProperty(this, key, {
9868
+ get() {
9869
+ return this._getProp(key);
9870
+ },
9871
+ set(val) {
9872
+ this._setProp(key, val);
9873
+ }
9874
+ });
9875
+ }
9876
+ }
9844
9877
  _setAttr(key) {
9845
9878
  let value = this.getAttribute(key);
9846
9879
  const camelKey = camelize(key);
@@ -9896,27 +9929,31 @@ class VueElement extends BaseClass {
9896
9929
  this._styles.length = 0;
9897
9930
  }
9898
9931
  this._applyStyles(newStyles);
9899
- // if this is an async component, ceReload is called from the inner
9900
- // component so no need to reload the async wrapper
9901
- if (!this._def.__asyncLoader) {
9902
- // reload
9903
- this._instance = null;
9904
- this._update();
9905
- }
9932
+ this._instance = null;
9933
+ this._update();
9906
9934
  };
9907
9935
  }
9908
- // intercept emit
9909
- instance.emit = (event, ...args) => {
9936
+ const dispatch = (event, args) => {
9910
9937
  this.dispatchEvent(new CustomEvent(event, {
9911
9938
  detail: args
9912
9939
  }));
9913
9940
  };
9941
+ // intercept emit
9942
+ instance.emit = (event, ...args) => {
9943
+ // dispatch both the raw and hyphenated versions of an event
9944
+ // to match Vue behavior
9945
+ dispatch(event, args);
9946
+ if (hyphenate(event) !== event) {
9947
+ dispatch(hyphenate(event), args);
9948
+ }
9949
+ };
9914
9950
  // locate nearest Vue custom element parent for provide/inject
9915
9951
  let parent = this;
9916
9952
  while ((parent =
9917
9953
  parent && (parent.parentNode || parent.host))) {
9918
9954
  if (parent instanceof VueElement) {
9919
9955
  instance.parent = parent._instance;
9956
+ instance.provides = parent._instance.provides;
9920
9957
  break;
9921
9958
  }
9922
9959
  }
@@ -9972,7 +10009,14 @@ function useCssVars(getter) {
9972
10009
  warn$1(`useCssVars is called without current active component instance.`);
9973
10010
  return;
9974
10011
  }
9975
- const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
10012
+ const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
10013
+ Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach(node => setVarsOnNode(node, vars));
10014
+ });
10015
+ const setVars = () => {
10016
+ const vars = getter(instance.proxy);
10017
+ setVarsOnVNode(instance.subTree, vars);
10018
+ updateTeleports(vars);
10019
+ };
9976
10020
  watchPostEffect(setVars);
9977
10021
  onMounted(() => {
9978
10022
  const ob = new MutationObserver(setVars);