@vue/compat 3.2.19 → 3.2.23

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.
@@ -266,12 +266,12 @@ function escapeHtml(string) {
266
266
  continue;
267
267
  }
268
268
  if (lastIndex !== index) {
269
- html += str.substring(lastIndex, index);
269
+ html += str.slice(lastIndex, index);
270
270
  }
271
271
  lastIndex = index + 1;
272
272
  html += escaped;
273
273
  }
274
- return lastIndex !== index ? html + str.substring(lastIndex, index) : html;
274
+ return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
275
275
  }
276
276
 
277
277
  function looseCompareArrays(a, b) {
@@ -361,17 +361,6 @@ const replacer = (_key, val) => {
361
361
  return val;
362
362
  };
363
363
 
364
- /**
365
- * List of @babel/parser plugins that are used for template expression
366
- * transforms and SFC script transforms. By default we enable proposals slated
367
- * for ES2020. This will need to be updated as the spec moves forward.
368
- * Full list at https://babeljs.io/docs/en/next/babel-parser#plugins
369
- */
370
- const babelParserDefaultPlugins = [
371
- 'bigInt',
372
- 'optionalChaining',
373
- 'nullishCoalescingOperator'
374
- ];
375
364
  const EMPTY_OBJ = {};
376
365
  const EMPTY_ARR = [];
377
366
  const NOOP = () => { };
@@ -593,7 +582,7 @@ const targetMap = new WeakMap();
593
582
  let effectTrackDepth = 0;
594
583
  let trackOpBit = 1;
595
584
  /**
596
- * The bitwise track markers support at most 30 levels op recursion.
585
+ * The bitwise track markers support at most 30 levels of recursion.
597
586
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
598
587
  * When recursion depth is greater, fall back to using a full cleanup.
599
588
  */
@@ -902,7 +891,7 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
902
891
  function createSetter(shallow = false) {
903
892
  return function set(target, key, value, receiver) {
904
893
  let oldValue = target[key];
905
- if (!shallow) {
894
+ if (!shallow && !isReadonly(value)) {
906
895
  value = toRaw(value);
907
896
  oldValue = toRaw(oldValue);
908
897
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1505,18 +1494,39 @@ function computed(getterOrOptions, debugOptions) {
1505
1494
  let devtools;
1506
1495
  let buffer = [];
1507
1496
  function setDevtoolsHook(hook, target) {
1497
+ var _a, _b;
1508
1498
  devtools = hook;
1509
1499
  if (devtools) {
1510
1500
  devtools.enabled = true;
1511
1501
  buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
1512
1502
  buffer = [];
1513
1503
  }
1514
- else {
1504
+ else if (
1505
+ // handle late devtools injection - only do this if we are in an actual
1506
+ // browser environment to avoid the timer handle stalling test runner exit
1507
+ // (#4815)
1508
+ // eslint-disable-next-line no-restricted-globals
1509
+ typeof window !== 'undefined' &&
1510
+ // some envs mock window but not fully
1511
+ window.HTMLElement &&
1512
+ // also exclude jsdom
1513
+ !((_b = (_a = window.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.includes('jsdom'))) {
1515
1514
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1516
1515
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1517
1516
  replay.push((newHook) => {
1518
1517
  setDevtoolsHook(newHook, target);
1519
1518
  });
1519
+ // clear buffer after 3s - the user probably doesn't have devtools installed
1520
+ // at all, and keeping the buffer will cause memory leaks (#4738)
1521
+ setTimeout(() => {
1522
+ if (!devtools) {
1523
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1524
+ buffer = [];
1525
+ }
1526
+ }, 3000);
1527
+ }
1528
+ else {
1529
+ buffer = [];
1520
1530
  }
1521
1531
  }
1522
1532
 
@@ -3197,7 +3207,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
3197
3207
  }
3198
3208
  current = current.parent;
3199
3209
  }
3200
- hook();
3210
+ return hook();
3201
3211
  });
3202
3212
  injectHook(type, wrappedHook, target);
3203
3213
  // In addition to registering it on the target instance, we walk up the parent
@@ -4259,7 +4269,7 @@ function createCompatVue(createApp, createSingletonApp) {
4259
4269
  return vm;
4260
4270
  }
4261
4271
  }
4262
- Vue.version = "3.2.19";
4272
+ Vue.version = "3.2.23";
4263
4273
  Vue.config = singletonApp.config;
4264
4274
  Vue.use = (p, ...options) => {
4265
4275
  if (p && isFunction(p.install)) {
@@ -5498,7 +5508,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5498
5508
  }
5499
5509
  };
5500
5510
  const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
5501
- // 2.x compat may pre-creaate the component instance before actually
5511
+ // 2.x compat may pre-create the component instance before actually
5502
5512
  // mounting
5503
5513
  const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
5504
5514
  const instance = compatMountInstance ||
@@ -6278,8 +6288,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
6278
6288
  *
6279
6289
  * #2080
6280
6290
  * Inside keyed `template` fragment static children, if a fragment is moved,
6281
- * the children will always moved so that need inherit el form previous nodes
6282
- * to ensure correct moved position.
6291
+ * the children will always be moved. Therefore, in order to ensure correct move
6292
+ * position, el should be inherited from previous nodes.
6283
6293
  */
6284
6294
  function traverseStaticChildren(n1, n2, shallow = false) {
6285
6295
  const ch1 = n1.children;
@@ -7326,7 +7336,8 @@ function mergeProps(...args) {
7326
7336
  else if (isOn(key)) {
7327
7337
  const existing = ret[key];
7328
7338
  const incoming = toMerge[key];
7329
- if (existing !== incoming) {
7339
+ if (existing !== incoming &&
7340
+ !(isArray(existing) && existing.includes(incoming))) {
7330
7341
  ret[key] = existing
7331
7342
  ? [].concat(existing, incoming)
7332
7343
  : incoming;
@@ -7743,23 +7754,23 @@ const PublicInstanceProxyHandlers = {
7743
7754
  const n = accessCache[key];
7744
7755
  if (n !== undefined) {
7745
7756
  switch (n) {
7746
- case 0 /* SETUP */:
7757
+ case 1 /* SETUP */:
7747
7758
  return setupState[key];
7748
- case 1 /* DATA */:
7759
+ case 2 /* DATA */:
7749
7760
  return data[key];
7750
- case 3 /* CONTEXT */:
7761
+ case 4 /* CONTEXT */:
7751
7762
  return ctx[key];
7752
- case 2 /* PROPS */:
7763
+ case 3 /* PROPS */:
7753
7764
  return props[key];
7754
7765
  // default: just fallthrough
7755
7766
  }
7756
7767
  }
7757
7768
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7758
- accessCache[key] = 0 /* SETUP */;
7769
+ accessCache[key] = 1 /* SETUP */;
7759
7770
  return setupState[key];
7760
7771
  }
7761
7772
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7762
- accessCache[key] = 1 /* DATA */;
7773
+ accessCache[key] = 2 /* DATA */;
7763
7774
  return data[key];
7764
7775
  }
7765
7776
  else if (
@@ -7767,15 +7778,15 @@ const PublicInstanceProxyHandlers = {
7767
7778
  // props
7768
7779
  (normalizedProps = instance.propsOptions[0]) &&
7769
7780
  hasOwn(normalizedProps, key)) {
7770
- accessCache[key] = 2 /* PROPS */;
7781
+ accessCache[key] = 3 /* PROPS */;
7771
7782
  return props[key];
7772
7783
  }
7773
7784
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7774
- accessCache[key] = 3 /* CONTEXT */;
7785
+ accessCache[key] = 4 /* CONTEXT */;
7775
7786
  return ctx[key];
7776
7787
  }
7777
7788
  else if (shouldCacheAccess) {
7778
- accessCache[key] = 4 /* OTHER */;
7789
+ accessCache[key] = 0 /* OTHER */;
7779
7790
  }
7780
7791
  }
7781
7792
  const publicGetter = publicPropertiesMap[key];
@@ -7795,7 +7806,7 @@ const PublicInstanceProxyHandlers = {
7795
7806
  }
7796
7807
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7797
7808
  // user may set custom properties to `this` that start with `$`
7798
- accessCache[key] = 3 /* CONTEXT */;
7809
+ accessCache[key] = 4 /* CONTEXT */;
7799
7810
  return ctx[key];
7800
7811
  }
7801
7812
  else if (
@@ -7838,7 +7849,7 @@ const PublicInstanceProxyHandlers = {
7838
7849
  },
7839
7850
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7840
7851
  let normalizedProps;
7841
- return (accessCache[key] !== undefined ||
7852
+ return (!!accessCache[key] ||
7842
7853
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7843
7854
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7844
7855
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -8809,21 +8820,44 @@ function getContext() {
8809
8820
  * only.
8810
8821
  * @internal
8811
8822
  */
8812
- function mergeDefaults(
8813
- // the base props is compiler-generated and guaranteed to be in this shape.
8814
- props, defaults) {
8823
+ function mergeDefaults(raw, defaults) {
8824
+ const props = isArray(raw)
8825
+ ? raw.reduce((normalized, p) => ((normalized[p] = {}), normalized), {})
8826
+ : raw;
8815
8827
  for (const key in defaults) {
8816
- const val = props[key];
8817
- if (val) {
8818
- val.default = defaults[key];
8828
+ const opt = props[key];
8829
+ if (opt) {
8830
+ if (isArray(opt) || isFunction(opt)) {
8831
+ props[key] = { type: opt, default: defaults[key] };
8832
+ }
8833
+ else {
8834
+ opt.default = defaults[key];
8835
+ }
8819
8836
  }
8820
- else if (val === null) {
8837
+ else if (opt === null) {
8821
8838
  props[key] = { default: defaults[key] };
8822
8839
  }
8823
8840
  else ;
8824
8841
  }
8825
8842
  return props;
8826
8843
  }
8844
+ /**
8845
+ * Used to create a proxy for the rest element when destructuring props with
8846
+ * defineProps().
8847
+ * @internal
8848
+ */
8849
+ function createPropsRestProxy(props, excludedKeys) {
8850
+ const ret = {};
8851
+ for (const key in props) {
8852
+ if (!excludedKeys.includes(key)) {
8853
+ Object.defineProperty(ret, key, {
8854
+ enumerable: true,
8855
+ get: () => props[key]
8856
+ });
8857
+ }
8858
+ }
8859
+ return ret;
8860
+ }
8827
8861
  /**
8828
8862
  * `<script setup>` helper for persisting the current instance context over
8829
8863
  * async/await flows.
@@ -8930,7 +8964,7 @@ function isMemoSame(cached, memo) {
8930
8964
  }
8931
8965
 
8932
8966
  // Core API ------------------------------------------------------------------
8933
- const version = "3.2.19";
8967
+ const version = "3.2.23";
8934
8968
  const _ssrUtils = {
8935
8969
  createComponentInstance,
8936
8970
  setupComponent,
@@ -9067,16 +9101,8 @@ function patchClass(el, value, isSVG) {
9067
9101
 
9068
9102
  function patchStyle(el, prev, next) {
9069
9103
  const style = el.style;
9070
- const currentDisplay = style.display;
9071
- if (!next) {
9072
- el.removeAttribute('style');
9073
- }
9074
- else if (isString(next)) {
9075
- if (prev !== next) {
9076
- style.cssText = next;
9077
- }
9078
- }
9079
- else {
9104
+ const isCssString = isString(next);
9105
+ if (next && !isCssString) {
9080
9106
  for (const key in next) {
9081
9107
  setStyle(style, key, next[key]);
9082
9108
  }
@@ -9088,11 +9114,22 @@ function patchStyle(el, prev, next) {
9088
9114
  }
9089
9115
  }
9090
9116
  }
9091
- // indicates that the `display` of the element is controlled by `v-show`,
9092
- // so we always keep the current `display` value regardless of the `style` value,
9093
- // thus handing over control to `v-show`.
9094
- if ('_vod' in el) {
9095
- style.display = currentDisplay;
9117
+ else {
9118
+ const currentDisplay = style.display;
9119
+ if (isCssString) {
9120
+ if (prev !== next) {
9121
+ style.cssText = next;
9122
+ }
9123
+ }
9124
+ else if (prev) {
9125
+ el.removeAttribute('style');
9126
+ }
9127
+ // indicates that the `display` of the element is controlled by `v-show`,
9128
+ // so we always keep the current `display` value regardless of the `style`
9129
+ // value, thus handing over control to `v-show`.
9130
+ if ('_vod' in el) {
9131
+ style.display = currentDisplay;
9132
+ }
9096
9133
  }
9097
9134
  }
9098
9135
  const importantRE = /\s*!important$/;
@@ -9202,12 +9239,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9202
9239
  el[key] = value == null ? '' : value;
9203
9240
  return;
9204
9241
  }
9205
- if (key === 'value' && el.tagName !== 'PROGRESS') {
9242
+ if (key === 'value' &&
9243
+ el.tagName !== 'PROGRESS' &&
9244
+ // custom elements may use _value internally
9245
+ !el.tagName.includes('-')) {
9206
9246
  // store value as _value as well since
9207
9247
  // non-string values will be stringified.
9208
9248
  el._value = value;
9209
9249
  const newValue = value == null ? '' : value;
9210
- if (el.value !== newValue) {
9250
+ if (el.value !== newValue ||
9251
+ // #4956: always set for OPTION elements because its value falls back to
9252
+ // textContent if no value attribute is present. And setting .value for
9253
+ // OPTION has no side effect
9254
+ el.tagName === 'OPTION') {
9211
9255
  el.value = newValue;
9212
9256
  }
9213
9257
  if (value == null) {
@@ -9466,22 +9510,11 @@ class VueElement extends BaseClass {
9466
9510
  else {
9467
9511
  this.attachShadow({ mode: 'open' });
9468
9512
  }
9469
- // set initial attrs
9470
- for (let i = 0; i < this.attributes.length; i++) {
9471
- this._setAttr(this.attributes[i].name);
9472
- }
9473
- // watch future attr changes
9474
- new MutationObserver(mutations => {
9475
- for (const m of mutations) {
9476
- this._setAttr(m.attributeName);
9477
- }
9478
- }).observe(this, { attributes: true });
9479
9513
  }
9480
9514
  connectedCallback() {
9481
9515
  this._connected = true;
9482
9516
  if (!this._instance) {
9483
9517
  this._resolveDef();
9484
- this._update();
9485
9518
  }
9486
9519
  }
9487
9520
  disconnectedCallback() {
@@ -9500,8 +9533,18 @@ class VueElement extends BaseClass {
9500
9533
  if (this._resolved) {
9501
9534
  return;
9502
9535
  }
9536
+ this._resolved = true;
9537
+ // set initial attrs
9538
+ for (let i = 0; i < this.attributes.length; i++) {
9539
+ this._setAttr(this.attributes[i].name);
9540
+ }
9541
+ // watch future attr changes
9542
+ new MutationObserver(mutations => {
9543
+ for (const m of mutations) {
9544
+ this._setAttr(m.attributeName);
9545
+ }
9546
+ }).observe(this, { attributes: true });
9503
9547
  const resolve = (def) => {
9504
- this._resolved = true;
9505
9548
  const { props, styles } = def;
9506
9549
  const hasOptions = !isArray(props);
9507
9550
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -9516,14 +9559,11 @@ class VueElement extends BaseClass {
9516
9559
  }
9517
9560
  }
9518
9561
  }
9519
- if (numberProps) {
9520
- this._numberProps = numberProps;
9521
- this._update();
9522
- }
9562
+ this._numberProps = numberProps;
9523
9563
  // check if there are props set pre-upgrade or connect
9524
9564
  for (const key of Object.keys(this)) {
9525
9565
  if (key[0] !== '_') {
9526
- this._setProp(key, this[key]);
9566
+ this._setProp(key, this[key], true, false);
9527
9567
  }
9528
9568
  }
9529
9569
  // defining getter/setters on prototype
@@ -9537,7 +9577,10 @@ class VueElement extends BaseClass {
9537
9577
  }
9538
9578
  });
9539
9579
  }
9580
+ // apply CSS
9540
9581
  this._applyStyles(styles);
9582
+ // initial render
9583
+ this._update();
9541
9584
  };
9542
9585
  const asyncDef = this._def.__asyncLoader;
9543
9586
  if (asyncDef) {
@@ -9563,10 +9606,10 @@ class VueElement extends BaseClass {
9563
9606
  /**
9564
9607
  * @internal
9565
9608
  */
9566
- _setProp(key, val, shouldReflect = true) {
9609
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9567
9610
  if (val !== this._props[key]) {
9568
9611
  this._props[key] = val;
9569
- if (this._instance) {
9612
+ if (shouldUpdate && this._instance) {
9570
9613
  this._update();
9571
9614
  }
9572
9615
  // reflect
@@ -10644,6 +10687,7 @@ var runtimeDom = /*#__PURE__*/Object.freeze({
10644
10687
  defineExpose: defineExpose,
10645
10688
  withDefaults: withDefaults,
10646
10689
  mergeDefaults: mergeDefaults,
10690
+ createPropsRestProxy: createPropsRestProxy,
10647
10691
  withAsyncContext: withAsyncContext,
10648
10692
  getCurrentInstance: getCurrentInstance,
10649
10693
  h: h,
@@ -11058,7 +11102,7 @@ const isSimpleIdentifier = (name) => !nonIdentifierRE.test(name);
11058
11102
  const isMemberExpressionNode = (path, context) => {
11059
11103
  try {
11060
11104
  let ret = parser.parseExpression(path, {
11061
- plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
11105
+ plugins: context.expressionPlugins
11062
11106
  });
11063
11107
  if (ret.type === 'TSAsExpression' || ret.type === 'TSTypeAssertion') {
11064
11108
  ret = ret.expression;
@@ -11073,7 +11117,7 @@ const isMemberExpressionNode = (path, context) => {
11073
11117
  };
11074
11118
  const isMemberExpression = isMemberExpressionNode;
11075
11119
  function getInnerRange(loc, offset, length) {
11076
- const source = loc.source.substr(offset, length);
11120
+ const source = loc.source.slice(offset, offset + length);
11077
11121
  const newLoc = {
11078
11122
  source,
11079
11123
  start: advancePositionWithClone(loc.start, loc.source, offset),
@@ -11888,10 +11932,10 @@ function parseAttribute(context, nameSet) {
11888
11932
  isStatic = false;
11889
11933
  if (!content.endsWith(']')) {
11890
11934
  emitError(context, 27 /* X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END */);
11891
- content = content.substr(1);
11935
+ content = content.slice(1);
11892
11936
  }
11893
11937
  else {
11894
- content = content.substr(1, content.length - 2);
11938
+ content = content.slice(1, content.length - 1);
11895
11939
  }
11896
11940
  }
11897
11941
  else if (isSlot) {
@@ -11917,7 +11961,7 @@ function parseAttribute(context, nameSet) {
11917
11961
  valueLoc.end = advancePositionWithClone(valueLoc.start, value.content);
11918
11962
  valueLoc.source = valueLoc.source.slice(1, -1);
11919
11963
  }
11920
- const modifiers = match[3] ? match[3].substr(1).split('.') : [];
11964
+ const modifiers = match[3] ? match[3].slice(1).split('.') : [];
11921
11965
  if (isPropShorthand)
11922
11966
  modifiers.push('prop');
11923
11967
  // 2.x compat v-bind:foo.sync -> v-model:foo
@@ -12135,7 +12179,7 @@ function isEnd(context, mode, ancestors) {
12135
12179
  }
12136
12180
  function startsWithEndTagOpen(source, tag) {
12137
12181
  return (startsWith(source, '</') &&
12138
- source.substr(2, tag.length).toLowerCase() === tag.toLowerCase() &&
12182
+ source.slice(2, 2 + tag.length).toLowerCase() === tag.toLowerCase() &&
12139
12183
  /[\t\r\n\f />]/.test(source[2 + tag.length] || '>'));
12140
12184
  }
12141
12185
 
@@ -13899,12 +13943,19 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
13899
13943
  // it gets correct type
13900
13944
  return `__props.${raw}`;
13901
13945
  }
13946
+ else if (type === "props-aliased" /* PROPS_ALIASED */) {
13947
+ // prop with a different local alias (from defineProps() destructure)
13948
+ return `__props.${bindingMetadata.__propsAliases[raw]}`;
13949
+ }
13902
13950
  }
13903
13951
  else {
13904
13952
  if (type && type.startsWith('setup')) {
13905
13953
  // setup bindings in non-inline mode
13906
13954
  return `$setup.${raw}`;
13907
13955
  }
13956
+ else if (type === "props-aliased" /* PROPS_ALIASED */) {
13957
+ return `$props.${bindingMetadata.__propsAliases[raw]}`;
13958
+ }
13908
13959
  else if (type) {
13909
13960
  return `$${type}.${raw}`;
13910
13961
  }
@@ -13949,7 +14000,7 @@ asRawStatements = false, localVars = Object.create(context.identifiers)) {
13949
14000
  : `(${rawExp})${asParams ? `=>{}` : ``}`;
13950
14001
  try {
13951
14002
  ast = parser.parse(source, {
13952
- plugins: [...context.expressionPlugins, ...babelParserDefaultPlugins]
14003
+ plugins: context.expressionPlugins
13953
14004
  }).program;
13954
14005
  }
13955
14006
  catch (e) {
@@ -15350,7 +15401,7 @@ function stringifyDynamicPropNames(props) {
15350
15401
  return propsNamesString + `]`;
15351
15402
  }
15352
15403
  function isComponentTag(tag) {
15353
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
15404
+ return tag === 'component' || tag === 'Component';
15354
15405
  }
15355
15406
  function processInlineRef(context, raw) {
15356
15407
  const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
@@ -18348,7 +18399,7 @@ const decodeHtml = (rawText, asAttr) => {
18348
18399
  maxCRNameLength = Object.keys(namedCharacterReferences).reduce((max, name) => Math.max(max, name.length), 0);
18349
18400
  }
18350
18401
  for (let length = maxCRNameLength; !value && length > 0; --length) {
18351
- name = rawText.substr(1, length);
18402
+ name = rawText.slice(1, 1 + length);
18352
18403
  value = namedCharacterReferences[name];
18353
18404
  }
18354
18405
  if (value) {