@vue/compat 3.2.20 → 3.2.24

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.
@@ -455,7 +455,7 @@ const targetMap = new WeakMap();
455
455
  let effectTrackDepth = 0;
456
456
  let trackOpBit = 1;
457
457
  /**
458
- * The bitwise track markers support at most 30 levels op recursion.
458
+ * The bitwise track markers support at most 30 levels of recursion.
459
459
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
460
460
  * When recursion depth is greater, fall back to using a full cleanup.
461
461
  */
@@ -776,7 +776,7 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
776
776
  function createSetter(shallow = false) {
777
777
  return function set(target, key, value, receiver) {
778
778
  let oldValue = target[key];
779
- if (!shallow) {
779
+ if (!shallow && !isReadonly(value)) {
780
780
  value = toRaw(value);
781
781
  oldValue = toRaw(oldValue);
782
782
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1572,22 +1572,33 @@ function tryWrap(fn) {
1572
1572
 
1573
1573
  let devtools;
1574
1574
  let buffer = [];
1575
+ let devtoolsNotInstalled = false;
1575
1576
  function emit(event, ...args) {
1576
1577
  if (devtools) {
1577
1578
  devtools.emit(event, ...args);
1578
1579
  }
1579
- else {
1580
+ else if (!devtoolsNotInstalled) {
1580
1581
  buffer.push({ event, args });
1581
1582
  }
1582
1583
  }
1583
1584
  function setDevtoolsHook(hook, target) {
1585
+ var _a, _b;
1584
1586
  devtools = hook;
1585
1587
  if (devtools) {
1586
1588
  devtools.enabled = true;
1587
1589
  buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
1588
1590
  buffer = [];
1589
1591
  }
1590
- else {
1592
+ else if (
1593
+ // handle late devtools injection - only do this if we are in an actual
1594
+ // browser environment to avoid the timer handle stalling test runner exit
1595
+ // (#4815)
1596
+ // eslint-disable-next-line no-restricted-globals
1597
+ typeof window !== 'undefined' &&
1598
+ // some envs mock window but not fully
1599
+ window.HTMLElement &&
1600
+ // also exclude jsdom
1601
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1591
1602
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1592
1603
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1593
1604
  replay.push((newHook) => {
@@ -1596,9 +1607,18 @@ function setDevtoolsHook(hook, target) {
1596
1607
  // clear buffer after 3s - the user probably doesn't have devtools installed
1597
1608
  // at all, and keeping the buffer will cause memory leaks (#4738)
1598
1609
  setTimeout(() => {
1599
- buffer = [];
1610
+ if (!devtools) {
1611
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1612
+ devtoolsNotInstalled = true;
1613
+ buffer = [];
1614
+ }
1600
1615
  }, 3000);
1601
1616
  }
1617
+ else {
1618
+ // non-browser env, assume not installed
1619
+ devtoolsNotInstalled = true;
1620
+ buffer = [];
1621
+ }
1602
1622
  }
1603
1623
  function devtoolsInitApp(app, version) {
1604
1624
  emit("app:init" /* APP_INIT */, app, version, {
@@ -3212,7 +3232,8 @@ const BaseTransitionImpl = {
3212
3232
  const rawProps = toRaw(props);
3213
3233
  const { mode } = rawProps;
3214
3234
  // check mode
3215
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
3235
+ if (mode &&
3236
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3216
3237
  warn$1(`invalid <transition> mode: ${mode}`);
3217
3238
  }
3218
3239
  // at this point children has a guaranteed length of 1.
@@ -3858,7 +3879,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
3858
3879
  }
3859
3880
  current = current.parent;
3860
3881
  }
3861
- hook();
3882
+ return hook();
3862
3883
  });
3863
3884
  injectHook(type, wrappedHook, target);
3864
3885
  // In addition to registering it on the target instance, we walk up the parent
@@ -4636,7 +4657,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4636
4657
  continue;
4637
4658
  }
4638
4659
  }
4639
- if (value !== attrs[key]) {
4660
+ if (!(key in attrs) || value !== attrs[key]) {
4640
4661
  attrs[key] = value;
4641
4662
  hasAttrsChanged = true;
4642
4663
  }
@@ -5082,7 +5103,7 @@ return withDirectives(h(comp), [
5082
5103
  [bar, this.y]
5083
5104
  ])
5084
5105
  */
5085
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
5106
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5086
5107
  function validateDirectiveName(name) {
5087
5108
  if (isBuiltInDirective(name)) {
5088
5109
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -5217,7 +5238,7 @@ function createCompatVue(createApp, createSingletonApp) {
5217
5238
  return vm;
5218
5239
  }
5219
5240
  }
5220
- Vue.version = "3.2.20";
5241
+ Vue.version = "3.2.24";
5221
5242
  Vue.config = singletonApp.config;
5222
5243
  Vue.use = (p, ...options) => {
5223
5244
  if (p && isFunction(p.install)) {
@@ -6663,7 +6684,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6663
6684
  }
6664
6685
  };
6665
6686
  const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
6666
- // 2.x compat may pre-creaate the component instance before actually
6687
+ // 2.x compat may pre-create the component instance before actually
6667
6688
  // mounting
6668
6689
  const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
6669
6690
  const instance = compatMountInstance ||
@@ -7543,8 +7564,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7543
7564
  *
7544
7565
  * #2080
7545
7566
  * Inside keyed `template` fragment static children, if a fragment is moved,
7546
- * the children will always moved so that need inherit el form previous nodes
7547
- * to ensure correct moved position.
7567
+ * the children will always be moved. Therefore, in order to ensure correct move
7568
+ * position, el should be inherited from previous nodes.
7548
7569
  */
7549
7570
  function traverseStaticChildren(n1, n2, shallow = false) {
7550
7571
  const ch1 = n1.children;
@@ -8182,6 +8203,7 @@ function convertLegacyFunctionalComponent(comp) {
8182
8203
  };
8183
8204
  Func.props = comp.props;
8184
8205
  Func.displayName = comp.name;
8206
+ Func.compatConfig = comp.compatConfig;
8185
8207
  // v2 functional components do not inherit attrs
8186
8208
  Func.inheritAttrs = false;
8187
8209
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -8671,7 +8693,8 @@ function mergeProps(...args) {
8671
8693
  else if (isOn(key)) {
8672
8694
  const existing = ret[key];
8673
8695
  const incoming = toMerge[key];
8674
- if (existing !== incoming) {
8696
+ if (existing !== incoming &&
8697
+ !(isArray(existing) && existing.includes(incoming))) {
8675
8698
  ret[key] = existing
8676
8699
  ? [].concat(existing, incoming)
8677
8700
  : incoming;
@@ -9115,23 +9138,23 @@ const PublicInstanceProxyHandlers = {
9115
9138
  const n = accessCache[key];
9116
9139
  if (n !== undefined) {
9117
9140
  switch (n) {
9118
- case 0 /* SETUP */:
9141
+ case 1 /* SETUP */:
9119
9142
  return setupState[key];
9120
- case 1 /* DATA */:
9143
+ case 2 /* DATA */:
9121
9144
  return data[key];
9122
- case 3 /* CONTEXT */:
9145
+ case 4 /* CONTEXT */:
9123
9146
  return ctx[key];
9124
- case 2 /* PROPS */:
9147
+ case 3 /* PROPS */:
9125
9148
  return props[key];
9126
9149
  // default: just fallthrough
9127
9150
  }
9128
9151
  }
9129
9152
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
9130
- accessCache[key] = 0 /* SETUP */;
9153
+ accessCache[key] = 1 /* SETUP */;
9131
9154
  return setupState[key];
9132
9155
  }
9133
9156
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
9134
- accessCache[key] = 1 /* DATA */;
9157
+ accessCache[key] = 2 /* DATA */;
9135
9158
  return data[key];
9136
9159
  }
9137
9160
  else if (
@@ -9139,15 +9162,15 @@ const PublicInstanceProxyHandlers = {
9139
9162
  // props
9140
9163
  (normalizedProps = instance.propsOptions[0]) &&
9141
9164
  hasOwn(normalizedProps, key)) {
9142
- accessCache[key] = 2 /* PROPS */;
9165
+ accessCache[key] = 3 /* PROPS */;
9143
9166
  return props[key];
9144
9167
  }
9145
9168
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9146
- accessCache[key] = 3 /* CONTEXT */;
9169
+ accessCache[key] = 4 /* CONTEXT */;
9147
9170
  return ctx[key];
9148
9171
  }
9149
9172
  else if (shouldCacheAccess) {
9150
- accessCache[key] = 4 /* OTHER */;
9173
+ accessCache[key] = 0 /* OTHER */;
9151
9174
  }
9152
9175
  }
9153
9176
  const publicGetter = publicPropertiesMap[key];
@@ -9168,7 +9191,7 @@ const PublicInstanceProxyHandlers = {
9168
9191
  }
9169
9192
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9170
9193
  // user may set custom properties to `this` that start with `$`
9171
- accessCache[key] = 3 /* CONTEXT */;
9194
+ accessCache[key] = 4 /* CONTEXT */;
9172
9195
  return ctx[key];
9173
9196
  }
9174
9197
  else if (
@@ -9236,7 +9259,7 @@ const PublicInstanceProxyHandlers = {
9236
9259
  },
9237
9260
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
9238
9261
  let normalizedProps;
9239
- return (accessCache[key] !== undefined ||
9262
+ return (!!accessCache[key] ||
9240
9263
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
9241
9264
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
9242
9265
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -10811,7 +10834,7 @@ function isMemoSame(cached, memo) {
10811
10834
  }
10812
10835
 
10813
10836
  // Core API ------------------------------------------------------------------
10814
- const version = "3.2.20";
10837
+ const version = "3.2.24";
10815
10838
  /**
10816
10839
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
10817
10840
  * @internal
@@ -10940,16 +10963,8 @@ function patchClass(el, value, isSVG) {
10940
10963
 
10941
10964
  function patchStyle(el, prev, next) {
10942
10965
  const style = el.style;
10943
- const currentDisplay = style.display;
10944
- if (!next) {
10945
- el.removeAttribute('style');
10946
- }
10947
- else if (isString(next)) {
10948
- if (prev !== next) {
10949
- style.cssText = next;
10950
- }
10951
- }
10952
- else {
10966
+ const isCssString = isString(next);
10967
+ if (next && !isCssString) {
10953
10968
  for (const key in next) {
10954
10969
  setStyle(style, key, next[key]);
10955
10970
  }
@@ -10961,11 +10976,22 @@ function patchStyle(el, prev, next) {
10961
10976
  }
10962
10977
  }
10963
10978
  }
10964
- // indicates that the `display` of the element is controlled by `v-show`,
10965
- // so we always keep the current `display` value regardless of the `style` value,
10966
- // thus handing over control to `v-show`.
10967
- if ('_vod' in el) {
10968
- style.display = currentDisplay;
10979
+ else {
10980
+ const currentDisplay = style.display;
10981
+ if (isCssString) {
10982
+ if (prev !== next) {
10983
+ style.cssText = next;
10984
+ }
10985
+ }
10986
+ else if (prev) {
10987
+ el.removeAttribute('style');
10988
+ }
10989
+ // indicates that the `display` of the element is controlled by `v-show`,
10990
+ // so we always keep the current `display` value regardless of the `style`
10991
+ // value, thus handing over control to `v-show`.
10992
+ if ('_vod' in el) {
10993
+ style.display = currentDisplay;
10994
+ }
10969
10995
  }
10970
10996
  }
10971
10997
  const importantRE = /\s*!important$/;
@@ -11075,12 +11101,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11075
11101
  el[key] = value == null ? '' : value;
11076
11102
  return;
11077
11103
  }
11078
- if (key === 'value' && el.tagName !== 'PROGRESS') {
11104
+ if (key === 'value' &&
11105
+ el.tagName !== 'PROGRESS' &&
11106
+ // custom elements may use _value internally
11107
+ !el.tagName.includes('-')) {
11079
11108
  // store value as _value as well since
11080
11109
  // non-string values will be stringified.
11081
11110
  el._value = value;
11082
11111
  const newValue = value == null ? '' : value;
11083
- if (el.value !== newValue) {
11112
+ if (el.value !== newValue ||
11113
+ // #4956: always set for OPTION elements because its value falls back to
11114
+ // textContent if no value attribute is present. And setting .value for
11115
+ // OPTION has no side effect
11116
+ el.tagName === 'OPTION') {
11084
11117
  el.value = newValue;
11085
11118
  }
11086
11119
  if (value == null) {
@@ -11348,22 +11381,11 @@ class VueElement extends BaseClass {
11348
11381
  }
11349
11382
  this.attachShadow({ mode: 'open' });
11350
11383
  }
11351
- // set initial attrs
11352
- for (let i = 0; i < this.attributes.length; i++) {
11353
- this._setAttr(this.attributes[i].name);
11354
- }
11355
- // watch future attr changes
11356
- new MutationObserver(mutations => {
11357
- for (const m of mutations) {
11358
- this._setAttr(m.attributeName);
11359
- }
11360
- }).observe(this, { attributes: true });
11361
11384
  }
11362
11385
  connectedCallback() {
11363
11386
  this._connected = true;
11364
11387
  if (!this._instance) {
11365
11388
  this._resolveDef();
11366
- this._update();
11367
11389
  }
11368
11390
  }
11369
11391
  disconnectedCallback() {
@@ -11382,8 +11404,18 @@ class VueElement extends BaseClass {
11382
11404
  if (this._resolved) {
11383
11405
  return;
11384
11406
  }
11407
+ this._resolved = true;
11408
+ // set initial attrs
11409
+ for (let i = 0; i < this.attributes.length; i++) {
11410
+ this._setAttr(this.attributes[i].name);
11411
+ }
11412
+ // watch future attr changes
11413
+ new MutationObserver(mutations => {
11414
+ for (const m of mutations) {
11415
+ this._setAttr(m.attributeName);
11416
+ }
11417
+ }).observe(this, { attributes: true });
11385
11418
  const resolve = (def) => {
11386
- this._resolved = true;
11387
11419
  const { props, styles } = def;
11388
11420
  const hasOptions = !isArray(props);
11389
11421
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -11398,14 +11430,11 @@ class VueElement extends BaseClass {
11398
11430
  }
11399
11431
  }
11400
11432
  }
11401
- if (numberProps) {
11402
- this._numberProps = numberProps;
11403
- this._update();
11404
- }
11433
+ this._numberProps = numberProps;
11405
11434
  // check if there are props set pre-upgrade or connect
11406
11435
  for (const key of Object.keys(this)) {
11407
11436
  if (key[0] !== '_') {
11408
- this._setProp(key, this[key]);
11437
+ this._setProp(key, this[key], true, false);
11409
11438
  }
11410
11439
  }
11411
11440
  // defining getter/setters on prototype
@@ -11419,7 +11448,10 @@ class VueElement extends BaseClass {
11419
11448
  }
11420
11449
  });
11421
11450
  }
11451
+ // apply CSS
11422
11452
  this._applyStyles(styles);
11453
+ // initial render
11454
+ this._update();
11423
11455
  };
11424
11456
  const asyncDef = this._def.__asyncLoader;
11425
11457
  if (asyncDef) {
@@ -11445,10 +11477,10 @@ class VueElement extends BaseClass {
11445
11477
  /**
11446
11478
  * @internal
11447
11479
  */
11448
- _setProp(key, val, shouldReflect = true) {
11480
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
11449
11481
  if (val !== this._props[key]) {
11450
11482
  this._props[key] = val;
11451
- if (this._instance) {
11483
+ if (shouldUpdate && this._instance) {
11452
11484
  this._update();
11453
11485
  }
11454
11486
  // reflect
@@ -11477,7 +11509,7 @@ class VueElement extends BaseClass {
11477
11509
  // HMR
11478
11510
  {
11479
11511
  instance.ceReload = newStyles => {
11480
- // alawys reset styles
11512
+ // always reset styles
11481
11513
  if (this._styles) {
11482
11514
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
11483
11515
  this._styles.length = 0;