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.
@@ -530,7 +530,7 @@ const targetMap = new WeakMap();
530
530
  let effectTrackDepth = 0;
531
531
  let trackOpBit = 1;
532
532
  /**
533
- * The bitwise track markers support at most 30 levels op recursion.
533
+ * The bitwise track markers support at most 30 levels of recursion.
534
534
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
535
535
  * When recursion depth is greater, fall back to using a full cleanup.
536
536
  */
@@ -851,7 +851,7 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
851
851
  function createSetter(shallow = false) {
852
852
  return function set(target, key, value, receiver) {
853
853
  let oldValue = target[key];
854
- if (!shallow) {
854
+ if (!shallow && !isReadonly(value)) {
855
855
  value = toRaw(value);
856
856
  oldValue = toRaw(oldValue);
857
857
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1647,22 +1647,33 @@ function tryWrap(fn) {
1647
1647
 
1648
1648
  let devtools;
1649
1649
  let buffer = [];
1650
+ let devtoolsNotInstalled = false;
1650
1651
  function emit(event, ...args) {
1651
1652
  if (devtools) {
1652
1653
  devtools.emit(event, ...args);
1653
1654
  }
1654
- else {
1655
+ else if (!devtoolsNotInstalled) {
1655
1656
  buffer.push({ event, args });
1656
1657
  }
1657
1658
  }
1658
1659
  function setDevtoolsHook(hook, target) {
1660
+ var _a, _b;
1659
1661
  devtools = hook;
1660
1662
  if (devtools) {
1661
1663
  devtools.enabled = true;
1662
1664
  buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
1663
1665
  buffer = [];
1664
1666
  }
1665
- else {
1667
+ else if (
1668
+ // handle late devtools injection - only do this if we are in an actual
1669
+ // browser environment to avoid the timer handle stalling test runner exit
1670
+ // (#4815)
1671
+ // eslint-disable-next-line no-restricted-globals
1672
+ typeof window !== 'undefined' &&
1673
+ // some envs mock window but not fully
1674
+ window.HTMLElement &&
1675
+ // also exclude jsdom
1676
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1666
1677
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1667
1678
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1668
1679
  replay.push((newHook) => {
@@ -1671,9 +1682,18 @@ function setDevtoolsHook(hook, target) {
1671
1682
  // clear buffer after 3s - the user probably doesn't have devtools installed
1672
1683
  // at all, and keeping the buffer will cause memory leaks (#4738)
1673
1684
  setTimeout(() => {
1674
- buffer = [];
1685
+ if (!devtools) {
1686
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1687
+ devtoolsNotInstalled = true;
1688
+ buffer = [];
1689
+ }
1675
1690
  }, 3000);
1676
1691
  }
1692
+ else {
1693
+ // non-browser env, assume not installed
1694
+ devtoolsNotInstalled = true;
1695
+ buffer = [];
1696
+ }
1677
1697
  }
1678
1698
  function devtoolsInitApp(app, version) {
1679
1699
  emit("app:init" /* APP_INIT */, app, version, {
@@ -2747,7 +2767,8 @@ const BaseTransitionImpl = {
2747
2767
  const rawProps = toRaw(props);
2748
2768
  const { mode } = rawProps;
2749
2769
  // check mode
2750
- if (mode && !['in-out', 'out-in', 'default'].includes(mode)) {
2770
+ if (mode &&
2771
+ mode !== 'in-out' && mode !== 'out-in' && mode !== 'default') {
2751
2772
  warn$1(`invalid <transition> mode: ${mode}`);
2752
2773
  }
2753
2774
  // at this point children has a guaranteed length of 1.
@@ -3387,7 +3408,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
3387
3408
  }
3388
3409
  current = current.parent;
3389
3410
  }
3390
- hook();
3411
+ return hook();
3391
3412
  });
3392
3413
  injectHook(type, wrappedHook, target);
3393
3414
  // In addition to registering it on the target instance, we walk up the parent
@@ -4049,7 +4070,7 @@ function setFullProps(instance, rawProps, props, attrs) {
4049
4070
  }
4050
4071
  }
4051
4072
  else if (!isEmitListener(instance.emitsOptions, key)) {
4052
- if (value !== attrs[key]) {
4073
+ if (!(key in attrs) || value !== attrs[key]) {
4053
4074
  attrs[key] = value;
4054
4075
  hasAttrsChanged = true;
4055
4076
  }
@@ -4461,7 +4482,7 @@ return withDirectives(h(comp), [
4461
4482
  [bar, this.y]
4462
4483
  ])
4463
4484
  */
4464
- const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text');
4485
+ const isBuiltInDirective = /*#__PURE__*/ makeMap('bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo');
4465
4486
  function validateDirectiveName(name) {
4466
4487
  if (isBuiltInDirective(name)) {
4467
4488
  warn$1('Do not use built-in directive ids as custom directive id: ' + name);
@@ -6378,8 +6399,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
6378
6399
  *
6379
6400
  * #2080
6380
6401
  * Inside keyed `template` fragment static children, if a fragment is moved,
6381
- * the children will always moved so that need inherit el form previous nodes
6382
- * to ensure correct moved position.
6402
+ * the children will always be moved. Therefore, in order to ensure correct move
6403
+ * position, el should be inherited from previous nodes.
6383
6404
  */
6384
6405
  function traverseStaticChildren(n1, n2, shallow = false) {
6385
6406
  const ch1 = n1.children;
@@ -7159,7 +7180,8 @@ function mergeProps(...args) {
7159
7180
  else if (isOn(key)) {
7160
7181
  const existing = ret[key];
7161
7182
  const incoming = toMerge[key];
7162
- if (existing !== incoming) {
7183
+ if (existing !== incoming &&
7184
+ !(isArray(existing) && existing.includes(incoming))) {
7163
7185
  ret[key] = existing
7164
7186
  ? [].concat(existing, incoming)
7165
7187
  : incoming;
@@ -7362,23 +7384,23 @@ const PublicInstanceProxyHandlers = {
7362
7384
  const n = accessCache[key];
7363
7385
  if (n !== undefined) {
7364
7386
  switch (n) {
7365
- case 0 /* SETUP */:
7387
+ case 1 /* SETUP */:
7366
7388
  return setupState[key];
7367
- case 1 /* DATA */:
7389
+ case 2 /* DATA */:
7368
7390
  return data[key];
7369
- case 3 /* CONTEXT */:
7391
+ case 4 /* CONTEXT */:
7370
7392
  return ctx[key];
7371
- case 2 /* PROPS */:
7393
+ case 3 /* PROPS */:
7372
7394
  return props[key];
7373
7395
  // default: just fallthrough
7374
7396
  }
7375
7397
  }
7376
7398
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7377
- accessCache[key] = 0 /* SETUP */;
7399
+ accessCache[key] = 1 /* SETUP */;
7378
7400
  return setupState[key];
7379
7401
  }
7380
7402
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7381
- accessCache[key] = 1 /* DATA */;
7403
+ accessCache[key] = 2 /* DATA */;
7382
7404
  return data[key];
7383
7405
  }
7384
7406
  else if (
@@ -7386,15 +7408,15 @@ const PublicInstanceProxyHandlers = {
7386
7408
  // props
7387
7409
  (normalizedProps = instance.propsOptions[0]) &&
7388
7410
  hasOwn(normalizedProps, key)) {
7389
- accessCache[key] = 2 /* PROPS */;
7411
+ accessCache[key] = 3 /* PROPS */;
7390
7412
  return props[key];
7391
7413
  }
7392
7414
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7393
- accessCache[key] = 3 /* CONTEXT */;
7415
+ accessCache[key] = 4 /* CONTEXT */;
7394
7416
  return ctx[key];
7395
7417
  }
7396
7418
  else if (shouldCacheAccess) {
7397
- accessCache[key] = 4 /* OTHER */;
7419
+ accessCache[key] = 0 /* OTHER */;
7398
7420
  }
7399
7421
  }
7400
7422
  const publicGetter = publicPropertiesMap[key];
@@ -7415,7 +7437,7 @@ const PublicInstanceProxyHandlers = {
7415
7437
  }
7416
7438
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7417
7439
  // user may set custom properties to `this` that start with `$`
7418
- accessCache[key] = 3 /* CONTEXT */;
7440
+ accessCache[key] = 4 /* CONTEXT */;
7419
7441
  return ctx[key];
7420
7442
  }
7421
7443
  else if (
@@ -7476,7 +7498,7 @@ const PublicInstanceProxyHandlers = {
7476
7498
  },
7477
7499
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7478
7500
  let normalizedProps;
7479
- return (accessCache[key] !== undefined ||
7501
+ return (!!accessCache[key] ||
7480
7502
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7481
7503
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7482
7504
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -9023,7 +9045,7 @@ function isMemoSame(cached, memo) {
9023
9045
  }
9024
9046
 
9025
9047
  // Core API ------------------------------------------------------------------
9026
- const version = "3.2.20";
9048
+ const version = "3.2.24";
9027
9049
  /**
9028
9050
  * SSR utils for \@vue/server-renderer. Only exposed in cjs builds.
9029
9051
  * @internal
@@ -9145,16 +9167,8 @@ function patchClass(el, value, isSVG) {
9145
9167
 
9146
9168
  function patchStyle(el, prev, next) {
9147
9169
  const style = el.style;
9148
- const currentDisplay = style.display;
9149
- if (!next) {
9150
- el.removeAttribute('style');
9151
- }
9152
- else if (isString(next)) {
9153
- if (prev !== next) {
9154
- style.cssText = next;
9155
- }
9156
- }
9157
- else {
9170
+ const isCssString = isString(next);
9171
+ if (next && !isCssString) {
9158
9172
  for (const key in next) {
9159
9173
  setStyle(style, key, next[key]);
9160
9174
  }
@@ -9166,11 +9180,22 @@ function patchStyle(el, prev, next) {
9166
9180
  }
9167
9181
  }
9168
9182
  }
9169
- // indicates that the `display` of the element is controlled by `v-show`,
9170
- // so we always keep the current `display` value regardless of the `style` value,
9171
- // thus handing over control to `v-show`.
9172
- if ('_vod' in el) {
9173
- style.display = currentDisplay;
9183
+ else {
9184
+ const currentDisplay = style.display;
9185
+ if (isCssString) {
9186
+ if (prev !== next) {
9187
+ style.cssText = next;
9188
+ }
9189
+ }
9190
+ else if (prev) {
9191
+ el.removeAttribute('style');
9192
+ }
9193
+ // indicates that the `display` of the element is controlled by `v-show`,
9194
+ // so we always keep the current `display` value regardless of the `style`
9195
+ // value, thus handing over control to `v-show`.
9196
+ if ('_vod' in el) {
9197
+ style.display = currentDisplay;
9198
+ }
9174
9199
  }
9175
9200
  }
9176
9201
  const importantRE = /\s*!important$/;
@@ -9253,12 +9278,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9253
9278
  el[key] = value == null ? '' : value;
9254
9279
  return;
9255
9280
  }
9256
- if (key === 'value' && el.tagName !== 'PROGRESS') {
9281
+ if (key === 'value' &&
9282
+ el.tagName !== 'PROGRESS' &&
9283
+ // custom elements may use _value internally
9284
+ !el.tagName.includes('-')) {
9257
9285
  // store value as _value as well since
9258
9286
  // non-string values will be stringified.
9259
9287
  el._value = value;
9260
9288
  const newValue = value == null ? '' : value;
9261
- if (el.value !== newValue) {
9289
+ if (el.value !== newValue ||
9290
+ // #4956: always set for OPTION elements because its value falls back to
9291
+ // textContent if no value attribute is present. And setting .value for
9292
+ // OPTION has no side effect
9293
+ el.tagName === 'OPTION') {
9262
9294
  el.value = newValue;
9263
9295
  }
9264
9296
  if (value == null) {
@@ -9516,22 +9548,11 @@ class VueElement extends BaseClass {
9516
9548
  }
9517
9549
  this.attachShadow({ mode: 'open' });
9518
9550
  }
9519
- // set initial attrs
9520
- for (let i = 0; i < this.attributes.length; i++) {
9521
- this._setAttr(this.attributes[i].name);
9522
- }
9523
- // watch future attr changes
9524
- new MutationObserver(mutations => {
9525
- for (const m of mutations) {
9526
- this._setAttr(m.attributeName);
9527
- }
9528
- }).observe(this, { attributes: true });
9529
9551
  }
9530
9552
  connectedCallback() {
9531
9553
  this._connected = true;
9532
9554
  if (!this._instance) {
9533
9555
  this._resolveDef();
9534
- this._update();
9535
9556
  }
9536
9557
  }
9537
9558
  disconnectedCallback() {
@@ -9550,8 +9571,18 @@ class VueElement extends BaseClass {
9550
9571
  if (this._resolved) {
9551
9572
  return;
9552
9573
  }
9574
+ this._resolved = true;
9575
+ // set initial attrs
9576
+ for (let i = 0; i < this.attributes.length; i++) {
9577
+ this._setAttr(this.attributes[i].name);
9578
+ }
9579
+ // watch future attr changes
9580
+ new MutationObserver(mutations => {
9581
+ for (const m of mutations) {
9582
+ this._setAttr(m.attributeName);
9583
+ }
9584
+ }).observe(this, { attributes: true });
9553
9585
  const resolve = (def) => {
9554
- this._resolved = true;
9555
9586
  const { props, styles } = def;
9556
9587
  const hasOptions = !isArray(props);
9557
9588
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -9566,14 +9597,11 @@ class VueElement extends BaseClass {
9566
9597
  }
9567
9598
  }
9568
9599
  }
9569
- if (numberProps) {
9570
- this._numberProps = numberProps;
9571
- this._update();
9572
- }
9600
+ this._numberProps = numberProps;
9573
9601
  // check if there are props set pre-upgrade or connect
9574
9602
  for (const key of Object.keys(this)) {
9575
9603
  if (key[0] !== '_') {
9576
- this._setProp(key, this[key]);
9604
+ this._setProp(key, this[key], true, false);
9577
9605
  }
9578
9606
  }
9579
9607
  // defining getter/setters on prototype
@@ -9587,7 +9615,10 @@ class VueElement extends BaseClass {
9587
9615
  }
9588
9616
  });
9589
9617
  }
9618
+ // apply CSS
9590
9619
  this._applyStyles(styles);
9620
+ // initial render
9621
+ this._update();
9591
9622
  };
9592
9623
  const asyncDef = this._def.__asyncLoader;
9593
9624
  if (asyncDef) {
@@ -9613,10 +9644,10 @@ class VueElement extends BaseClass {
9613
9644
  /**
9614
9645
  * @internal
9615
9646
  */
9616
- _setProp(key, val, shouldReflect = true) {
9647
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9617
9648
  if (val !== this._props[key]) {
9618
9649
  this._props[key] = val;
9619
- if (this._instance) {
9650
+ if (shouldUpdate && this._instance) {
9620
9651
  this._update();
9621
9652
  }
9622
9653
  // reflect
@@ -9645,7 +9676,7 @@ class VueElement extends BaseClass {
9645
9676
  // HMR
9646
9677
  {
9647
9678
  instance.ceReload = newStyles => {
9648
- // alawys reset styles
9679
+ // always reset styles
9649
9680
  if (this._styles) {
9650
9681
  this._styles.forEach(s => this.shadowRoot.removeChild(s));
9651
9682
  this._styles.length = 0;
@@ -11317,7 +11348,6 @@ function getUnnormalizedProps(props, callPath = []) {
11317
11348
  }
11318
11349
  function injectProp(node, prop, context) {
11319
11350
  let propsWithInjection;
11320
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11321
11351
  /**
11322
11352
  * 1. mergeProps(...)
11323
11353
  * 2. toHandlers(...)
@@ -11326,7 +11356,7 @@ function injectProp(node, prop, context) {
11326
11356
  *
11327
11357
  * we need to get the real props before normalization
11328
11358
  */
11329
- let props = originalProps;
11359
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11330
11360
  let callPath = [];
11331
11361
  let parentCall;
11332
11362
  if (props &&
@@ -12291,15 +12321,6 @@ function isSingleElementRoot(root, child) {
12291
12321
  !isSlotOutlet(child));
12292
12322
  }
12293
12323
  function walk(node, context, doNotHoistNode = false) {
12294
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
12295
- // static bindings with expressions. These expressions are guaranteed to be
12296
- // constant so they are still eligible for hoisting, but they are only
12297
- // available at runtime and therefore cannot be evaluated ahead of time.
12298
- // This is only a concern for pre-stringification (via transformHoist by
12299
- // @vue/compiler-dom), but doing it here allows us to perform only one full
12300
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
12301
- // stringification threshold is met.
12302
- let canStringify = true;
12303
12324
  const { children } = node;
12304
12325
  const originalCount = children.length;
12305
12326
  let hoistedCount = 0;
@@ -12312,9 +12333,6 @@ function walk(node, context, doNotHoistNode = false) {
12312
12333
  ? 0 /* NOT_CONSTANT */
12313
12334
  : getConstantType(child, context);
12314
12335
  if (constantType > 0 /* NOT_CONSTANT */) {
12315
- if (constantType < 3 /* CAN_STRINGIFY */) {
12316
- canStringify = false;
12317
- }
12318
12336
  if (constantType >= 2 /* CAN_HOIST */) {
12319
12337
  child.codegenNode.patchFlag =
12320
12338
  -1 /* HOISTED */ + (` /* HOISTED */` );
@@ -12345,17 +12363,10 @@ function walk(node, context, doNotHoistNode = false) {
12345
12363
  }
12346
12364
  }
12347
12365
  }
12348
- else if (child.type === 12 /* TEXT_CALL */) {
12349
- const contentType = getConstantType(child.content, context);
12350
- if (contentType > 0) {
12351
- if (contentType < 3 /* CAN_STRINGIFY */) {
12352
- canStringify = false;
12353
- }
12354
- if (contentType >= 2 /* CAN_HOIST */) {
12355
- child.codegenNode = context.hoist(child.codegenNode);
12356
- hoistedCount++;
12357
- }
12358
- }
12366
+ else if (child.type === 12 /* TEXT_CALL */ &&
12367
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
12368
+ child.codegenNode = context.hoist(child.codegenNode);
12369
+ hoistedCount++;
12359
12370
  }
12360
12371
  // walk further
12361
12372
  if (child.type === 1 /* ELEMENT */) {
@@ -12379,7 +12390,7 @@ function walk(node, context, doNotHoistNode = false) {
12379
12390
  }
12380
12391
  }
12381
12392
  }
12382
- if (canStringify && hoistedCount && context.transformHoist) {
12393
+ if (hoistedCount && context.transformHoist) {
12383
12394
  context.transformHoist(children, context, node);
12384
12395
  }
12385
12396
  // all children were hoisted - the entire children array is hoistable.
@@ -14680,7 +14691,7 @@ function stringifyDynamicPropNames(props) {
14680
14691
  return propsNamesString + `]`;
14681
14692
  }
14682
14693
  function isComponentTag(tag) {
14683
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
14694
+ return tag === 'component' || tag === 'Component';
14684
14695
  }
14685
14696
 
14686
14697
  const transformSlotOutlet = (node, context) => {