vue 3.2.41 → 3.2.42

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.
@@ -92,27 +92,6 @@ function generateCodeFrame(source, start = 0, end = source.length) {
92
92
  return res.join('\n');
93
93
  }
94
94
 
95
- /**
96
- * On the client we only need to offer special cases for boolean attributes that
97
- * have different names from their corresponding dom properties:
98
- * - itemscope -> N/A
99
- * - allowfullscreen -> allowFullscreen
100
- * - formnovalidate -> formNoValidate
101
- * - ismap -> isMap
102
- * - nomodule -> noModule
103
- * - novalidate -> noValidate
104
- * - readonly -> readOnly
105
- */
106
- const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
107
- const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
108
- /**
109
- * Boolean attributes should be included if the value is truthy or ''.
110
- * e.g. `<select multiple>` compiles to `{ multiple: '' }`
111
- */
112
- function includeBooleanAttr(value) {
113
- return !!value || value === '';
114
- }
115
-
116
95
  function normalizeStyle(value) {
117
96
  if (isArray(value)) {
118
97
  const res = {};
@@ -137,10 +116,14 @@ function normalizeStyle(value) {
137
116
  }
138
117
  }
139
118
  const listDelimiterRE = /;(?![^(]*\))/g;
140
- const propertyDelimiterRE = /:(.+)/;
119
+ const propertyDelimiterRE = /:([^]+)/;
120
+ const styleCommentRE = /\/\*.*?\*\//gs;
141
121
  function parseStringStyle(cssText) {
142
122
  const ret = {};
143
- cssText.split(listDelimiterRE).forEach(item => {
123
+ cssText
124
+ .replace(styleCommentRE, '')
125
+ .split(listDelimiterRE)
126
+ .forEach(item => {
144
127
  if (item) {
145
128
  const tmp = item.split(propertyDelimiterRE);
146
129
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -222,6 +205,27 @@ const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
222
205
  */
223
206
  const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
224
207
 
208
+ /**
209
+ * On the client we only need to offer special cases for boolean attributes that
210
+ * have different names from their corresponding dom properties:
211
+ * - itemscope -> N/A
212
+ * - allowfullscreen -> allowFullscreen
213
+ * - formnovalidate -> formNoValidate
214
+ * - ismap -> isMap
215
+ * - nomodule -> noModule
216
+ * - novalidate -> noValidate
217
+ * - readonly -> readOnly
218
+ */
219
+ const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
220
+ const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
221
+ /**
222
+ * Boolean attributes should be included if the value is truthy or ''.
223
+ * e.g. `<select multiple>` compiles to `{ multiple: '' }`
224
+ */
225
+ function includeBooleanAttr(value) {
226
+ return !!value || value === '';
227
+ }
228
+
225
229
  function looseCompareArrays(a, b) {
226
230
  if (a.length !== b.length)
227
231
  return false;
@@ -725,8 +729,9 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
725
729
  deps = [...depsMap.values()];
726
730
  }
727
731
  else if (key === 'length' && isArray(target)) {
732
+ const newLength = toNumber(newValue);
728
733
  depsMap.forEach((dep, key) => {
729
- if (key === 'length' || key >= newValue) {
734
+ if (key === 'length' || key >= newLength) {
730
735
  deps.push(dep);
731
736
  }
732
737
  });
@@ -2261,7 +2266,7 @@ function emit$1(instance, event, ...rawArgs) {
2261
2266
  const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
2262
2267
  const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
2263
2268
  if (trim) {
2264
- args = rawArgs.map(a => a.trim());
2269
+ args = rawArgs.map(a => (isString(a) ? a.trim() : a));
2265
2270
  }
2266
2271
  if (number) {
2267
2272
  args = rawArgs.map(toNumber);
@@ -3323,7 +3328,9 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3323
3328
  callWithErrorHandling(fn, instance, 4 /* ErrorCodes.WATCH_CLEANUP */);
3324
3329
  };
3325
3330
  };
3326
- let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
3331
+ let oldValue = isMultiSource
3332
+ ? new Array(source.length).fill(INITIAL_WATCHER_VALUE)
3333
+ : INITIAL_WATCHER_VALUE;
3327
3334
  const job = () => {
3328
3335
  if (!effect.active) {
3329
3336
  return;
@@ -3344,7 +3351,10 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3344
3351
  callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
3345
3352
  newValue,
3346
3353
  // pass undefined as the old value when it's changed for the first time
3347
- oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
3354
+ oldValue === INITIAL_WATCHER_VALUE ||
3355
+ (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3356
+ ? undefined
3357
+ : oldValue,
3348
3358
  onCleanup
3349
3359
  ]);
3350
3360
  oldValue = newValue;
@@ -3392,12 +3402,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3392
3402
  else {
3393
3403
  effect.run();
3394
3404
  }
3395
- return () => {
3405
+ const unwatch = () => {
3396
3406
  effect.stop();
3397
3407
  if (instance && instance.scope) {
3398
3408
  remove(instance.scope.effects, effect);
3399
3409
  }
3400
3410
  };
3411
+ return unwatch;
3401
3412
  }
3402
3413
  // this.$watch
3403
3414
  function instanceWatch(source, value, options) {
@@ -3579,7 +3590,11 @@ const BaseTransitionImpl = {
3579
3590
  // return placeholder node and queue update when leave finishes
3580
3591
  leavingHooks.afterLeave = () => {
3581
3592
  state.isLeaving = false;
3582
- instance.update();
3593
+ // #6835
3594
+ // it also needs to be updated when active is undefined
3595
+ if (instance.update.active !== false) {
3596
+ instance.update();
3597
+ }
3583
3598
  };
3584
3599
  return emptyPlaceholder(child);
3585
3600
  }
@@ -4097,7 +4112,8 @@ const KeepAliveImpl = {
4097
4112
  : comp);
4098
4113
  const { include, exclude, max } = props;
4099
4114
  if ((include && (!name || !matches(include, name))) ||
4100
- (exclude && name && matches(exclude, name))) {
4115
+ (exclude && name && matches(exclude, name)) ||
4116
+ (hmrDirtyComponents.has(comp))) {
4101
4117
  current = vnode;
4102
4118
  return rawVNode;
4103
4119
  }
@@ -4309,23 +4325,25 @@ function withDirectives(vnode, directives) {
4309
4325
  const bindings = vnode.dirs || (vnode.dirs = []);
4310
4326
  for (let i = 0; i < directives.length; i++) {
4311
4327
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4312
- if (isFunction(dir)) {
4313
- dir = {
4314
- mounted: dir,
4315
- updated: dir
4316
- };
4317
- }
4318
- if (dir.deep) {
4319
- traverse(value);
4328
+ if (dir) {
4329
+ if (isFunction(dir)) {
4330
+ dir = {
4331
+ mounted: dir,
4332
+ updated: dir
4333
+ };
4334
+ }
4335
+ if (dir.deep) {
4336
+ traverse(value);
4337
+ }
4338
+ bindings.push({
4339
+ dir,
4340
+ instance,
4341
+ value,
4342
+ oldValue: void 0,
4343
+ arg,
4344
+ modifiers
4345
+ });
4320
4346
  }
4321
- bindings.push({
4322
- dir,
4323
- instance,
4324
- value,
4325
- oldValue: void 0,
4326
- arg,
4327
- modifiers
4328
- });
4329
4347
  }
4330
4348
  return vnode;
4331
4349
  }
@@ -5538,7 +5556,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
5538
5556
  if (validatePropName(normalizedKey)) {
5539
5557
  const opt = raw[key];
5540
5558
  const prop = (normalized[normalizedKey] =
5541
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
5559
+ isArray(opt) || isFunction(opt) ? { type: opt } : Object.assign({}, opt));
5542
5560
  if (prop) {
5543
5561
  const booleanIndex = getTypeIndex(Boolean, prop.type);
5544
5562
  const stringIndex = getTypeIndex(String, prop.type);
@@ -8875,6 +8893,9 @@ function getExposeProxy(instance) {
8875
8893
  else if (key in publicPropertiesMap) {
8876
8894
  return publicPropertiesMap[key](instance);
8877
8895
  }
8896
+ },
8897
+ has(target, key) {
8898
+ return key in target || key in publicPropertiesMap;
8878
8899
  }
8879
8900
  })));
8880
8901
  }
@@ -9328,7 +9349,7 @@ function isMemoSame(cached, memo) {
9328
9349
  }
9329
9350
 
9330
9351
  // Core API ------------------------------------------------------------------
9331
- const version = "3.2.41";
9352
+ const version = "3.2.42";
9332
9353
  /**
9333
9354
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
9334
9355
  * @internal
@@ -9847,7 +9868,7 @@ class VueElement extends BaseClass {
9847
9868
  }
9848
9869
  }).observe(this, { attributes: true });
9849
9870
  const resolve = (def) => {
9850
- const { props, styles } = def;
9871
+ const { props = {}, styles } = def;
9851
9872
  const hasOptions = !isArray(props);
9852
9873
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
9853
9874
  // cast Number-type props set before resolve
@@ -9894,10 +9915,11 @@ class VueElement extends BaseClass {
9894
9915
  }
9895
9916
  _setAttr(key) {
9896
9917
  let value = this.getAttribute(key);
9897
- if (this._numberProps && this._numberProps[key]) {
9918
+ const camelKey = camelize(key);
9919
+ if (this._numberProps && this._numberProps[camelKey]) {
9898
9920
  value = toNumber(value);
9899
9921
  }
9900
- this._setProp(camelize(key), value, false);
9922
+ this._setProp(camelKey, value, false);
9901
9923
  }
9902
9924
  /**
9903
9925
  * @internal
@@ -10290,11 +10312,11 @@ function getTransitionInfo(el, expectedType) {
10290
10312
  const styles = window.getComputedStyle(el);
10291
10313
  // JSDOM may return undefined for transition properties
10292
10314
  const getStyleProperties = (key) => (styles[key] || '').split(', ');
10293
- const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
10294
- const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
10315
+ const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
10316
+ const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
10295
10317
  const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
10296
- const animationDelays = getStyleProperties(ANIMATION + 'Delay');
10297
- const animationDurations = getStyleProperties(ANIMATION + 'Duration');
10318
+ const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
10319
+ const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
10298
10320
  const animationTimeout = getTimeout(animationDelays, animationDurations);
10299
10321
  let type = null;
10300
10322
  let timeout = 0;
@@ -10329,7 +10351,7 @@ function getTransitionInfo(el, expectedType) {
10329
10351
  : 0;
10330
10352
  }
10331
10353
  const hasTransform = type === TRANSITION &&
10332
- /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
10354
+ /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
10333
10355
  return {
10334
10356
  type,
10335
10357
  timeout,
@@ -11641,7 +11663,10 @@ function injectProp(node, prop, context) {
11641
11663
  // if doesn't override user provided keys
11642
11664
  const first = props.arguments[0];
11643
11665
  if (!isString(first) && first.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
11644
- first.properties.unshift(prop);
11666
+ // #6631
11667
+ if (!hasProp(prop, first)) {
11668
+ first.properties.unshift(prop);
11669
+ }
11645
11670
  }
11646
11671
  else {
11647
11672
  if (props.callee === TO_HANDLERS) {
@@ -11658,14 +11683,7 @@ function injectProp(node, prop, context) {
11658
11683
  !propsWithInjection && (propsWithInjection = props);
11659
11684
  }
11660
11685
  else if (props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
11661
- let alreadyExists = false;
11662
- // check existing key to avoid overriding user provided keys
11663
- if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
11664
- const propKeyName = prop.key.content;
11665
- alreadyExists = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
11666
- p.key.content === propKeyName);
11667
- }
11668
- if (!alreadyExists) {
11686
+ if (!hasProp(prop, props)) {
11669
11687
  props.properties.unshift(prop);
11670
11688
  }
11671
11689
  propsWithInjection = props;
@@ -11700,6 +11718,16 @@ function injectProp(node, prop, context) {
11700
11718
  }
11701
11719
  }
11702
11720
  }
11721
+ // check existing key to avoid overriding user provided keys
11722
+ function hasProp(prop, props) {
11723
+ let result = false;
11724
+ if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
11725
+ const propKeyName = prop.key.content;
11726
+ result = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
11727
+ p.key.content === propKeyName);
11728
+ }
11729
+ return result;
11730
+ }
11703
11731
  function toValidAssetId(name, type) {
11704
11732
  // see issue#4422, we need adding identifier on validAssetId if variable `name` has specific character
11705
11733
  return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
@@ -11962,13 +11990,18 @@ function parseChildren(context, mode, ancestors) {
11962
11990
  const next = nodes[i + 1];
11963
11991
  // Remove if:
11964
11992
  // - the whitespace is the first or last node, or:
11965
- // - (condense mode) the whitespace is adjacent to a comment, or:
11993
+ // - (condense mode) the whitespace is between twos comments, or:
11994
+ // - (condense mode) the whitespace is between comment and element, or:
11966
11995
  // - (condense mode) the whitespace is between two elements AND contains newline
11967
11996
  if (!prev ||
11968
11997
  !next ||
11969
11998
  (shouldCondense &&
11970
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
11971
- next.type === 3 /* NodeTypes.COMMENT */ ||
11999
+ ((prev.type === 3 /* NodeTypes.COMMENT */ &&
12000
+ next.type === 3 /* NodeTypes.COMMENT */) ||
12001
+ (prev.type === 3 /* NodeTypes.COMMENT */ &&
12002
+ next.type === 1 /* NodeTypes.ELEMENT */) ||
12003
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
12004
+ next.type === 3 /* NodeTypes.COMMENT */) ||
11972
12005
  (prev.type === 1 /* NodeTypes.ELEMENT */ &&
11973
12006
  next.type === 1 /* NodeTypes.ELEMENT */ &&
11974
12007
  /[\r\n]/.test(node.content))))) {
@@ -15077,7 +15110,7 @@ function processSlotOutlet(node, context) {
15077
15110
  };
15078
15111
  }
15079
15112
 
15080
- const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
15113
+ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
15081
15114
  const transformOn = (dir, node, context, augmentor) => {
15082
15115
  const { loc, modifiers, arg } = dir;
15083
15116
  if (!dir.exp && !modifiers.length) {
@@ -15091,10 +15124,10 @@ const transformOn = (dir, node, context, augmentor) => {
15091
15124
  if (rawName.startsWith('vue:')) {
15092
15125
  rawName = `vnode-${rawName.slice(4)}`;
15093
15126
  }
15094
- const eventString = node.tagType === 1 /* ElementTypes.COMPONENT */ ||
15127
+ const eventString = node.tagType !== 0 /* ElementTypes.ELEMENT */ ||
15095
15128
  rawName.startsWith('vnode') ||
15096
15129
  !/[A-Z]/.test(rawName)
15097
- ? // for component and vnode lifecycle event listeners, auto convert
15130
+ ? // for non-element and vnode lifecycle event listeners, auto convert
15098
15131
  // it to camelCase. See issue #2249
15099
15132
  toHandlerKey(camelize(rawName))
15100
15133
  : // preserve case for plain element listeners that have uppercase