@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.
@@ -582,7 +582,7 @@ const targetMap = new WeakMap();
582
582
  let effectTrackDepth = 0;
583
583
  let trackOpBit = 1;
584
584
  /**
585
- * The bitwise track markers support at most 30 levels op recursion.
585
+ * The bitwise track markers support at most 30 levels of recursion.
586
586
  * This value is chosen to enable modern JS engines to use a SMI on all platforms.
587
587
  * When recursion depth is greater, fall back to using a full cleanup.
588
588
  */
@@ -891,7 +891,7 @@ const shallowSet = /*#__PURE__*/ createSetter(true);
891
891
  function createSetter(shallow = false) {
892
892
  return function set(target, key, value, receiver) {
893
893
  let oldValue = target[key];
894
- if (!shallow) {
894
+ if (!shallow && !isReadonly(value)) {
895
895
  value = toRaw(value);
896
896
  oldValue = toRaw(oldValue);
897
897
  if (!isArray(target) && isRef(oldValue) && !isRef(value)) {
@@ -1494,13 +1494,23 @@ function computed(getterOrOptions, debugOptions) {
1494
1494
  let devtools;
1495
1495
  let buffer = [];
1496
1496
  function setDevtoolsHook(hook, target) {
1497
+ var _a, _b;
1497
1498
  devtools = hook;
1498
1499
  if (devtools) {
1499
1500
  devtools.enabled = true;
1500
1501
  buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
1501
1502
  buffer = [];
1502
1503
  }
1503
- 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'))) {
1504
1514
  const replay = (target.__VUE_DEVTOOLS_HOOK_REPLAY__ =
1505
1515
  target.__VUE_DEVTOOLS_HOOK_REPLAY__ || []);
1506
1516
  replay.push((newHook) => {
@@ -1509,9 +1519,15 @@ function setDevtoolsHook(hook, target) {
1509
1519
  // clear buffer after 3s - the user probably doesn't have devtools installed
1510
1520
  // at all, and keeping the buffer will cause memory leaks (#4738)
1511
1521
  setTimeout(() => {
1512
- buffer = [];
1522
+ if (!devtools) {
1523
+ target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
1524
+ buffer = [];
1525
+ }
1513
1526
  }, 3000);
1514
1527
  }
1528
+ else {
1529
+ buffer = [];
1530
+ }
1515
1531
  }
1516
1532
 
1517
1533
  function warnDeprecation(key, instance, ...args) {
@@ -3191,7 +3207,7 @@ function registerKeepAliveHook(hook, type, target = currentInstance) {
3191
3207
  }
3192
3208
  current = current.parent;
3193
3209
  }
3194
- hook();
3210
+ return hook();
3195
3211
  });
3196
3212
  injectHook(type, wrappedHook, target);
3197
3213
  // In addition to registering it on the target instance, we walk up the parent
@@ -3863,7 +3879,7 @@ function setFullProps(instance, rawProps, props, attrs) {
3863
3879
  continue;
3864
3880
  }
3865
3881
  }
3866
- if (value !== attrs[key]) {
3882
+ if (!(key in attrs) || value !== attrs[key]) {
3867
3883
  attrs[key] = value;
3868
3884
  hasAttrsChanged = true;
3869
3885
  }
@@ -4253,7 +4269,7 @@ function createCompatVue(createApp, createSingletonApp) {
4253
4269
  return vm;
4254
4270
  }
4255
4271
  }
4256
- Vue.version = "3.2.20";
4272
+ Vue.version = "3.2.24";
4257
4273
  Vue.config = singletonApp.config;
4258
4274
  Vue.use = (p, ...options) => {
4259
4275
  if (p && isFunction(p.install)) {
@@ -5492,7 +5508,7 @@ function baseCreateRenderer(options, createHydrationFns) {
5492
5508
  }
5493
5509
  };
5494
5510
  const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, isSVG, optimized) => {
5495
- // 2.x compat may pre-creaate the component instance before actually
5511
+ // 2.x compat may pre-create the component instance before actually
5496
5512
  // mounting
5497
5513
  const compatMountInstance = initialVNode.isCompatRoot && initialVNode.component;
5498
5514
  const instance = compatMountInstance ||
@@ -6272,8 +6288,8 @@ function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
6272
6288
  *
6273
6289
  * #2080
6274
6290
  * Inside keyed `template` fragment static children, if a fragment is moved,
6275
- * the children will always moved so that need inherit el form previous nodes
6276
- * 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.
6277
6293
  */
6278
6294
  function traverseStaticChildren(n1, n2, shallow = false) {
6279
6295
  const ch1 = n1.children;
@@ -6870,6 +6886,7 @@ function convertLegacyFunctionalComponent(comp) {
6870
6886
  };
6871
6887
  Func.props = comp.props;
6872
6888
  Func.displayName = comp.name;
6889
+ Func.compatConfig = comp.compatConfig;
6873
6890
  // v2 functional components do not inherit attrs
6874
6891
  Func.inheritAttrs = false;
6875
6892
  normalizedFunctionalComponentMap.set(comp, Func);
@@ -7320,7 +7337,8 @@ function mergeProps(...args) {
7320
7337
  else if (isOn(key)) {
7321
7338
  const existing = ret[key];
7322
7339
  const incoming = toMerge[key];
7323
- if (existing !== incoming) {
7340
+ if (existing !== incoming &&
7341
+ !(isArray(existing) && existing.includes(incoming))) {
7324
7342
  ret[key] = existing
7325
7343
  ? [].concat(existing, incoming)
7326
7344
  : incoming;
@@ -7737,23 +7755,23 @@ const PublicInstanceProxyHandlers = {
7737
7755
  const n = accessCache[key];
7738
7756
  if (n !== undefined) {
7739
7757
  switch (n) {
7740
- case 0 /* SETUP */:
7758
+ case 1 /* SETUP */:
7741
7759
  return setupState[key];
7742
- case 1 /* DATA */:
7760
+ case 2 /* DATA */:
7743
7761
  return data[key];
7744
- case 3 /* CONTEXT */:
7762
+ case 4 /* CONTEXT */:
7745
7763
  return ctx[key];
7746
- case 2 /* PROPS */:
7764
+ case 3 /* PROPS */:
7747
7765
  return props[key];
7748
7766
  // default: just fallthrough
7749
7767
  }
7750
7768
  }
7751
7769
  else if (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) {
7752
- accessCache[key] = 0 /* SETUP */;
7770
+ accessCache[key] = 1 /* SETUP */;
7753
7771
  return setupState[key];
7754
7772
  }
7755
7773
  else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
7756
- accessCache[key] = 1 /* DATA */;
7774
+ accessCache[key] = 2 /* DATA */;
7757
7775
  return data[key];
7758
7776
  }
7759
7777
  else if (
@@ -7761,15 +7779,15 @@ const PublicInstanceProxyHandlers = {
7761
7779
  // props
7762
7780
  (normalizedProps = instance.propsOptions[0]) &&
7763
7781
  hasOwn(normalizedProps, key)) {
7764
- accessCache[key] = 2 /* PROPS */;
7782
+ accessCache[key] = 3 /* PROPS */;
7765
7783
  return props[key];
7766
7784
  }
7767
7785
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7768
- accessCache[key] = 3 /* CONTEXT */;
7786
+ accessCache[key] = 4 /* CONTEXT */;
7769
7787
  return ctx[key];
7770
7788
  }
7771
7789
  else if (shouldCacheAccess) {
7772
- accessCache[key] = 4 /* OTHER */;
7790
+ accessCache[key] = 0 /* OTHER */;
7773
7791
  }
7774
7792
  }
7775
7793
  const publicGetter = publicPropertiesMap[key];
@@ -7789,7 +7807,7 @@ const PublicInstanceProxyHandlers = {
7789
7807
  }
7790
7808
  else if (ctx !== EMPTY_OBJ && hasOwn(ctx, key)) {
7791
7809
  // user may set custom properties to `this` that start with `$`
7792
- accessCache[key] = 3 /* CONTEXT */;
7810
+ accessCache[key] = 4 /* CONTEXT */;
7793
7811
  return ctx[key];
7794
7812
  }
7795
7813
  else if (
@@ -7832,7 +7850,7 @@ const PublicInstanceProxyHandlers = {
7832
7850
  },
7833
7851
  has({ _: { data, setupState, accessCache, ctx, appContext, propsOptions } }, key) {
7834
7852
  let normalizedProps;
7835
- return (accessCache[key] !== undefined ||
7853
+ return (!!accessCache[key] ||
7836
7854
  (data !== EMPTY_OBJ && hasOwn(data, key)) ||
7837
7855
  (setupState !== EMPTY_OBJ && hasOwn(setupState, key)) ||
7838
7856
  ((normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key)) ||
@@ -8947,7 +8965,7 @@ function isMemoSame(cached, memo) {
8947
8965
  }
8948
8966
 
8949
8967
  // Core API ------------------------------------------------------------------
8950
- const version = "3.2.20";
8968
+ const version = "3.2.24";
8951
8969
  const _ssrUtils = {
8952
8970
  createComponentInstance,
8953
8971
  setupComponent,
@@ -9084,16 +9102,8 @@ function patchClass(el, value, isSVG) {
9084
9102
 
9085
9103
  function patchStyle(el, prev, next) {
9086
9104
  const style = el.style;
9087
- const currentDisplay = style.display;
9088
- if (!next) {
9089
- el.removeAttribute('style');
9090
- }
9091
- else if (isString(next)) {
9092
- if (prev !== next) {
9093
- style.cssText = next;
9094
- }
9095
- }
9096
- else {
9105
+ const isCssString = isString(next);
9106
+ if (next && !isCssString) {
9097
9107
  for (const key in next) {
9098
9108
  setStyle(style, key, next[key]);
9099
9109
  }
@@ -9105,11 +9115,22 @@ function patchStyle(el, prev, next) {
9105
9115
  }
9106
9116
  }
9107
9117
  }
9108
- // indicates that the `display` of the element is controlled by `v-show`,
9109
- // so we always keep the current `display` value regardless of the `style` value,
9110
- // thus handing over control to `v-show`.
9111
- if ('_vod' in el) {
9112
- style.display = currentDisplay;
9118
+ else {
9119
+ const currentDisplay = style.display;
9120
+ if (isCssString) {
9121
+ if (prev !== next) {
9122
+ style.cssText = next;
9123
+ }
9124
+ }
9125
+ else if (prev) {
9126
+ el.removeAttribute('style');
9127
+ }
9128
+ // indicates that the `display` of the element is controlled by `v-show`,
9129
+ // so we always keep the current `display` value regardless of the `style`
9130
+ // value, thus handing over control to `v-show`.
9131
+ if ('_vod' in el) {
9132
+ style.display = currentDisplay;
9133
+ }
9113
9134
  }
9114
9135
  }
9115
9136
  const importantRE = /\s*!important$/;
@@ -9219,12 +9240,19 @@ prevChildren, parentComponent, parentSuspense, unmountChildren) {
9219
9240
  el[key] = value == null ? '' : value;
9220
9241
  return;
9221
9242
  }
9222
- if (key === 'value' && el.tagName !== 'PROGRESS') {
9243
+ if (key === 'value' &&
9244
+ el.tagName !== 'PROGRESS' &&
9245
+ // custom elements may use _value internally
9246
+ !el.tagName.includes('-')) {
9223
9247
  // store value as _value as well since
9224
9248
  // non-string values will be stringified.
9225
9249
  el._value = value;
9226
9250
  const newValue = value == null ? '' : value;
9227
- if (el.value !== newValue) {
9251
+ if (el.value !== newValue ||
9252
+ // #4956: always set for OPTION elements because its value falls back to
9253
+ // textContent if no value attribute is present. And setting .value for
9254
+ // OPTION has no side effect
9255
+ el.tagName === 'OPTION') {
9228
9256
  el.value = newValue;
9229
9257
  }
9230
9258
  if (value == null) {
@@ -9483,22 +9511,11 @@ class VueElement extends BaseClass {
9483
9511
  else {
9484
9512
  this.attachShadow({ mode: 'open' });
9485
9513
  }
9486
- // set initial attrs
9487
- for (let i = 0; i < this.attributes.length; i++) {
9488
- this._setAttr(this.attributes[i].name);
9489
- }
9490
- // watch future attr changes
9491
- new MutationObserver(mutations => {
9492
- for (const m of mutations) {
9493
- this._setAttr(m.attributeName);
9494
- }
9495
- }).observe(this, { attributes: true });
9496
9514
  }
9497
9515
  connectedCallback() {
9498
9516
  this._connected = true;
9499
9517
  if (!this._instance) {
9500
9518
  this._resolveDef();
9501
- this._update();
9502
9519
  }
9503
9520
  }
9504
9521
  disconnectedCallback() {
@@ -9517,8 +9534,18 @@ class VueElement extends BaseClass {
9517
9534
  if (this._resolved) {
9518
9535
  return;
9519
9536
  }
9537
+ this._resolved = true;
9538
+ // set initial attrs
9539
+ for (let i = 0; i < this.attributes.length; i++) {
9540
+ this._setAttr(this.attributes[i].name);
9541
+ }
9542
+ // watch future attr changes
9543
+ new MutationObserver(mutations => {
9544
+ for (const m of mutations) {
9545
+ this._setAttr(m.attributeName);
9546
+ }
9547
+ }).observe(this, { attributes: true });
9520
9548
  const resolve = (def) => {
9521
- this._resolved = true;
9522
9549
  const { props, styles } = def;
9523
9550
  const hasOptions = !isArray(props);
9524
9551
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
@@ -9533,14 +9560,11 @@ class VueElement extends BaseClass {
9533
9560
  }
9534
9561
  }
9535
9562
  }
9536
- if (numberProps) {
9537
- this._numberProps = numberProps;
9538
- this._update();
9539
- }
9563
+ this._numberProps = numberProps;
9540
9564
  // check if there are props set pre-upgrade or connect
9541
9565
  for (const key of Object.keys(this)) {
9542
9566
  if (key[0] !== '_') {
9543
- this._setProp(key, this[key]);
9567
+ this._setProp(key, this[key], true, false);
9544
9568
  }
9545
9569
  }
9546
9570
  // defining getter/setters on prototype
@@ -9554,7 +9578,10 @@ class VueElement extends BaseClass {
9554
9578
  }
9555
9579
  });
9556
9580
  }
9581
+ // apply CSS
9557
9582
  this._applyStyles(styles);
9583
+ // initial render
9584
+ this._update();
9558
9585
  };
9559
9586
  const asyncDef = this._def.__asyncLoader;
9560
9587
  if (asyncDef) {
@@ -9580,10 +9607,10 @@ class VueElement extends BaseClass {
9580
9607
  /**
9581
9608
  * @internal
9582
9609
  */
9583
- _setProp(key, val, shouldReflect = true) {
9610
+ _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
9584
9611
  if (val !== this._props[key]) {
9585
9612
  this._props[key] = val;
9586
- if (this._instance) {
9613
+ if (shouldUpdate && this._instance) {
9587
9614
  this._update();
9588
9615
  }
9589
9616
  // reflect
@@ -11194,7 +11221,6 @@ function getUnnormalizedProps(props, callPath = []) {
11194
11221
  }
11195
11222
  function injectProp(node, prop, context) {
11196
11223
  let propsWithInjection;
11197
- const originalProps = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11198
11224
  /**
11199
11225
  * 1. mergeProps(...)
11200
11226
  * 2. toHandlers(...)
@@ -11203,7 +11229,7 @@ function injectProp(node, prop, context) {
11203
11229
  *
11204
11230
  * we need to get the real props before normalization
11205
11231
  */
11206
- let props = originalProps;
11232
+ let props = node.type === 13 /* VNODE_CALL */ ? node.props : node.arguments[2];
11207
11233
  let callPath = [];
11208
11234
  let parentCall;
11209
11235
  if (props &&
@@ -12170,15 +12196,6 @@ function isSingleElementRoot(root, child) {
12170
12196
  !isSlotOutlet(child));
12171
12197
  }
12172
12198
  function walk$1(node, context, doNotHoistNode = false) {
12173
- // Some transforms, e.g. transformAssetUrls from @vue/compiler-sfc, replaces
12174
- // static bindings with expressions. These expressions are guaranteed to be
12175
- // constant so they are still eligible for hoisting, but they are only
12176
- // available at runtime and therefore cannot be evaluated ahead of time.
12177
- // This is only a concern for pre-stringification (via transformHoist by
12178
- // @vue/compiler-dom), but doing it here allows us to perform only one full
12179
- // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
12180
- // stringification threshold is met.
12181
- let canStringify = true;
12182
12199
  const { children } = node;
12183
12200
  const originalCount = children.length;
12184
12201
  let hoistedCount = 0;
@@ -12191,9 +12208,6 @@ function walk$1(node, context, doNotHoistNode = false) {
12191
12208
  ? 0 /* NOT_CONSTANT */
12192
12209
  : getConstantType(child, context);
12193
12210
  if (constantType > 0 /* NOT_CONSTANT */) {
12194
- if (constantType < 3 /* CAN_STRINGIFY */) {
12195
- canStringify = false;
12196
- }
12197
12211
  if (constantType >= 2 /* CAN_HOIST */) {
12198
12212
  child.codegenNode.patchFlag =
12199
12213
  -1 /* HOISTED */ + (``);
@@ -12224,17 +12238,10 @@ function walk$1(node, context, doNotHoistNode = false) {
12224
12238
  }
12225
12239
  }
12226
12240
  }
12227
- else if (child.type === 12 /* TEXT_CALL */) {
12228
- const contentType = getConstantType(child.content, context);
12229
- if (contentType > 0) {
12230
- if (contentType < 3 /* CAN_STRINGIFY */) {
12231
- canStringify = false;
12232
- }
12233
- if (contentType >= 2 /* CAN_HOIST */) {
12234
- child.codegenNode = context.hoist(child.codegenNode);
12235
- hoistedCount++;
12236
- }
12237
- }
12241
+ else if (child.type === 12 /* TEXT_CALL */ &&
12242
+ getConstantType(child.content, context) >= 2 /* CAN_HOIST */) {
12243
+ child.codegenNode = context.hoist(child.codegenNode);
12244
+ hoistedCount++;
12238
12245
  }
12239
12246
  // walk further
12240
12247
  if (child.type === 1 /* ELEMENT */) {
@@ -12258,7 +12265,7 @@ function walk$1(node, context, doNotHoistNode = false) {
12258
12265
  }
12259
12266
  }
12260
12267
  }
12261
- if (canStringify && hoistedCount && context.transformHoist) {
12268
+ if (hoistedCount && context.transformHoist) {
12262
12269
  context.transformHoist(children, context, node);
12263
12270
  }
12264
12271
  // all children were hoisted - the entire children array is hoistable.
@@ -15375,7 +15382,7 @@ function stringifyDynamicPropNames(props) {
15375
15382
  return propsNamesString + `]`;
15376
15383
  }
15377
15384
  function isComponentTag(tag) {
15378
- return tag[0].toLowerCase() + tag.slice(1) === 'component';
15385
+ return tag === 'component' || tag === 'Component';
15379
15386
  }
15380
15387
  function processInlineRef(context, raw) {
15381
15388
  const body = [createSimpleExpression(`_refs['${raw}'] = _value`)];
@@ -18804,6 +18811,11 @@ const transformShow = (dir, node, context) => {
18804
18811
  /**
18805
18812
  * This module is Node-only.
18806
18813
  */
18814
+ /**
18815
+ * Regex for replacing placeholders for embedded constant variables
18816
+ * (e.g. import URL string constants generated by compiler-sfc)
18817
+ */
18818
+ const expReplaceRE = /__VUE_EXP_START__(.*?)__VUE_EXP_END__/g;
18807
18819
  /**
18808
18820
  * Turn eligible hoisted static trees into stringified static nodes, e.g.
18809
18821
  *
@@ -18840,7 +18852,7 @@ const stringifyStatic = (children, context, parent) => {
18840
18852
  ec >= 5 /* ELEMENT_WITH_BINDING_COUNT */) {
18841
18853
  // combine all currently eligible nodes into a single static vnode call
18842
18854
  const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
18843
- JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')),
18855
+ JSON.stringify(currentChunk.map(node => stringifyNode(node, context)).join('')).replace(expReplaceRE, `" + $1 + "`),
18844
18856
  // the 2nd argument indicates the number of DOM nodes this static vnode
18845
18857
  // will insert / hydrate
18846
18858
  String(currentChunk.length)
@@ -18908,7 +18920,7 @@ const replaceHoist = (node, replacement, context) => {
18908
18920
  const isNonStringifiable = /*#__PURE__*/ makeMap(`caption,thead,tr,th,tbody,td,tfoot,colgroup,col`);
18909
18921
  /**
18910
18922
  * for a hoisted node, analyze it and return:
18911
- * - false: bailed (contains runtime constant)
18923
+ * - false: bailed (contains non-stringifiable props or runtime constant)
18912
18924
  * - [nc, ec] where
18913
18925
  * - nc is the number of nodes inside
18914
18926
  * - ec is the number of element with bindings inside
@@ -18946,6 +18958,11 @@ function analyzeNode(node) {
18946
18958
  (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns)))) {
18947
18959
  return bail();
18948
18960
  }
18961
+ if (p.exp &&
18962
+ (p.exp.type === 8 /* COMPOUND_EXPRESSION */ ||
18963
+ p.exp.constType < 3 /* CAN_STRINGIFY */)) {
18964
+ return bail();
18965
+ }
18949
18966
  }
18950
18967
  }
18951
18968
  for (let i = 0; i < node.children.length; i++) {
@@ -19001,8 +19018,15 @@ function stringifyElement(node, context) {
19001
19018
  }
19002
19019
  }
19003
19020
  else if (p.type === 7 /* DIRECTIVE */ && p.name === 'bind') {
19021
+ const exp = p.exp;
19022
+ if (exp.content[0] === '_') {
19023
+ // internally generated string constant references
19024
+ // e.g. imported URL strings via compiler-sfc transformAssetUrl plugin
19025
+ res += ` ${p.arg.content}="__VUE_EXP_START__${exp.content}__VUE_EXP_END__"`;
19026
+ continue;
19027
+ }
19004
19028
  // constant v-bind, e.g. :foo="1"
19005
- let evaluated = evaluateConstant(p.exp);
19029
+ let evaluated = evaluateConstant(exp);
19006
19030
  if (evaluated != null) {
19007
19031
  const arg = p.arg && p.arg.content;
19008
19032
  if (arg === 'class') {