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