vue 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.
@@ -533,7 +533,7 @@ var Vue = (function (exports) {
533
533
  let effectTrackDepth = 0;
534
534
  let trackOpBit = 1;
535
535
  /**
536
- * The bitwise track markers support at most 30 levels op recursion.
536
+ * The bitwise track markers support at most 30 levels of recursion.
537
537
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
538
538
  * When recursion depth is greater, fall back to using a full cleanup.
539
539
  */
@@ -854,7 +854,7 @@ var Vue = (function (exports) {
854
854
  function createSetter(shallow = false) {
855
855
  return function set(target, key, value, receiver) {
856
856
  let oldValue = target[key];
857
- if (!shallow) {
857
+ if (!shallow && !isReadonly(value)) {
858
858
  value = toRaw(value);
859
859
  oldValue = toRaw(oldValue);
860
860
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1649,22 +1649,33 @@ var Vue = (function (exports) {
1649
1649
  }
1650
1650
 
1651
1651
  let buffer = [];
1652
+ let devtoolsNotInstalled = false;
1652
1653
  function emit(event, ...args) {
1653
1654
  if (exports.devtools) {
1654
1655
  exports.devtools.emit(event, ...args);
1655
1656
  }
1656
- else {
1657
+ else if (!devtoolsNotInstalled) {
1657
1658
  buffer.push({ event, args });
1658
1659
  }
1659
1660
  }
1660
1661
  function setDevtoolsHook(hook, target) {
1662
+ var _a, _b;
1661
1663
  exports.devtools = hook;
1662
1664
  if (exports.devtools) {
1663
1665
  exports.devtools.enabled = true;
1664
1666
  buffer.forEach(({ event, args }) => exports.devtools.emit(event, ...args));
1665
1667
  buffer = [];
1666
1668
  }
1667
- else {
1669
+ else if (
1670
+ // handle late devtools injection - only do this if we are in an actual
1671
+ // browser environment to avoid the timer handle stalling test runner exit
1672
+ // (#4815)
1673
+ // eslint-disable-next-line no-restricted-globals
1674
+ typeof window !== 'undefined' &&
1675
+ // some envs mock window but not fully
1676
+ window.HTMLElement &&
1677
+ // also exclude jsdom
1678
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1668
1679
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1669
1680
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1670
1681
  replay.push((newHook) => {
@@ -1673,9 +1684,18 @@ var Vue = (function (exports) {
1673
1684
  // clear buffer after 3s - the user probably doesn't have devtools installed
1674
1685
  // at all, and keeping the buffer will cause memory leaks (#4738)
1675
1686
  setTimeout(() => {
1676
- buffer = [];
1687
+ if (!exports.devtools) {
1688
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1689
+ devtoolsNotInstalled = true;
1690
+ buffer = [];
1691
+ }
1677
1692
  }, 3000);
1678
1693
  }
1694
+ else {
1695
+ // non-browser env, assume not installed
1696
+ devtoolsNotInstalled = true;
1697
+ buffer = [];
1698
+ }
1679
1699
  }
1680
1700
  function devtoolsInitApp(app, version) {
1681
1701
  emit("app:init" /* APP_INIT */, app, version, {
@@ -2749,7 +2769,8 @@ var Vue = (function (exports) {
2749
2769
  const rawProps = toRaw(props);
2750
2770
  const { mode } = rawProps;
2751
2771
  // check mode
2752
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
2772
+ if (mode &&
2773
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
2753
2774
  warn$1(`invalid <transition> mode: ${mode}`);
2754
2775
  }
2755
2776
  // at this point children has a guaranteed length of 1.
@@ -3389,7 +3410,7 @@ var Vue = (function (exports) {
3389
3410
  }
3390
3411
  current = current.parent;
3391
3412
  }
3392
- hook();
3413
+ return hook();
3393
3414
  });
3394
3415
  injectHook(type, wrappedHook, target);
3395
3416
  // In addition to registering it on the target instance, we walk up the parent
@@ -4051,7 +4072,7 @@ var Vue = (function (exports) {
4051
4072
  }
4052
4073
  }
4053
4074
  else if (!isEmitListener(instance.emitsOptions, key)) {
4054
- if (value !== attrs[key]) {
4075
+ if (!(key in attrs) || value !== attrs[key]) {
4055
4076
  attrs[key] = value;
4056
4077
  hasAttrsChanged = true;
4057
4078
  }
@@ -4463,7 +4484,7 @@ var Vue = (function (exports) {
4463
4484
  [bar, this.y]
4464
4485
  ])
4465
4486
  */
4466
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
4487
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
4467
4488
  function validateDirectiveName(name) {
4468
4489
  if (isBuiltInDirective(name)) {
4469
4490
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -6380,8 +6401,8 @@ var Vue = (function (exports) {
6380
6401
  *
6381
6402
  * #2080
6382
6403
  * Inside keyed `template` fragment static children, if a fragment is moved,
6383
- * the children will always moved so that need inherit el form previous nodes
6384
- * to ensure correct moved position.
6404
+ * the children will always be moved. Therefore, in order to ensure correct move
6405
+ * position, el should be inherited from previous nodes.
6385
6406
  */
6386
6407
  function traverseStaticChildren(n1, n2, shallow = false) {
6387
6408
  const ch1 = n1.children;
@@ -7161,7 +7182,8 @@ var Vue = (function (exports) {
7161
7182
  else if (isOn(key)) {
7162
7183
  const existing = ret[key];
7163
7184
  const incoming = toMerge[key];
7164
- if (existing !== incoming) {
7185
+ if (existing !== incoming &&
7186
+ !(isArray(existing) && existing.includes(incoming))) {
7165
7187
  ret[key] = existing
7166
7188
  ? [].concat(existing, incoming)
7167
7189
  : incoming;
@@ -7364,23 +7386,23 @@ var Vue = (function (exports) {
7364
7386
  const n = accessCache[key];
7365
7387
  if (n !== undefined) {
7366
7388
  switch (n) {
7367
- case 0 /* SETUP */:
7389
+ case 1 /* SETUP */:
7368
7390
  return setupState[key];
7369
- case 1 /* DATA */:
7391
+ case 2 /* DATA */:
7370
7392
  return data[key];
7371
- case 3 /* CONTEXT */:
7393
+ case 4 /* CONTEXT */:
7372
7394
  return ctx[key];
7373
- case 2 /* PROPS */:
7395
+ case 3 /* PROPS */:
7374
7396
  return props[key];
7375
7397
  // default: just fallthrough
7376
7398
  }
7377
7399
  }
7378
7400
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7379
- accessCache[key] = 0 /* SETUP */;
7401
+ accessCache[key] = 1 /* SETUP */;
7380
7402
  return setupState[key];
7381
7403
  }
7382
7404
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7383
- accessCache[key] = 1 /* DATA */;
7405
+ accessCache[key] = 2 /* DATA */;
7384
7406
  return data[key];
7385
7407
  }
7386
7408
  else if (
@@ -7388,15 +7410,15 @@ var Vue = (function (exports) {
7388
7410
  // props
7389
7411
  (normalizedProps = instance.propsOptions[0]) &&
7390
7412
  hasOwn(normalizedProps, key)) {
7391
- accessCache[key] = 2 /* PROPS */;
7413
+ accessCache[key] = 3 /* PROPS */;
7392
7414
  return props[key];
7393
7415
  }
7394
7416
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7395
- accessCache[key] = 3 /* CONTEXT */;
7417
+ accessCache[key] = 4 /* CONTEXT */;
7396
7418
  return ctx[key];
7397
7419
  }
7398
7420
  else if (shouldCacheAccess) {
7399
- accessCache[key] = 4 /* OTHER */;
7421
+ accessCache[key] = 0 /* OTHER */;
7400
7422
  }
7401
7423
  }
7402
7424
  const publicGetter = publicPropertiesMap[key];
@@ -7417,7 +7439,7 @@ var Vue = (function (exports) {
7417
7439
  }
7418
7440
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7419
7441
  // user may set custom properties to `this` that start with `$`
7420
- accessCache[key] = 3 /* CONTEXT */;
7442
+ accessCache[key] = 4 /* CONTEXT */;
7421
7443
  return ctx[key];
7422
7444
  }
7423
7445
  else if (
@@ -7478,7 +7500,7 @@ var Vue = (function (exports) {
7478
7500
  },
7479
7501
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7480
7502
  let normalizedProps;
7481
- return (accessCache[key] !== undefined ||
7503
+ return (!!accessCache[key] ||
7482
7504
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7483
7505
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7484
7506
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -9020,7 +9042,7 @@ var Vue = (function (exports) {
9020
9042
  }
9021
9043
 
9022
9044
  // Core API ------------------------------------------------------------------
9023
- const version = "3.2.20";
9045
+ const version = "3.2.24";
9024
9046
  /**
9025
9047
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9026
9048
  * @internal
@@ -9142,16 +9164,8 @@ var Vue = (function (exports) {
9142
9164
 
9143
9165
  function patchStyle(el, prev, next) {
9144
9166
  const style = el.style;
9145
- const currentDisplay = style.display;
9146
- if (!next) {
9147
- el.removeAttribute('style');
9148
- }
9149
- else if (isString(next)) {
9150
- if (prev !== next) {
9151
- style.cssText = next;
9152
- }
9153
- }
9154
- else {
9167
+ const isCssString = isString(next);
9168
+ if (next && !isCssString) {
9155
9169
  for (const key in next) {
9156
9170
  setStyle(style, key, next[key]);
9157
9171
  }
@@ -9163,11 +9177,22 @@ var Vue = (function (exports) {
9163
9177
  }
9164
9178
  }
9165
9179
  }
9166
- // indicates that the `display` of the element is controlled by `v-show`,
9167
- // so we always keep the current `display` value regardless of the `style` value,
9168
- // thus handing over control to `v-show`.
9169
- if ('_vod' in el) {
9170
- style.display = currentDisplay;
9180
+ else {
9181
+ const currentDisplay = style.display;
9182
+ if (isCssString) {
9183
+ if (prev !== next) {
9184
+ style.cssText = next;
9185
+ }
9186
+ }
9187
+ else if (prev) {
9188
+ el.removeAttribute('style');
9189
+ }
9190
+ // indicates that the `display` of the element is controlled by `v-show`,
9191
+ // so we always keep the current `display` value regardless of the `style`
9192
+ // value, thus handing over control to `v-show`.
9193
+ if ('_vod' in el) {
9194
+ style.display = currentDisplay;
9195
+ }
9171
9196
  }
9172
9197
  }
9173
9198
  const importantRE = /\s*!important$/;
@@ -9250,12 +9275,19 @@ var Vue = (function (exports) {
9250
9275
  el[key] = value == null ? '' : value;
9251
9276
  return;
9252
9277
  }
9253
- if (key === 'value' && el.tagName !== 'PROGRESS') {
9278
+ if (key === 'value' &&
9279
+ el.tagName !== 'PROGRESS' &&
9280
+ // custom elements may use _value internally
9281
+ !el.tagName.includes('-')) {
9254
9282
  // store value as _value as well since
9255
9283
  // non-string values will be stringified.
9256
9284
  el._value = value;
9257
9285
  const newValue = value == null ? '' : value;
9258
- if (el.value !== newValue) {
9286
+ if (el.value !== newValue ||
9287
+ // #4956: always set for OPTION elements because its value falls back to
9288
+ // textContent if no value attribute is present. And setting .value for
9289
+ // OPTION has no side effect
9290
+ el.tagName === 'OPTION') {
9259
9291
  el.value = newValue;
9260
9292
  }
9261
9293
  if (value == null) {
@@ -9513,22 +9545,11 @@ var Vue = (function (exports) {
9513
9545
  }
9514
9546
  this.attachShadow({ mode: 'open' });
9515
9547
  }
9516
- // set initial attrs
9517
- for (let i = 0; i < this.attributes.length; i++) {
9518
- this._setAttr(this.attributes[i].name);
9519
- }
9520
- // watch future attr changes
9521
- new MutationObserver(mutations => {
9522
- for (const m of mutations) {
9523
- this._setAttr(m.attributeName);
9524
- }
9525
- }).observe(this, { attributes: true });
9526
9548
  }
9527
9549
  connectedCallback() {
9528
9550
  this._connected = true;
9529
9551
  if (!this._instance) {
9530
9552
  this._resolveDef();
9531
- this._update();
9532
9553
  }
9533
9554
  }
9534
9555
  disconnectedCallback() {
@@ -9547,8 +9568,18 @@ var Vue = (function (exports) {
9547
9568
  if (this._resolved) {
9548
9569
  return;
9549
9570
  }
9571
+ this._resolved = true;
9572
+ // set initial attrs
9573
+ for (let i = 0; i < this.attributes.length; i++) {
9574
+ this._setAttr(this.attributes[i].name);
9575
+ }
9576
+ // watch future attr changes
9577
+ new MutationObserver(mutations => {
9578
+ for (const m of mutations) {
9579
+ this._setAttr(m.attributeName);
9580
+ }
9581
+ }).observe(this, { attributes: true });
9550
9582
  const resolve = (def) => {
9551
- this._resolved = true;
9552
9583
  const { props, styles } = def;
9553
9584
  const hasOptions = !isArray(props);
9554
9585
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -9563,14 +9594,11 @@ var Vue = (function (exports) {
9563
9594
  }
9564
9595
  }
9565
9596
  }
9566
- if (numberProps) {
9567
- this._numberProps = numberProps;
9568
- this._update();
9569
- }
9597
+ this._numberProps = numberProps;
9570
9598
  // check if there are props set pre-upgrade or connect
9571
9599
  for (const key of Object.keys(this)) {
9572
9600
  if (key[0] !== '_') {
9573
- this._setProp(key, this[key]);
9601
+ this._setProp(key, this[key], true, false);
9574
9602
  }
9575
9603
  }
9576
9604
  // defining getter/setters on prototype
@@ -9584,7 +9612,10 @@ var Vue = (function (exports) {
9584
9612
  }
9585
9613
  });
9586
9614
  }
9615
+ // apply CSS
9587
9616
  this._applyStyles(styles);
9617
+ // initial render
9618
+ this._update();
9588
9619
  };
9589
9620
  const asyncDef = this._def.__asyncLoader;
9590
9621
  if (asyncDef) {
@@ -9610,10 +9641,10 @@ var Vue = (function (exports) {
9610
9641
  /**
9611
9642
  * @internal
9612
9643
  */
9613
- _setProp(key, val, shouldReflect = true) {
9644
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9614
9645
  if (val !== this._props[key]) {
9615
9646
  this._props[key] = val;
9616
- if (this._instance) {
9647
+ if (shouldUpdate && this._instance) {
9617
9648
  this._update();
9618
9649
  }
9619
9650
  // reflect
@@ -9642,7 +9673,7 @@ var Vue = (function (exports) {
9642
9673
  // HMR
9643
9674
  {
9644
9675
  instance.ceReload = newStyles => {
9645
- // alawys reset styles
9676
+ // always reset styles
9646
9677
  if (this._styles) {
9647
9678
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
9648
9679
  this._styles.length = 0;
@@ -11155,7 +11186,6 @@ var Vue = (function (exports) {
11155
11186
  }
11156
11187
  function injectProp(node, prop, context) {
11157
11188
  let propsWithInjection;
11158
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11159
11189
  /**
11160
11190
  * 1. mergeProps(...)
11161
11191
  * 2. toHandlers(...)
@@ -11164,7 +11194,7 @@ var Vue = (function (exports) {
11164
11194
  *
11165
11195
  * we need to get the real props before normalization
11166
11196
  */
11167
- let props = originalProps;
11197
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11168
11198
  let callPath = [];
11169
11199
  let parentCall;
11170
11200
  if (props &&
@@ -12129,15 +12159,6 @@ var Vue = (function (exports) {
12129
12159
  !isSlotOutlet(child));
12130
12160
  }
12131
12161
  function walk(node, context, doNotHoistNode = false) {
12132
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
12133
- // static bindings with expressions. These expressions are guaranteed to be
12134
- // constant so they are still eligible for hoisting, but they are only
12135
- // available at runtime and therefore cannot be evaluated ahead of time.
12136
- // This is only a concern for pre-stringification (via transformHoist by
12137
- // @vue/compiler-dom), but doing it here allows us to perform only one full
12138
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
12139
- // stringification threshold is met.
12140
- let canStringify = true;
12141
12162
  const { children } = node;
12142
12163
  const originalCount = children.length;
12143
12164
  let hoistedCount = 0;
@@ -12150,9 +12171,6 @@ var Vue = (function (exports) {
12150
12171
  ? 0 /* NOT_CONSTANT */
12151
12172
  : getConstantType(child, context);
12152
12173
  if (constantType > 0 /* NOT_CONSTANT */) {
12153
- if (constantType < 3 /* CAN_STRINGIFY */) {
12154
- canStringify = false;
12155
- }
12156
12174
  if (constantType >= 2 /* CAN_HOIST */) {
12157
12175
  child.codegenNode.patchFlag =
12158
12176
  -1 /* HOISTED */ + (` /* HOISTED */` );
@@ -12183,17 +12201,10 @@ var Vue = (function (exports) {
12183
12201
  }
12184
12202
  }
12185
12203
  }
12186
- else if (child.type === 12 /* TEXT_CALL */) {
12187
- const contentType = getConstantType(child.content, context);
12188
- if (contentType > 0) {
12189
- if (contentType < 3 /* CAN_STRINGIFY */) {
12190
- canStringify = false;
12191
- }
12192
- if (contentType >= 2 /* CAN_HOIST */) {
12193
- child.codegenNode = context.hoist(child.codegenNode);
12194
- hoistedCount++;
12195
- }
12196
- }
12204
+ else if (child.type === 12 /* TEXT_CALL */ &&
12205
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
12206
+ child.codegenNode = context.hoist(child.codegenNode);
12207
+ hoistedCount++;
12197
12208
  }
12198
12209
  // walk further
12199
12210
  if (child.type === 1 /* ELEMENT */) {
@@ -12217,7 +12228,7 @@ var Vue = (function (exports) {
12217
12228
  }
12218
12229
  }
12219
12230
  }
12220
- if (canStringify && hoistedCount && context.transformHoist) {
12231
+ if (hoistedCount && context.transformHoist) {
12221
12232
  context.transformHoist(children, context, node);
12222
12233
  }
12223
12234
  // all children were hoisted - the entire children array is hoistable.
@@ -14518,7 +14529,7 @@ var Vue = (function (exports) {
14518
14529
  return propsNamesString + `]`;
14519
14530
  }
14520
14531
  function isComponentTag(tag) {
14521
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
14532
+ return tag === 'component' || tag === 'Component';
14522
14533
  }
14523
14534
 
14524
14535
  const transformSlotOutlet = (node, context) => {