@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.
@@ -456,7 +456,7 @@ const targetMap = new WeakMap();
456
456
  let effectTrackDepth = 0;
457
457
  let trackOpBit = 1;
458
458
  /**
459
- * The bitwise track markers support at most 30 levels op recursion.
459
+ * The bitwise track markers support at most 30 levels of recursion.
460
460
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
461
461
  * When recursion depth is greater, fall back to using a full cleanup.
462
462
  */
@@ -785,7 +785,7 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
785
785
  function createSetter(shallow = false) {
786
786
  return function set(target, key, value, receiver) {
787
787
  let oldValue = target[key];
788
- if (!shallow) {
788
+ if (!shallow && !isReadonly(value)) {
789
789
  value = toRaw(value);
790
790
  oldValue = toRaw(oldValue);
791
791
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1589,22 +1589,33 @@ function tryWrap(fn) {
1589
1589
 
1590
1590
  let devtools;
1591
1591
  let buffer = [];
1592
+ let devtoolsNotInstalled = false;
1592
1593
  function emit(event, ...args) {
1593
1594
  if (devtools) {
1594
1595
  devtools.emit(event, ...args);
1595
1596
  }
1596
- else {
1597
+ else if (!devtoolsNotInstalled) {
1597
1598
  buffer.push({ event, args });
1598
1599
  }
1599
1600
  }
1600
1601
  function setDevtoolsHook(hook, target) {
1602
+ var _a, _b;
1601
1603
  devtools = hook;
1602
1604
  if (devtools) {
1603
1605
  devtools.enabled = true;
1604
1606
  buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
1605
1607
  buffer = [];
1606
1608
  }
1607
- else {
1609
+ else if (
1610
+ // handle late devtools injection - only do this if we are in an actual
1611
+ // browser environment to avoid the timer handle stalling test runner exit
1612
+ // (#4815)
1613
+ // eslint-disable-next-line no-restricted-globals
1614
+ typeof window !== 'undefined' &&
1615
+ // some envs mock window but not fully
1616
+ window.HTMLElement &&
1617
+ // also exclude jsdom
1618
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1608
1619
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1609
1620
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1610
1621
  replay.push((newHook) => {
@@ -1613,9 +1624,18 @@ function setDevtoolsHook(hook, target) {
1613
1624
  // clear buffer after 3s - the user probably doesn't have devtools installed
1614
1625
  // at all, and keeping the buffer will cause memory leaks (#4738)
1615
1626
  setTimeout(() => {
1616
- buffer = [];
1627
+ if (!devtools) {
1628
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1629
+ devtoolsNotInstalled = true;
1630
+ buffer = [];
1631
+ }
1617
1632
  }, 3000);
1618
1633
  }
1634
+ else {
1635
+ // non-browser env, assume not installed
1636
+ devtoolsNotInstalled = true;
1637
+ buffer = [];
1638
+ }
1619
1639
  }
1620
1640
  function devtoolsInitApp(app, version) {
1621
1641
  emit("app:init" /* APP_INIT */, app, version, {
@@ -3233,7 +3253,9 @@ const BaseTransitionImpl = {
3233
3253
  const rawProps = toRaw(props);
3234
3254
  const { mode } = rawProps;
3235
3255
  // check mode
3236
- if ((process.env.NODE_ENV !== 'production') && mode && !['in-out', 'out-in', 'default'].includes(mode)) {
3256
+ if ((process.env.NODE_ENV !== 'production') &&
3257
+ mode &&
3258
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
3237
3259
  warn$1(`invalid <transition> mode: ${mode}`);
3238
3260
  }
3239
3261
  // at this point children has a guaranteed length of 1.
@@ -3879,7 +3901,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
3879
3901
  }
3880
3902
  current = current.parent;
3881
3903
  }
3882
- hook();
3904
+ return hook();
3883
3905
  });
3884
3906
  injectHook(type, wrappedHook, target);
3885
3907
  // In addition to registering it on the target instance, we walk up the parent
@@ -4664,7 +4686,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4664
4686
  continue;
4665
4687
  }
4666
4688
  }
4667
- if (value !== attrs[key]) {
4689
+ if (!(key in attrs) || value !== attrs[key]) {
4668
4690
  attrs[key] = value;
4669
4691
  hasAttrsChanged = true;
4670
4692
  }
@@ -5112,7 +5134,7 @@ return withDirectives(h(comp), [
5112
5134
  [bar, this.y]
5113
5135
  ])
5114
5136
  */
5115
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
5137
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
5116
5138
  function validateDirectiveName(name) {
5117
5139
  if (isBuiltInDirective(name)) {
5118
5140
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -5247,7 +5269,7 @@ function createCompatVue(createApp, createSingletonApp) {
5247
5269
  return vm;
5248
5270
  }
5249
5271
  }
5250
- Vue.version = "3.2.20";
5272
+ Vue.version = "3.2.24";
5251
5273
  Vue.config = singletonApp.config;
5252
5274
  Vue.use = (p, ...options) => {
5253
5275
  if (p && isFunction(p.install)) {
@@ -6744,7 +6766,7 @@ function baseCreateRenderer(options, createHydrationFns) {
6744
6766
  }
6745
6767
  };
6746
6768
  const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
6747
- // 2.x compat may pre-creaate the component instance before actually
6769
+ // 2.x compat may pre-create the component instance before actually
6748
6770
  // mounting
6749
6771
  const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
6750
6772
  const instance = compatMountInstance ||
@@ -7624,8 +7646,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
7624
7646
  *
7625
7647
  * #2080
7626
7648
  * Inside keyed `template` fragment static children, if a fragment is moved,
7627
- * the children will always moved so that need inherit el form previous nodes
7628
- * to ensure correct moved position.
7649
+ * the children will always be moved. Therefore, in order to ensure correct move
7650
+ * position, el should be inherited from previous nodes.
7629
7651
  */
7630
7652
  function traverseStaticChildren(n1, n2, shallow = false) {
7631
7653
  const ch1 = n1.children;
@@ -8267,6 +8289,7 @@ function convertLegacyFunctionalComponent(comp) {
8267
8289
  };
8268
8290
  Func.props = comp.props;
8269
8291
  Func.displayName = comp.name;
8292
+ Func.compatConfig = comp.compatConfig;
8270
8293
  // v2 functional components do not inherit attrs
8271
8294
  Func.inheritAttrs = false;
8272
8295
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -8757,7 +8780,8 @@ function mergeProps(...args) {
8757
8780
  else if (isOn(key)) {
8758
8781
  const existing = ret[key];
8759
8782
  const incoming = toMerge[key];
8760
- if (existing !== incoming) {
8783
+ if (existing !== incoming &&
8784
+ !(isArray(existing) && existing.includes(incoming))) {
8761
8785
  ret[key] = existing
8762
8786
  ? [].concat(existing, incoming)
8763
8787
  : incoming;
@@ -9202,23 +9226,23 @@ const PublicInstanceProxyHandlers = {
9202
9226
  const n = accessCache[key];
9203
9227
  if (n !== undefined) {
9204
9228
  switch (n) {
9205
- case 0 /* SETUP */:
9229
+ case 1 /* SETUP */:
9206
9230
  return setupState[key];
9207
- case 1 /* DATA */:
9231
+ case 2 /* DATA */:
9208
9232
  return data[key];
9209
- case 3 /* CONTEXT */:
9233
+ case 4 /* CONTEXT */:
9210
9234
  return ctx[key];
9211
- case 2 /* PROPS */:
9235
+ case 3 /* PROPS */:
9212
9236
  return props[key];
9213
9237
  // default: just fallthrough
9214
9238
  }
9215
9239
  }
9216
9240
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
9217
- accessCache[key] = 0 /* SETUP */;
9241
+ accessCache[key] = 1 /* SETUP */;
9218
9242
  return setupState[key];
9219
9243
  }
9220
9244
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
9221
- accessCache[key] = 1 /* DATA */;
9245
+ accessCache[key] = 2 /* DATA */;
9222
9246
  return data[key];
9223
9247
  }
9224
9248
  else if (
@@ -9226,15 +9250,15 @@ const PublicInstanceProxyHandlers = {
9226
9250
  // props
9227
9251
  (normalizedProps = instance.propsOptions[0]) &&
9228
9252
  hasOwn(normalizedProps, key)) {
9229
- accessCache[key] = 2 /* PROPS */;
9253
+ accessCache[key] = 3 /* PROPS */;
9230
9254
  return props[key];
9231
9255
  }
9232
9256
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9233
- accessCache[key] = 3 /* CONTEXT */;
9257
+ accessCache[key] = 4 /* CONTEXT */;
9234
9258
  return ctx[key];
9235
9259
  }
9236
9260
  else if (!__VUE_OPTIONS_API__ || shouldCacheAccess) {
9237
- accessCache[key] = 4 /* OTHER */;
9261
+ accessCache[key] = 0 /* OTHER */;
9238
9262
  }
9239
9263
  }
9240
9264
  const publicGetter = publicPropertiesMap[key];
@@ -9255,7 +9279,7 @@ const PublicInstanceProxyHandlers = {
9255
9279
  }
9256
9280
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
9257
9281
  // user may set custom properties to `this` that start with `$`
9258
- accessCache[key] = 3 /* CONTEXT */;
9282
+ accessCache[key] = 4 /* CONTEXT */;
9259
9283
  return ctx[key];
9260
9284
  }
9261
9285
  else if (
@@ -9326,7 +9350,7 @@ const PublicInstanceProxyHandlers = {
9326
9350
  },
9327
9351
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
9328
9352
  let normalizedProps;
9329
- return (accessCache[key] !== undefined ||
9353
+ return (!!accessCache[key] ||
9330
9354
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
9331
9355
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
9332
9356
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -10951,7 +10975,7 @@ function isMemoSame(cached, memo) {
10951
10975
  }
10952
10976
 
10953
10977
  // Core API ------------------------------------------------------------------
10954
- const version = "3.2.20";
10978
+ const version = "3.2.24";
10955
10979
  const _ssrUtils = {
10956
10980
  createComponentInstance,
10957
10981
  setupComponent,
@@ -11088,16 +11112,8 @@ function patchClass(el, value, isSVG) {
11088
11112
 
11089
11113
  function patchStyle(el, prev, next) {
11090
11114
  const style = el.style;
11091
- const currentDisplay = style.display;
11092
- if (!next) {
11093
- el.removeAttribute('style');
11094
- }
11095
- else if (isString(next)) {
11096
- if (prev !== next) {
11097
- style.cssText = next;
11098
- }
11099
- }
11100
- else {
11115
+ const isCssString = isString(next);
11116
+ if (next && !isCssString) {
11101
11117
  for (const key in next) {
11102
11118
  setStyle(style, key, next[key]);
11103
11119
  }
@@ -11109,11 +11125,22 @@ function patchStyle(el, prev, next) {
11109
11125
  }
11110
11126
  }
11111
11127
  }
11112
- // indicates that the `display` of the element is controlled by `v-show`,
11113
- // so we always keep the current `display` value regardless of the `style` value,
11114
- // thus handing over control to `v-show`.
11115
- if ('_vod' in el) {
11116
- style.display = currentDisplay;
11128
+ else {
11129
+ const currentDisplay = style.display;
11130
+ if (isCssString) {
11131
+ if (prev !== next) {
11132
+ style.cssText = next;
11133
+ }
11134
+ }
11135
+ else if (prev) {
11136
+ el.removeAttribute('style');
11137
+ }
11138
+ // indicates that the `display` of the element is controlled by `v-show`,
11139
+ // so we always keep the current `display` value regardless of the `style`
11140
+ // value, thus handing over control to `v-show`.
11141
+ if ('_vod' in el) {
11142
+ style.display = currentDisplay;
11143
+ }
11117
11144
  }
11118
11145
  }
11119
11146
  const importantRE = /\s*!important$/;
@@ -11223,12 +11250,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
11223
11250
  el[key] = value == null ? '' : value;
11224
11251
  return;
11225
11252
  }
11226
- if (key === 'value' && el.tagName !== 'PROGRESS') {
11253
+ if (key === 'value' &&
11254
+ el.tagName !== 'PROGRESS' &&
11255
+ // custom elements may use _value internally
11256
+ !el.tagName.includes('-')) {
11227
11257
  // store value as _value as well since
11228
11258
  // non-string values will be stringified.
11229
11259
  el._value = value;
11230
11260
  const newValue = value == null ? '' : value;
11231
- if (el.value !== newValue) {
11261
+ if (el.value !== newValue ||
11262
+ // #4956: always set for OPTION elements because its value falls back to
11263
+ // textContent if no value attribute is present. And setting .value for
11264
+ // OPTION has no side effect
11265
+ el.tagName === 'OPTION') {
11232
11266
  el.value = newValue;
11233
11267
  }
11234
11268
  if (value == null) {
@@ -11497,22 +11531,11 @@ class VueElement extends BaseClass {
11497
11531
  }
11498
11532
  this.attachShadow({ mode: 'open' });
11499
11533
  }
11500
- // set initial attrs
11501
- for (let i = 0; i < this.attributes.length; i++) {
11502
- this._setAttr(this.attributes[i].name);
11503
- }
11504
- // watch future attr changes
11505
- new MutationObserver(mutations => {
11506
- for (const m of mutations) {
11507
- this._setAttr(m.attributeName);
11508
- }
11509
- }).observe(this, { attributes: true });
11510
11534
  }
11511
11535
  connectedCallback() {
11512
11536
  this._connected = true;
11513
11537
  if (!this._instance) {
11514
11538
  this._resolveDef();
11515
- this._update();
11516
11539
  }
11517
11540
  }
11518
11541
  disconnectedCallback() {
@@ -11531,8 +11554,18 @@ class VueElement extends BaseClass {
11531
11554
  if (this._resolved) {
11532
11555
  return;
11533
11556
  }
11557
+ this._resolved = true;
11558
+ // set initial attrs
11559
+ for (let i = 0; i < this.attributes.length; i++) {
11560
+ this._setAttr(this.attributes[i].name);
11561
+ }
11562
+ // watch future attr changes
11563
+ new MutationObserver(mutations => {
11564
+ for (const m of mutations) {
11565
+ this._setAttr(m.attributeName);
11566
+ }
11567
+ }).observe(this, { attributes: true });
11534
11568
  const resolve = (def) => {
11535
- this._resolved = true;
11536
11569
  const { props, styles } = def;
11537
11570
  const hasOptions = !isArray(props);
11538
11571
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -11547,14 +11580,11 @@ class VueElement extends BaseClass {
11547
11580
  }
11548
11581
  }
11549
11582
  }
11550
- if (numberProps) {
11551
- this._numberProps = numberProps;
11552
- this._update();
11553
- }
11583
+ this._numberProps = numberProps;
11554
11584
  // check if there are props set pre-upgrade or connect
11555
11585
  for (const key of Object.keys(this)) {
11556
11586
  if (key[0] !== '_') {
11557
- this._setProp(key, this[key]);
11587
+ this._setProp(key, this[key], true, false);
11558
11588
  }
11559
11589
  }
11560
11590
  // defining getter/setters on prototype
@@ -11568,7 +11598,10 @@ class VueElement extends BaseClass {
11568
11598
  }
11569
11599
  });
11570
11600
  }
11601
+ // apply CSS
11571
11602
  this._applyStyles(styles);
11603
+ // initial render
11604
+ this._update();
11572
11605
  };
11573
11606
  const asyncDef = this._def.__asyncLoader;
11574
11607
  if (asyncDef) {
@@ -11594,10 +11627,10 @@ class VueElement extends BaseClass {
11594
11627
  /**
11595
11628
  * @internal
11596
11629
  */
11597
- _setProp(key, val, shouldReflect = true) {
11630
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
11598
11631
  if (val !== this._props[key]) {
11599
11632
  this._props[key] = val;
11600
- if (this._instance) {
11633
+ if (shouldUpdate && this._instance) {
11601
11634
  this._update();
11602
11635
  }
11603
11636
  // reflect
@@ -11626,7 +11659,7 @@ class VueElement extends BaseClass {
11626
11659
  // HMR
11627
11660
  if ((process.env.NODE_ENV !== 'production')) {
11628
11661
  instance.ceReload = newStyles => {
11629
- // alawys reset styles
11662
+ // always reset styles
11630
11663
  if (this._styles) {
11631
11664
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
11632
11665
  this._styles.length = 0;