@vue/compat 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.
@@ -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
@@ -2280,8 +2274,8 @@ const deprecationData = {
2280
2274
  },
2281
2275
  ["INSTANCE_EVENT_HOOKS" /* DeprecationTypes.INSTANCE_EVENT_HOOKS */]: {
2282
2276
  message: event => `"${event}" lifecycle events are no longer supported. From templates, ` +
2283
- `use the "vnode" prefix instead of "hook:". For example, @${event} ` +
2284
- `should be changed to @vnode-${event.slice(5)}. ` +
2277
+ `use the "vue:" prefix instead of "hook:". For example, @${event} ` +
2278
+ `should be changed to @vue:${event.slice(5)}. ` +
2285
2279
  `From JavaScript, use Composition API to dynamically register lifecycle ` +
2286
2280
  `hooks.`,
2287
2281
  link: `https://v3-migration.vuejs.org/breaking-changes/vnode-lifecycle-events.html`
@@ -3888,10 +3882,11 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3888
3882
  callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
3889
3883
  newValue,
3890
3884
  // pass undefined as the old value when it's changed for the first time
3891
- oldValue === INITIAL_WATCHER_VALUE ||
3892
- (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3893
- ? []
3894
- : oldValue,
3885
+ oldValue === INITIAL_WATCHER_VALUE
3886
+ ? undefined
3887
+ : (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3888
+ ? []
3889
+ : oldValue,
3895
3890
  onCleanup
3896
3891
  ]);
3897
3892
  oldValue = newValue;
@@ -4496,10 +4491,15 @@ function defineAsyncComponent(source) {
4496
4491
  }
4497
4492
  });
4498
4493
  }
4499
- function createInnerComp(comp, { vnode: { ref, props, children, shapeFlag }, parent }) {
4494
+ function createInnerComp(comp, parent) {
4495
+ const { ref, props, children, ce } = parent.vnode;
4500
4496
  const vnode = createVNode(comp, props, children);
4501
4497
  // ensure inner component inherits the async wrapper's ref owner
4502
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;
4503
4503
  return vnode;
4504
4504
  }
4505
4505
 
@@ -4665,8 +4665,7 @@ const KeepAliveImpl = {
4665
4665
  : comp);
4666
4666
  const { include, exclude, max } = props;
4667
4667
  if ((include && (!name || !matches(include, name))) ||
4668
- (exclude && name && matches(exclude, name)) ||
4669
- ((process.env.NODE_ENV !== 'production') && hmrDirtyComponents.has(comp))) {
4668
+ (exclude && name && matches(exclude, name))) {
4670
4669
  current = vnode;
4671
4670
  return rawVNode;
4672
4671
  }
@@ -4779,14 +4778,9 @@ function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
4779
4778
  }, target);
4780
4779
  }
4781
4780
  function resetShapeFlag(vnode) {
4782
- let shapeFlag = vnode.shapeFlag;
4783
- if (shapeFlag & 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */) {
4784
- shapeFlag -= 256 /* ShapeFlags.COMPONENT_SHOULD_KEEP_ALIVE */;
4785
- }
4786
- if (shapeFlag & 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */) {
4787
- shapeFlag -= 512 /* ShapeFlags.COMPONENT_KEPT_ALIVE */;
4788
- }
4789
- 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 */;
4790
4784
  }
4791
4785
  function getInnerChild(vnode) {
4792
4786
  return vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */ ? vnode.ssContent : vnode;
@@ -5414,7 +5408,9 @@ fallback, noSlotted) {
5414
5408
  (currentRenderingInstance.parent &&
5415
5409
  isAsyncWrapper(currentRenderingInstance.parent) &&
5416
5410
  currentRenderingInstance.parent.isCE)) {
5417
- return createVNode('slot', name === 'default' ? null : { name }, fallback && fallback());
5411
+ if (name !== 'default')
5412
+ props.name = name;
5413
+ return createVNode('slot', props, fallback && fallback());
5418
5414
  }
5419
5415
  let slot = slots[name];
5420
5416
  if ((process.env.NODE_ENV !== 'production') && slot && slot.length > 1) {
@@ -5734,6 +5730,7 @@ const publicPropertiesMap =
5734
5730
  installCompatInstanceProperties(publicPropertiesMap);
5735
5731
  }
5736
5732
  const isReservedPrefix = (key) => key === '_' || key === '$';
5733
+ const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
5737
5734
  const PublicInstanceProxyHandlers = {
5738
5735
  get({ _: instance }, key) {
5739
5736
  const { ctx, setupState, data, props, accessCache, type, appContext } = instance;
@@ -5741,16 +5738,6 @@ const PublicInstanceProxyHandlers = {
5741
5738
  if ((process.env.NODE_ENV !== 'production') && key === '__isVue') {
5742
5739
  return true;
5743
5740
  }
5744
- // prioritize <script setup> bindings during dev.
5745
- // this allows even properties that start with _ or $ to be used - so that
5746
- // it aligns with the production behavior where the render fn is inlined and
5747
- // indeed has access to all declared variables.
5748
- if ((process.env.NODE_ENV !== 'production') &&
5749
- setupState !== EMPTY_OBJ &&
5750
- setupState.__isScriptSetup &&
5751
- hasOwn(setupState, key)) {
5752
- return setupState[key];
5753
- }
5754
5741
  // data / props / ctx
5755
5742
  // This getter gets called for every property access on the render context
5756
5743
  // during render and is a major hotspot. The most expensive part of this
@@ -5773,7 +5760,7 @@ const PublicInstanceProxyHandlers = {
5773
5760
  // default: just fallthrough
5774
5761
  }
5775
5762
  }
5776
- else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5763
+ else if (hasSetupBinding(setupState, key)) {
5777
5764
  accessCache[key] = 1 /* AccessTypes.SETUP */;
5778
5765
  return setupState[key];
5779
5766
  }
@@ -5853,23 +5840,28 @@ const PublicInstanceProxyHandlers = {
5853
5840
  },
5854
5841
  set({ _: instance }, key, value) {
5855
5842
  const { data, setupState, ctx } = instance;
5856
- if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
5843
+ if (hasSetupBinding(setupState, key)) {
5857
5844
  setupState[key] = value;
5858
5845
  return true;
5859
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
+ }
5860
5853
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
5861
5854
  data[key] = value;
5862
5855
  return true;
5863
5856
  }
5864
5857
  else if (hasOwn(instance.props, key)) {
5865
- (process.env.NODE_ENV !== 'production') &&
5866
- 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.`);
5867
5859
  return false;
5868
5860
  }
5869
5861
  if (key[0] === '$' && key.slice(1) in instance) {
5870
5862
  (process.env.NODE_ENV !== 'production') &&
5871
5863
  warn$1(`Attempting to mutate public property "${key}". ` +
5872
- `Properties starting with $ are reserved and readonly.`, instance);
5864
+ `Properties starting with $ are reserved and readonly.`);
5873
5865
  return false;
5874
5866
  }
5875
5867
  else {
@@ -5890,7 +5882,7 @@ const PublicInstanceProxyHandlers = {
5890
5882
  let normalizedProps;
5891
5883
  return (!!accessCache[key] ||
5892
5884
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
5893
- (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
5885
+ hasSetupBinding(setupState, key) ||
5894
5886
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
5895
5887
  hasOwn(ctx, key) ||
5896
5888
  hasOwn(publicPropertiesMap, key) ||
@@ -7173,7 +7165,7 @@ function createCompatVue(createApp, createSingletonApp) {
7173
7165
  return vm;
7174
7166
  }
7175
7167
  }
7176
- Vue.version = `2.6.14-compat:${"3.2.43"}`;
7168
+ Vue.version = `2.6.14-compat:${"3.2.45"}`;
7177
7169
  Vue.config = singletonApp.config;
7178
7170
  Vue.use = (p, ...options) => {
7179
7171
  if (p && isFunction(p.install)) {
@@ -9603,6 +9595,10 @@ function traverseStaticChildren(n1, n2, shallow = false) {
9603
9595
  if (!shallow)
9604
9596
  traverseStaticChildren(c1, c2);
9605
9597
  }
9598
+ // #6852 also inherit for text nodes
9599
+ if (c2.type === Text) {
9600
+ c2.el = c1.el;
9601
+ }
9606
9602
  // also inherit for comment nodes, but not placeholders (e.g. v-if which
9607
9603
  // would have received .el during block patch)
9608
9604
  if ((process.env.NODE_ENV !== 'production') && c2.type === Comment && !c2.el) {
@@ -9777,6 +9773,7 @@ const TeleportImpl = {
9777
9773
  }
9778
9774
  }
9779
9775
  }
9776
+ updateCssVars(n2);
9780
9777
  },
9781
9778
  remove(vnode, parentComponent, parentSuspense, optimized, { um: unmount, o: { remove: hostRemove } }, doRemove) {
9782
9779
  const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode;
@@ -9855,11 +9852,26 @@ function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScope
9855
9852
  hydrateChildren(targetNode, vnode, target, parentComponent, parentSuspense, slotScopeIds, optimized);
9856
9853
  }
9857
9854
  }
9855
+ updateCssVars(vnode);
9858
9856
  }
9859
9857
  return vnode.anchor && nextSibling(vnode.anchor);
9860
9858
  }
9861
9859
  // Force-casted public typing for h and TSX props inference
9862
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
+ }
9863
9875
 
9864
9876
  const normalizedAsyncComponentMap = new Map();
9865
9877
  function convertLegacyAsyncComponent(comp) {
@@ -10015,6 +10027,10 @@ function isSameVNodeType(n1, n2) {
10015
10027
  if ((process.env.NODE_ENV !== 'production') &&
10016
10028
  n2.shapeFlag & 6 /* ShapeFlags.COMPONENT */ &&
10017
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 */;
10018
10034
  // HMR only: if the component has been hot-updated, force a reload.
10019
10035
  return false;
10020
10036
  }
@@ -10070,7 +10086,8 @@ function createBaseVNode(type, props = null, children = null, patchFlag = 0, dyn
10070
10086
  patchFlag,
10071
10087
  dynamicProps,
10072
10088
  dynamicChildren: null,
10073
- appContext: null
10089
+ appContext: null,
10090
+ ctx: currentRenderingInstance
10074
10091
  };
10075
10092
  if (needFullChildrenNormalization) {
10076
10093
  normalizeChildren(vnode, children);
@@ -10245,7 +10262,8 @@ function cloneVNode(vnode, extraProps, mergeRef = false) {
10245
10262
  ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
10246
10263
  ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
10247
10264
  el: vnode.el,
10248
- anchor: vnode.anchor
10265
+ anchor: vnode.anchor,
10266
+ ctx: vnode.ctx
10249
10267
  };
10250
10268
  {
10251
10269
  defineLegacyVNodeProperties(cloned);
@@ -11258,7 +11276,7 @@ function isMemoSame(cached, memo) {
11258
11276
  }
11259
11277
 
11260
11278
  // Core API ------------------------------------------------------------------
11261
- const version = "3.2.43";
11279
+ const version = "3.2.45";
11262
11280
  const _ssrUtils = {
11263
11281
  createComponentInstance,
11264
11282
  setupComponent,
@@ -11419,6 +11437,7 @@ function patchStyle(el, prev, next) {
11419
11437
  }
11420
11438
  }
11421
11439
  }
11440
+ const semicolonRE = /[^\\];\s*$/;
11422
11441
  const importantRE = /\s*!important$/;
11423
11442
  function setStyle(style, name, val) {
11424
11443
  if (isArray(val)) {
@@ -11427,6 +11446,11 @@ function setStyle(style, name, val) {
11427
11446
  else {
11428
11447
  if (val == null)
11429
11448
  val = '';
11449
+ if ((process.env.NODE_ENV !== 'production')) {
11450
+ if (semicolonRE.test(val)) {
11451
+ warn$1(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
11452
+ }
11453
+ }
11430
11454
  if (name.startsWith('--')) {
11431
11455
  // custom property definition
11432
11456
  style.setProperty(name, val);
@@ -11795,12 +11819,21 @@ class VueElement extends BaseClass {
11795
11819
  `defined as hydratable. Use \`defineSSRCustomElement\`.`);
11796
11820
  }
11797
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
+ }
11798
11826
  }
11799
11827
  }
11800
11828
  connectedCallback() {
11801
11829
  this._connected = true;
11802
11830
  if (!this._instance) {
11803
- this._resolveDef();
11831
+ if (this._resolved) {
11832
+ this._update();
11833
+ }
11834
+ else {
11835
+ this._resolveDef();
11836
+ }
11804
11837
  }
11805
11838
  }
11806
11839
  disconnectedCallback() {
@@ -11816,9 +11849,6 @@ class VueElement extends BaseClass {
11816
11849
  * resolve inner component definition (handle possible async component)
11817
11850
  */
11818
11851
  _resolveDef() {
11819
- if (this._resolved) {
11820
- return;
11821
- }
11822
11852
  this._resolved = true;
11823
11853
  // set initial attrs
11824
11854
  for (let i = 0; i < this.attributes.length; i++) {
@@ -11830,38 +11860,26 @@ class VueElement extends BaseClass {
11830
11860
  this._setAttr(m.attributeName);
11831
11861
  }
11832
11862
  }).observe(this, { attributes: true });
11833
- const resolve = (def) => {
11834
- const { props = {}, styles } = def;
11835
- const hasOptions = !isArray(props);
11836
- const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11863
+ const resolve = (def, isAsync = false) => {
11864
+ const { props, styles } = def;
11837
11865
  // cast Number-type props set before resolve
11838
11866
  let numberProps;
11839
- if (hasOptions) {
11840
- for (const key in this._props) {
11867
+ if (props && !isArray(props)) {
11868
+ for (const key in props) {
11841
11869
  const opt = props[key];
11842
11870
  if (opt === Number || (opt && opt.type === Number)) {
11843
- this._props[key] = toNumber(this._props[key]);
11844
- (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;
11845
11875
  }
11846
11876
  }
11847
11877
  }
11848
11878
  this._numberProps = numberProps;
11849
- // check if there are props set pre-upgrade or connect
11850
- for (const key of Object.keys(this)) {
11851
- if (key[0] !== '_') {
11852
- this._setProp(key, this[key], true, false);
11853
- }
11854
- }
11855
- // defining getter/setters on prototype
11856
- for (const key of rawKeys.map(camelize)) {
11857
- Object.defineProperty(this, key, {
11858
- get() {
11859
- return this._getProp(key);
11860
- },
11861
- set(val) {
11862
- this._setProp(key, val);
11863
- }
11864
- });
11879
+ if (isAsync) {
11880
+ // defining getter/setters on prototype
11881
+ // for sync defs, this already happened in the constructor
11882
+ this._resolveProps(def);
11865
11883
  }
11866
11884
  // apply CSS
11867
11885
  this._applyStyles(styles);
@@ -11870,12 +11888,33 @@ class VueElement extends BaseClass {
11870
11888
  };
11871
11889
  const asyncDef = this._def.__asyncLoader;
11872
11890
  if (asyncDef) {
11873
- asyncDef().then(resolve);
11891
+ asyncDef().then(def => resolve(def, true));
11874
11892
  }
11875
11893
  else {
11876
11894
  resolve(this._def);
11877
11895
  }
11878
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
+ }
11879
11918
  _setAttr(key) {
11880
11919
  let value = this.getAttribute(key);
11881
11920
  const camelKey = camelize(key);
@@ -11931,27 +11970,31 @@ class VueElement extends BaseClass {
11931
11970
  this._styles.length = 0;
11932
11971
  }
11933
11972
  this._applyStyles(newStyles);
11934
- // if this is an async component, ceReload is called from the inner
11935
- // component so no need to reload the async wrapper
11936
- if (!this._def.__asyncLoader) {
11937
- // reload
11938
- this._instance = null;
11939
- this._update();
11940
- }
11973
+ this._instance = null;
11974
+ this._update();
11941
11975
  };
11942
11976
  }
11943
- // intercept emit
11944
- instance.emit = (event, ...args) => {
11977
+ const dispatch = (event, args) => {
11945
11978
  this.dispatchEvent(new CustomEvent(event, {
11946
11979
  detail: args
11947
11980
  }));
11948
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
+ };
11949
11991
  // locate nearest Vue custom element parent for provide/inject
11950
11992
  let parent = this;
11951
11993
  while ((parent =
11952
11994
  parent && (parent.parentNode || parent.host))) {
11953
11995
  if (parent instanceof VueElement) {
11954
11996
  instance.parent = parent._instance;
11997
+ instance.provides = parent._instance.provides;
11955
11998
  break;
11956
11999
  }
11957
12000
  }
@@ -12009,7 +12052,14 @@ function useCssVars(getter) {
12009
12052
  warn$1(`useCssVars is called without current active component instance.`);
12010
12053
  return;
12011
12054
  }
12012
- 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
+ };
12013
12063
  watchPostEffect(setVars);
12014
12064
  onMounted(() => {
12015
12065
  const ob = new MutationObserver(setVars);