@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.
@@ -2044,12 +2044,6 @@ function reload(id, newComp) {
2044
2044
  // components to be unmounted and re-mounted. Queue the update so that we
2045
2045
  // don't end up forcing the same parent to re-render multiple times.
2046
2046
  queueJob(instance.parent.update);
2047
- // instance is the inner component of an async custom element
2048
- // invoke to reset styles
2049
- if (instance.parent.type.__asyncLoader &&
2050
- instance.parent.ceReload) {
2051
- instance.parent.ceReload(newComp.styles);
2052
- }
2053
2047
  }
2054
2048
  else if (instance.appContext.reload) {
2055
2049
  // root instance mounted via createApp() has a reload method
@@ -4497,10 +4491,15 @@ function defineAsyncComponent(source) {
4497
4491
  }
4498
4492
  });
4499
4493
  }
4500
- function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
4494
+ function createInnerComp(comp, parent) {
4495
+ const { ref, props, children, ce } = parent.vnode;
4501
4496
  const vnode = createVNode(comp, props, children);
4502
4497
  // ensure inner component inherits the async wrapper's ref owner
4503
4498
  vnode.ref = ref;
4499
+ // pass the custom element callback on to the inner comp
4500
+ // and remove it from the async wrapper
4501
+ vnode.ce = ce;
4502
+ delete parent.vnode.ce;
4504
4503
  return vnode;
4505
4504
  }
4506
4505
 
@@ -4666,8 +4665,7 @@ const KeepAliveImpl = {
4666
4665
  : comp);
4667
4666
  const { include, exclude, max } = props;
4668
4667
  if ((include && (!name || !matches(include, name))) ||
4669
- (exclude && name && matches(exclude, name)) ||
4670
- ((process.env.NODE_ENV !== 'production') && hmrDirtyComponents.has(comp))) {
4668
+ (exclude && name && matches(exclude, name))) {
4671
4669
  current = vnode;
4672
4670
  return rawVNode;
4673
4671
  }
@@ -4780,14 +4778,9 @@ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
4780
4778
  }, target);
4781
4779
  }
4782
4780
  function resetShapeFlag(vnode) {
4783
- let shapeFlag = vnode.shapeFlag;
4784
- if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
4785
- shapeFlag -= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4786
- }
4787
- if (shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
4788
- shapeFlag -= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4789
- }
4790
- vnode.shapeFlag = shapeFlag;
4781
+ // bitwise operations to remove keep alive flags
4782
+ vnode.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4783
+ vnode.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4791
4784
  }
4792
4785
  function getInnerChild(vnode) {
4793
4786
  return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
@@ -5415,7 +5408,9 @@ fallback, noSlotted) {
5415
5408
  (currentRenderingInstance.parent &&
5416
5409
  isAsyncWrapper(currentRenderingInstance.parent) &&
5417
5410
  currentRenderingInstance.parent.isCE)) {
5418
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
5411
+ if (name !== 'default')
5412
+ props.name = name;
5413
+ return createVNode('slot', props, fallback && fallback());
5419
5414
  }
5420
5415
  let slot = slots[name];
5421
5416
  if ((process.env.NODE_ENV !== 'production') && slot && slot.length > 1) {
@@ -5735,6 +5730,7 @@ const publicPropertiesMap =
5735
5730
  installCompatInstanceProperties(publicPropertiesMap);
5736
5731
  }
5737
5732
  const isReservedPrefix = (key) => key === '_' || key === '$';
5733
+ const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
5738
5734
  const PublicInstanceProxyHandlers = {
5739
5735
  get({ _: instance }, key) {
5740
5736
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
@@ -5742,16 +5738,6 @@ const PublicInstanceProxyHandlers = {
5742
5738
  if ((process.env.NODE_ENV !== 'production') && key === '__isVue') {
5743
5739
  return true;
5744
5740
  }
5745
- // prioritize <script setup> bindings during dev.
5746
- // this allows even properties that start with _ or $ to be used - so that
5747
- // it aligns with the production behavior where the render fn is inlined and
5748
- // indeed has access to all declared variables.
5749
- if ((process.env.NODE_ENV !== 'production') &&
5750
- setupState !== EMPTY_OBJ &&
5751
- setupState.__isScriptSetup &&
5752
- hasOwn(setupState, key)) {
5753
- return setupState[key];
5754
- }
5755
5741
  // data / props / ctx
5756
5742
  // This getter gets called for every property access on the render context
5757
5743
  // during render and is a major hotspot. The most expensive part of this
@@ -5774,7 +5760,7 @@ const PublicInstanceProxyHandlers = {
5774
5760
  // default: just fallthrough
5775
5761
  }
5776
5762
  }
5777
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5763
+ else if (hasSetupBinding(setupState, key)) {
5778
5764
  accessCache[key] = 1 /* AccessTypes.SETUP */;
5779
5765
  return setupState[key];
5780
5766
  }
@@ -5854,23 +5840,28 @@ const PublicInstanceProxyHandlers = {
5854
5840
  },
5855
5841
  set({ _: instance }, key, value) {
5856
5842
  const { data, setupState, ctx } = instance;
5857
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5843
+ if (hasSetupBinding(setupState, key)) {
5858
5844
  setupState[key] = value;
5859
5845
  return true;
5860
5846
  }
5847
+ else if ((process.env.NODE_ENV !== 'production') &&
5848
+ setupState.__isScriptSetup &&
5849
+ hasOwn(setupState, key)) {
5850
+ warn$1(`Cannot mutate <script setup> binding "${key}" from Options API.`);
5851
+ return false;
5852
+ }
5861
5853
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
5862
5854
  data[key] = value;
5863
5855
  return true;
5864
5856
  }
5865
5857
  else if (hasOwn(instance.props, key)) {
5866
- (process.env.NODE_ENV !== 'production') &&
5867
- warn$1(`Attempting to mutate prop "${key}". Props are readonly.`, instance);
5858
+ (process.env.NODE_ENV !== 'production') && warn$1(`Attempting to mutate prop "${key}". Props are readonly.`);
5868
5859
  return false;
5869
5860
  }
5870
5861
  if (key[0] === '$' && key.slice(1) in instance) {
5871
5862
  (process.env.NODE_ENV !== 'production') &&
5872
5863
  warn$1(`Attempting to mutate public property "${key}". ` +
5873
- `Properties starting with $ are reserved and readonly.`, instance);
5864
+ `Properties starting with $ are reserved and readonly.`);
5874
5865
  return false;
5875
5866
  }
5876
5867
  else {
@@ -5891,7 +5882,7 @@ const PublicInstanceProxyHandlers = {
5891
5882
  let normalizedProps;
5892
5883
  return (!!accessCache[key] ||
5893
5884
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
5894
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
5885
+ hasSetupBinding(setupState, key) ||
5895
5886
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
5896
5887
  hasOwn(ctx, key) ||
5897
5888
  hasOwn(publicPropertiesMap, key) ||
@@ -7174,7 +7165,7 @@ function createCompatVue(createApp, createSingletonApp) {
7174
7165
  return vm;
7175
7166
  }
7176
7167
  }
7177
- Vue.version = `2.6.14-compat:${"3.2.44"}`;
7168
+ Vue.version = `2.6.14-compat:${"3.2.45"}`;
7178
7169
  Vue.config = singletonApp.config;
7179
7170
  Vue.use = (p, ...options) => {
7180
7171
  if (p && isFunction(p.install)) {
@@ -9604,6 +9595,10 @@ function traverseStaticChildren(n1, n2, shallow = false) {
9604
9595
  if (!shallow)
9605
9596
  traverseStaticChildren(c1, c2);
9606
9597
  }
9598
+ // #6852 also inherit for text nodes
9599
+ if (c2.type === Text) {
9600
+ c2.el = c1.el;
9601
+ }
9607
9602
  // also inherit for comment nodes, but not placeholders (e.g. v-if which
9608
9603
  // would have received .el during block patch)
9609
9604
  if ((process.env.NODE_ENV !== 'production') && c2.type === Comment && !c2.el) {
@@ -9778,6 +9773,7 @@ const TeleportImpl = {
9778
9773
  }
9779
9774
  }
9780
9775
  }
9776
+ updateCssVars(n2);
9781
9777
  },
9782
9778
  remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
9783
9779
  const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
@@ -9856,11 +9852,26 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
9856
9852
  hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
9857
9853
  }
9858
9854
  }
9855
+ updateCssVars(vnode);
9859
9856
  }
9860
9857
  return vnode.anchor && nextSibling(vnode.anchor);
9861
9858
  }
9862
9859
  // Force-casted public typing for h and TSX props inference
9863
9860
  const Teleport = TeleportImpl;
9861
+ function updateCssVars(vnode) {
9862
+ // presence of .ut method indicates owner component uses css vars.
9863
+ // code path here can assume browser environment.
9864
+ const ctx = vnode.ctx;
9865
+ if (ctx && ctx.ut) {
9866
+ let node = vnode.children[0].el;
9867
+ while (node !== vnode.targetAnchor) {
9868
+ if (node.nodeType === 1)
9869
+ node.setAttribute('data-v-owner', ctx.uid);
9870
+ node = node.nextSibling;
9871
+ }
9872
+ ctx.ut();
9873
+ }
9874
+ }
9864
9875
 
9865
9876
  const normalizedAsyncComponentMap = new Map();
9866
9877
  function convertLegacyAsyncComponent(comp) {
@@ -10016,6 +10027,10 @@ function isSameVNodeType(n1, n2) {
10016
10027
  if ((process.env.NODE_ENV !== 'production') &&
10017
10028
  n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
10018
10029
  hmrDirtyComponents.has(n2.type)) {
10030
+ // #7042, ensure the vnode being unmounted during HMR
10031
+ // bitwise operations to remove keep alive flags
10032
+ n1.shapeFlag &= ~256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
10033
+ n2.shapeFlag &= ~512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
10019
10034
  // HMR only: if the component has been hot-updated, force a reload.
10020
10035
  return false;
10021
10036
  }
@@ -10071,7 +10086,8 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
10071
10086
  patchFlag,
10072
10087
  dynamicProps,
10073
10088
  dynamicChildren: null,
10074
- appContext: null
10089
+ appContext: null,
10090
+ ctx: currentRenderingInstance
10075
10091
  };
10076
10092
  if (needFullChildrenNormalization) {
10077
10093
  normalizeChildren(vnode, children);
@@ -10246,7 +10262,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
10246
10262
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
10247
10263
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
10248
10264
  el: vnode.el,
10249
- anchor: vnode.anchor
10265
+ anchor: vnode.anchor,
10266
+ ctx: vnode.ctx
10250
10267
  };
10251
10268
  {
10252
10269
  defineLegacyVNodeProperties(cloned);
@@ -11259,7 +11276,7 @@ function isMemoSame(cached, memo) {
11259
11276
  }
11260
11277
 
11261
11278
  // Core API ------------------------------------------------------------------
11262
- const version = "3.2.44";
11279
+ const version = "3.2.45";
11263
11280
  const _ssrUtils = {
11264
11281
  createComponentInstance,
11265
11282
  setupComponent,
@@ -11802,12 +11819,21 @@ class VueElement extends BaseClass {
11802
11819
  `defined as hydratable. Use \`defineSSRCustomElement\`.`);
11803
11820
  }
11804
11821
  this.attachShadow({ mode: 'open' });
11822
+ if (!this._def.__asyncLoader) {
11823
+ // for sync component defs we can immediately resolve props
11824
+ this._resolveProps(this._def);
11825
+ }
11805
11826
  }
11806
11827
  }
11807
11828
  connectedCallback() {
11808
11829
  this._connected = true;
11809
11830
  if (!this._instance) {
11810
- this._resolveDef();
11831
+ if (this._resolved) {
11832
+ this._update();
11833
+ }
11834
+ else {
11835
+ this._resolveDef();
11836
+ }
11811
11837
  }
11812
11838
  }
11813
11839
  disconnectedCallback() {
@@ -11823,9 +11849,6 @@ class VueElement extends BaseClass {
11823
11849
  * resolve inner component definition (handle possible async component)
11824
11850
  */
11825
11851
  _resolveDef() {
11826
- if (this._resolved) {
11827
- return;
11828
- }
11829
11852
  this._resolved = true;
11830
11853
  // set initial attrs
11831
11854
  for (let i = 0; i < this.attributes.length; i++) {
@@ -11837,38 +11860,26 @@ class VueElement extends BaseClass {
11837
11860
  this._setAttr(m.attributeName);
11838
11861
  }
11839
11862
  }).observe(this, { attributes: true });
11840
- const resolve = (def) => {
11841
- const { props = {}, styles } = def;
11842
- const hasOptions = !isArray(props);
11843
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11863
+ const resolve = (def, isAsync = false) => {
11864
+ const { props, styles } = def;
11844
11865
  // cast Number-type props set before resolve
11845
11866
  let numberProps;
11846
- if (hasOptions) {
11847
- for (const key in this._props) {
11867
+ if (props && !isArray(props)) {
11868
+ for (const key in props) {
11848
11869
  const opt = props[key];
11849
11870
  if (opt === Number || (opt && opt.type === Number)) {
11850
- this._props[key] = toNumber(this._props[key]);
11851
- (numberProps || (numberProps = Object.create(null)))[key] = true;
11871
+ if (key in this._props) {
11872
+ this._props[key] = toNumber(this._props[key]);
11873
+ }
11874
+ (numberProps || (numberProps = Object.create(null)))[camelize(key)] = true;
11852
11875
  }
11853
11876
  }
11854
11877
  }
11855
11878
  this._numberProps = numberProps;
11856
- // check if there are props set pre-upgrade or connect
11857
- for (const key of Object.keys(this)) {
11858
- if (key[0] !== '_') {
11859
- this._setProp(key, this[key], true, false);
11860
- }
11861
- }
11862
- // defining getter/setters on prototype
11863
- for (const key of rawKeys.map(camelize)) {
11864
- Object.defineProperty(this, key, {
11865
- get() {
11866
- return this._getProp(key);
11867
- },
11868
- set(val) {
11869
- this._setProp(key, val);
11870
- }
11871
- });
11879
+ if (isAsync) {
11880
+ // defining getter/setters on prototype
11881
+ // for sync defs, this already happened in the constructor
11882
+ this._resolveProps(def);
11872
11883
  }
11873
11884
  // apply CSS
11874
11885
  this._applyStyles(styles);
@@ -11877,12 +11888,33 @@ class VueElement extends BaseClass {
11877
11888
  };
11878
11889
  const asyncDef = this._def.__asyncLoader;
11879
11890
  if (asyncDef) {
11880
- asyncDef().then(resolve);
11891
+ asyncDef().then(def => resolve(def, true));
11881
11892
  }
11882
11893
  else {
11883
11894
  resolve(this._def);
11884
11895
  }
11885
11896
  }
11897
+ _resolveProps(def) {
11898
+ const { props } = def;
11899
+ const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
11900
+ // check if there are props set pre-upgrade or connect
11901
+ for (const key of Object.keys(this)) {
11902
+ if (key[0] !== '_' && declaredPropKeys.includes(key)) {
11903
+ this._setProp(key, this[key], true, false);
11904
+ }
11905
+ }
11906
+ // defining getter/setters on prototype
11907
+ for (const key of declaredPropKeys.map(camelize)) {
11908
+ Object.defineProperty(this, key, {
11909
+ get() {
11910
+ return this._getProp(key);
11911
+ },
11912
+ set(val) {
11913
+ this._setProp(key, val);
11914
+ }
11915
+ });
11916
+ }
11917
+ }
11886
11918
  _setAttr(key) {
11887
11919
  let value = this.getAttribute(key);
11888
11920
  const camelKey = camelize(key);
@@ -11938,27 +11970,31 @@ class VueElement extends BaseClass {
11938
11970
  this._styles.length = 0;
11939
11971
  }
11940
11972
  this._applyStyles(newStyles);
11941
- // if this is an async component, ceReload is called from the inner
11942
- // component so no need to reload the async wrapper
11943
- if (!this._def.__asyncLoader) {
11944
- // reload
11945
- this._instance = null;
11946
- this._update();
11947
- }
11973
+ this._instance = null;
11974
+ this._update();
11948
11975
  };
11949
11976
  }
11950
- // intercept emit
11951
- instance.emit = (event, ...args) => {
11977
+ const dispatch = (event, args) => {
11952
11978
  this.dispatchEvent(new CustomEvent(event, {
11953
11979
  detail: args
11954
11980
  }));
11955
11981
  };
11982
+ // intercept emit
11983
+ instance.emit = (event, ...args) => {
11984
+ // dispatch both the raw and hyphenated versions of an event
11985
+ // to match Vue behavior
11986
+ dispatch(event, args);
11987
+ if (hyphenate(event) !== event) {
11988
+ dispatch(hyphenate(event), args);
11989
+ }
11990
+ };
11956
11991
  // locate nearest Vue custom element parent for provide/inject
11957
11992
  let parent = this;
11958
11993
  while ((parent =
11959
11994
  parent && (parent.parentNode || parent.host))) {
11960
11995
  if (parent instanceof VueElement) {
11961
11996
  instance.parent = parent._instance;
11997
+ instance.provides = parent._instance.provides;
11962
11998
  break;
11963
11999
  }
11964
12000
  }
@@ -12016,7 +12052,14 @@ function useCssVars(getter) {
12016
12052
  warn$1(`useCssVars is called without current active component instance.`);
12017
12053
  return;
12018
12054
  }
12019
- const setVars = () => setVarsOnVNode(instance.subTree, getter(instance.proxy));
12055
+ const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
12056
+ Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach(node => setVarsOnNode(node, vars));
12057
+ });
12058
+ const setVars = () => {
12059
+ const vars = getter(instance.proxy);
12060
+ setVarsOnVNode(instance.subTree, vars);
12061
+ updateTeleports(vars);
12062
+ };
12020
12063
  watchPostEffect(setVars);
12021
12064
  onMounted(() => {
12022
12065
  const ob = new MutationObserver(setVars);