@vue/runtime-dom 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.
@@ -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
@@ -3272,10 +3266,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3272
3266
  callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
3273
3267
  newValue,
3274
3268
  // pass undefined as the old value when it's changed for the first time
3275
- oldValue === INITIAL_WATCHER_VALUE ||
3276
- (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3277
- ? []
3278
- : oldValue,
3269
+ oldValue === INITIAL_WATCHER_VALUE
3270
+ ? undefined
3271
+ : (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3272
+ ? []
3273
+ : oldValue,
3279
3274
  onCleanup
3280
3275
  ]);
3281
3276
  oldValue = newValue;
@@ -3872,10 +3867,15 @@ function defineAsyncComponent(source) {
3872
3867
  }
3873
3868
  });
3874
3869
  }
3875
- function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
3870
+ function createInnerComp(comp, parent) {
3871
+ const { ref, props, children, ce } = parent.vnode;
3876
3872
  const vnode = createVNode(comp, props, children);
3877
3873
  // ensure inner component inherits the async wrapper's ref owner
3878
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;
3879
3879
  return vnode;
3880
3880
  }
3881
3881
 
@@ -4033,8 +4033,7 @@ const KeepAliveImpl = {
4033
4033
  : comp);
4034
4034
  const { include, exclude, max } = props;
4035
4035
  if ((include && (!name || !matches(include, name))) ||
4036
- (exclude && name && matches(exclude, name)) ||
4037
- (hmrDirtyComponents.has(comp))) {
4036
+ (exclude && name && matches(exclude, name))) {
4038
4037
  current = vnode;
4039
4038
  return rawVNode;
4040
4039
  }
@@ -4144,14 +4143,9 @@ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
4144
4143
  }, target);
4145
4144
  }
4146
4145
  function resetShapeFlag(vnode) {
4147
- let shapeFlag = vnode.shapeFlag;
4148
- if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
4149
- shapeFlag -= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4150
- }
4151
- if (shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
4152
- shapeFlag -= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4153
- }
4154
- 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 */;
4155
4149
  }
4156
4150
  function getInnerChild(vnode) {
4157
4151
  return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
@@ -4450,7 +4444,9 @@ fallback, noSlotted) {
4450
4444
  (currentRenderingInstance.parent &&
4451
4445
  isAsyncWrapper(currentRenderingInstance.parent) &&
4452
4446
  currentRenderingInstance.parent.isCE)) {
4453
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
4447
+ if (name !== 'default')
4448
+ props.name = name;
4449
+ return createVNode('slot', props, fallback && fallback());
4454
4450
  }
4455
4451
  let slot = slots[name];
4456
4452
  if (slot && slot.length > 1) {
@@ -4550,6 +4546,7 @@ const publicPropertiesMap =
4550
4546
  $watch: i => (instanceWatch.bind(i) )
4551
4547
  });
4552
4548
  const isReservedPrefix = (key) => key === '_' || key === '$';
4549
+ const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
4553
4550
  const PublicInstanceProxyHandlers = {
4554
4551
  get({ _: instance }, key) {
4555
4552
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
@@ -4557,15 +4554,6 @@ const PublicInstanceProxyHandlers = {
4557
4554
  if (key === '__isVue') {
4558
4555
  return true;
4559
4556
  }
4560
- // prioritize <script setup> bindings during dev.
4561
- // this allows even properties that start with _ or $ to be used - so that
4562
- // it aligns with the production behavior where the render fn is inlined and
4563
- // indeed has access to all declared variables.
4564
- if (setupState !== EMPTY_OBJ &&
4565
- setupState.__isScriptSetup &&
4566
- hasOwn(setupState, key)) {
4567
- return setupState[key];
4568
- }
4569
4557
  // data / props / ctx
4570
4558
  // This getter gets called for every property access on the render context
4571
4559
  // during render and is a major hotspot. The most expensive part of this
@@ -4588,7 +4576,7 @@ const PublicInstanceProxyHandlers = {
4588
4576
  // default: just fallthrough
4589
4577
  }
4590
4578
  }
4591
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4579
+ else if (hasSetupBinding(setupState, key)) {
4592
4580
  accessCache[key] = 1 /* AccessTypes.SETUP */;
4593
4581
  return setupState[key];
4594
4582
  }
@@ -4658,21 +4646,26 @@ const PublicInstanceProxyHandlers = {
4658
4646
  },
4659
4647
  set({ _: instance }, key, value) {
4660
4648
  const { data, setupState, ctx } = instance;
4661
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
4649
+ if (hasSetupBinding(setupState, key)) {
4662
4650
  setupState[key] = value;
4663
4651
  return true;
4664
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
+ }
4665
4658
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
4666
4659
  data[key] = value;
4667
4660
  return true;
4668
4661
  }
4669
4662
  else if (hasOwn(instance.props, key)) {
4670
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
4663
+ warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
4671
4664
  return false;
4672
4665
  }
4673
4666
  if (key[0] === '$' && key.slice(1) in instance) {
4674
4667
  warn$1(`Attempting to mutate public property "${key}". ` +
4675
- `Properties starting with $ are reserved and readonly.`, instance);
4668
+ `Properties starting with $ are reserved and readonly.`);
4676
4669
  return false;
4677
4670
  }
4678
4671
  else {
@@ -4693,7 +4686,7 @@ const PublicInstanceProxyHandlers = {
4693
4686
  let normalizedProps;
4694
4687
  return (!!accessCache[key] ||
4695
4688
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
4696
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
4689
+ hasSetupBinding(setupState, key) ||
4697
4690
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
4698
4691
  hasOwn(ctx, key) ||
4699
4692
  hasOwn(publicPropertiesMap, key) ||
@@ -7732,6 +7725,10 @@ function traverseStaticChildren(n1, n2, shallow = false) {
7732
7725
  if (!shallow)
7733
7726
  traverseStaticChildren(c1, c2);
7734
7727
  }
7728
+ // #6852 also inherit for text nodes
7729
+ if (c2.type === Text) {
7730
+ c2.el = c1.el;
7731
+ }
7735
7732
  // also inherit for comment nodes, but not placeholders (e.g. v-if which
7736
7733
  // would have received .el during block patch)
7737
7734
  if (c2.type === Comment && !c2.el) {
@@ -7902,6 +7899,7 @@ const TeleportImpl = {
7902
7899
  }
7903
7900
  }
7904
7901
  }
7902
+ updateCssVars(n2);
7905
7903
  },
7906
7904
  remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
7907
7905
  const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
@@ -7980,11 +7978,26 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
7980
7978
  hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
7981
7979
  }
7982
7980
  }
7981
+ updateCssVars(vnode);
7983
7982
  }
7984
7983
  return vnode.anchor && nextSibling(vnode.anchor);
7985
7984
  }
7986
7985
  // Force-casted public typing for h and TSX props inference
7987
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
+ }
7988
8001
 
7989
8002
  const Fragment = Symbol('Fragment' );
7990
8003
  const Text = Symbol('Text' );
@@ -8079,6 +8092,10 @@ function isVNode(value) {
8079
8092
  function isSameVNodeType(n1, n2) {
8080
8093
  if (n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
8081
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 */;
8082
8099
  // HMR only: if the component has been hot-updated, force a reload.
8083
8100
  return false;
8084
8101
  }
@@ -8134,7 +8151,8 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
8134
8151
  patchFlag,
8135
8152
  dynamicProps,
8136
8153
  dynamicChildren: null,
8137
- appContext: null
8154
+ appContext: null,
8155
+ ctx: currentRenderingInstance
8138
8156
  };
8139
8157
  if (needFullChildrenNormalization) {
8140
8158
  normalizeChildren(vnode, children);
@@ -8301,7 +8319,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
8301
8319
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
8302
8320
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
8303
8321
  el: vnode.el,
8304
- anchor: vnode.anchor
8322
+ anchor: vnode.anchor,
8323
+ ctx: vnode.ctx
8305
8324
  };
8306
8325
  return cloned;
8307
8326
  }
@@ -9270,7 +9289,7 @@ function isMemoSame(cached, memo) {
9270
9289
  }
9271
9290
 
9272
9291
  // Core API ------------------------------------------------------------------
9273
- const version = "3.2.43";
9292
+ const version = "3.2.45";
9274
9293
  /**
9275
9294
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
9276
9295
  * @internal
@@ -9416,6 +9435,7 @@ function patchStyle(el, prev, next) {
9416
9435
  }
9417
9436
  }
9418
9437
  }
9438
+ const semicolonRE = /[^\\];\s*$/;
9419
9439
  const importantRE = /\s*!important$/;
9420
9440
  function setStyle(style, name, val) {
9421
9441
  if (isArray(val)) {
@@ -9424,6 +9444,11 @@ function setStyle(style, name, val) {
9424
9444
  else {
9425
9445
  if (val == null)
9426
9446
  val = '';
9447
+ {
9448
+ if (semicolonRE.test(val)) {
9449
+ warn$1(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
9450
+ }
9451
+ }
9427
9452
  if (name.startsWith('--')) {
9428
9453
  // custom property definition
9429
9454
  style.setProperty(name, val);
@@ -9753,12 +9778,21 @@ class VueElement extends BaseClass {
9753
9778
  `defined as hydratable. Use \`defineSSRCustomElement\`.`);
9754
9779
  }
9755
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
+ }
9756
9785
  }
9757
9786
  }
9758
9787
  connectedCallback() {
9759
9788
  this._connected = true;
9760
9789
  if (!this._instance) {
9761
- this._resolveDef();
9790
+ if (this._resolved) {
9791
+ this._update();
9792
+ }
9793
+ else {
9794
+ this._resolveDef();
9795
+ }
9762
9796
  }
9763
9797
  }
9764
9798
  disconnectedCallback() {
@@ -9774,9 +9808,6 @@ class VueElement extends BaseClass {
9774
9808
  * resolve inner component definition (handle possible async component)
9775
9809
  */
9776
9810
  _resolveDef() {
9777
- if (this._resolved) {
9778
- return;
9779
- }
9780
9811
  this._resolved = true;
9781
9812
  // set initial attrs
9782
9813
  for (let i = 0; i < this.attributes.length; i++) {
@@ -9788,38 +9819,26 @@ class VueElement extends BaseClass {
9788
9819
  this._setAttr(m.attributeName);
9789
9820
  }
9790
9821
  }).observe(this, { attributes: true });
9791
- const resolve = (def) => {
9792
- const { props = {}, styles } = def;
9793
- const hasOptions = !isArray(props);
9794
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
9822
+ const resolve = (def, isAsync = false) => {
9823
+ const { props, styles } = def;
9795
9824
  // cast Number-type props set before resolve
9796
9825
  let numberProps;
9797
- if (hasOptions) {
9798
- for (const key in this._props) {
9826
+ if (props && !isArray(props)) {
9827
+ for (const key in props) {
9799
9828
  const opt = props[key];
9800
9829
  if (opt === Number || (opt && opt.type === Number)) {
9801
- this._props[key] = toNumber(this._props[key]);
9802
- (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;
9803
9834
  }
9804
9835
  }
9805
9836
  }
9806
9837
  this._numberProps = numberProps;
9807
- // check if there are props set pre-upgrade or connect
9808
- for (const key of Object.keys(this)) {
9809
- if (key[0] !== '_') {
9810
- this._setProp(key, this[key], true, false);
9811
- }
9812
- }
9813
- // defining getter/setters on prototype
9814
- for (const key of rawKeys.map(camelize)) {
9815
- Object.defineProperty(this, key, {
9816
- get() {
9817
- return this._getProp(key);
9818
- },
9819
- set(val) {
9820
- this._setProp(key, val);
9821
- }
9822
- });
9838
+ if (isAsync) {
9839
+ // defining getter/setters on prototype
9840
+ // for sync defs, this already happened in the constructor
9841
+ this._resolveProps(def);
9823
9842
  }
9824
9843
  // apply CSS
9825
9844
  this._applyStyles(styles);
@@ -9828,12 +9847,33 @@ class VueElement extends BaseClass {
9828
9847
  };
9829
9848
  const asyncDef = this._def.__asyncLoader;
9830
9849
  if (asyncDef) {
9831
- asyncDef().then(resolve);
9850
+ asyncDef().then(def => resolve(def, true));
9832
9851
  }
9833
9852
  else {
9834
9853
  resolve(this._def);
9835
9854
  }
9836
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
+ }
9837
9877
  _setAttr(key) {
9838
9878
  let value = this.getAttribute(key);
9839
9879
  const camelKey = camelize(key);
@@ -9889,27 +9929,31 @@ class VueElement extends BaseClass {
9889
9929
  this._styles.length = 0;
9890
9930
  }
9891
9931
  this._applyStyles(newStyles);
9892
- // if this is an async component, ceReload is called from the inner
9893
- // component so no need to reload the async wrapper
9894
- if (!this._def.__asyncLoader) {
9895
- // reload
9896
- this._instance = null;
9897
- this._update();
9898
- }
9932
+ this._instance = null;
9933
+ this._update();
9899
9934
  };
9900
9935
  }
9901
- // intercept emit
9902
- instance.emit = (event, ...args) => {
9936
+ const dispatch = (event, args) => {
9903
9937
  this.dispatchEvent(new CustomEvent(event, {
9904
9938
  detail: args
9905
9939
  }));
9906
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
+ };
9907
9950
  // locate nearest Vue custom element parent for provide/inject
9908
9951
  let parent = this;
9909
9952
  while ((parent =
9910
9953
  parent && (parent.parentNode || parent.host))) {
9911
9954
  if (parent instanceof VueElement) {
9912
9955
  instance.parent = parent._instance;
9956
+ instance.provides = parent._instance.provides;
9913
9957
  break;
9914
9958
  }
9915
9959
  }
@@ -9965,7 +10009,14 @@ function useCssVars(getter) {
9965
10009
  warn$1(`useCssVars is called without current active component instance.`);
9966
10010
  return;
9967
10011
  }
9968
- 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
+ };
9969
10020
  watchPostEffect(setVars);
9970
10021
  onMounted(() => {
9971
10022
  const ob = new MutationObserver(setVars);