vue 3.2.41 → 3.2.43

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.
@@ -95,27 +95,6 @@ var Vue = (function (exports) {
95
95
  return res.join('\n');
96
96
  }
97
97
 
98
- /**
99
- * On the client we only need to offer special cases for boolean attributes that
100
- * have different names from their corresponding dom properties:
101
- * - itemscope -> N/A
102
- * - allowfullscreen -> allowFullscreen
103
- * - formnovalidate -> formNoValidate
104
- * - ismap -> isMap
105
- * - nomodule -> noModule
106
- * - novalidate -> noValidate
107
- * - readonly -> readOnly
108
- */
109
- const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
110
- const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
111
- /**
112
- * Boolean attributes should be included if the value is truthy or ''.
113
- * e.g. `<select multiple>` compiles to `{ multiple: '' }`
114
- */
115
- function includeBooleanAttr(value) {
116
- return !!value || value === '';
117
- }
118
-
119
98
  function normalizeStyle(value) {
120
99
  if (isArray(value)) {
121
100
  const res = {};
@@ -140,10 +119,14 @@ var Vue = (function (exports) {
140
119
  }
141
120
  }
142
121
  const listDelimiterRE = /;(?![^(]*\))/g;
143
- const propertyDelimiterRE = /:(.+)/;
122
+ const propertyDelimiterRE = /:([^]+)/;
123
+ const styleCommentRE = /\/\*.*?\*\//gs;
144
124
  function parseStringStyle(cssText) {
145
125
  const ret = {};
146
- cssText.split(listDelimiterRE).forEach(item => {
126
+ cssText
127
+ .replace(styleCommentRE, '')
128
+ .split(listDelimiterRE)
129
+ .forEach(item => {
147
130
  if (item) {
148
131
  const tmp = item.split(propertyDelimiterRE);
149
132
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -225,6 +208,27 @@ var Vue = (function (exports) {
225
208
  */
226
209
  const isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);
227
210
 
211
+ /**
212
+ * On the client we only need to offer special cases for boolean attributes that
213
+ * have different names from their corresponding dom properties:
214
+ * - itemscope -> N/A
215
+ * - allowfullscreen -> allowFullscreen
216
+ * - formnovalidate -> formNoValidate
217
+ * - ismap -> isMap
218
+ * - nomodule -> noModule
219
+ * - novalidate -> noValidate
220
+ * - readonly -> readOnly
221
+ */
222
+ const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
223
+ const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
224
+ /**
225
+ * Boolean attributes should be included if the value is truthy or ''.
226
+ * e.g. `<select multiple>` compiles to `{ multiple: '' }`
227
+ */
228
+ function includeBooleanAttr(value) {
229
+ return !!value || value === '';
230
+ }
231
+
228
232
  function looseCompareArrays(a, b) {
229
233
  if (a.length !== b.length)
230
234
  return false;
@@ -728,8 +732,9 @@ var Vue = (function (exports) {
728
732
  deps = [...depsMap.values()];
729
733
  }
730
734
  else if (key === 'length' && isArray(target)) {
735
+ const newLength = toNumber(newValue);
731
736
  depsMap.forEach((dep, key) => {
732
- if (key === 'length' || key >= newValue) {
737
+ if (key === 'length' || key >= newLength) {
733
738
  deps.push(dep);
734
739
  }
735
740
  });
@@ -2263,7 +2268,7 @@ var Vue = (function (exports) {
2263
2268
  const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
2264
2269
  const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
2265
2270
  if (trim) {
2266
- args = rawArgs.map(a => a.trim());
2271
+ args = rawArgs.map(a => (isString(a) ? a.trim() : a));
2267
2272
  }
2268
2273
  if (number) {
2269
2274
  args = rawArgs.map(toNumber);
@@ -3325,7 +3330,9 @@ var Vue = (function (exports) {
3325
3330
  callWithErrorHandling(fn, instance, 4 /* ErrorCodes.WATCH_CLEANUP */);
3326
3331
  };
3327
3332
  };
3328
- let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
3333
+ let oldValue = isMultiSource
3334
+ ? new Array(source.length).fill(INITIAL_WATCHER_VALUE)
3335
+ : INITIAL_WATCHER_VALUE;
3329
3336
  const job = () => {
3330
3337
  if (!effect.active) {
3331
3338
  return;
@@ -3346,7 +3353,10 @@ var Vue = (function (exports) {
3346
3353
  callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
3347
3354
  newValue,
3348
3355
  // pass undefined as the old value when it's changed for the first time
3349
- oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
3356
+ oldValue === INITIAL_WATCHER_VALUE ||
3357
+ (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3358
+ ? []
3359
+ : oldValue,
3350
3360
  onCleanup
3351
3361
  ]);
3352
3362
  oldValue = newValue;
@@ -3394,12 +3404,13 @@ var Vue = (function (exports) {
3394
3404
  else {
3395
3405
  effect.run();
3396
3406
  }
3397
- return () => {
3407
+ const unwatch = () => {
3398
3408
  effect.stop();
3399
3409
  if (instance && instance.scope) {
3400
3410
  remove(instance.scope.effects, effect);
3401
3411
  }
3402
3412
  };
3413
+ return unwatch;
3403
3414
  }
3404
3415
  // this.$watch
3405
3416
  function instanceWatch(source, value, options) {
@@ -3581,7 +3592,11 @@ var Vue = (function (exports) {
3581
3592
  // return placeholder node and queue update when leave finishes
3582
3593
  leavingHooks.afterLeave = () => {
3583
3594
  state.isLeaving = false;
3584
- instance.update();
3595
+ // #6835
3596
+ // it also needs to be updated when active is undefined
3597
+ if (instance.update.active !== false) {
3598
+ instance.update();
3599
+ }
3585
3600
  };
3586
3601
  return emptyPlaceholder(child);
3587
3602
  }
@@ -4099,7 +4114,8 @@ var Vue = (function (exports) {
4099
4114
  : comp);
4100
4115
  const { include, exclude, max } = props;
4101
4116
  if ((include && (!name || !matches(include, name))) ||
4102
- (exclude && name && matches(exclude, name))) {
4117
+ (exclude && name && matches(exclude, name)) ||
4118
+ (hmrDirtyComponents.has(comp))) {
4103
4119
  current = vnode;
4104
4120
  return rawVNode;
4105
4121
  }
@@ -4311,23 +4327,25 @@ var Vue = (function (exports) {
4311
4327
  const bindings = vnode.dirs || (vnode.dirs = []);
4312
4328
  for (let i = 0; i < directives.length; i++) {
4313
4329
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4314
- if (isFunction(dir)) {
4315
- dir = {
4316
- mounted: dir,
4317
- updated: dir
4318
- };
4319
- }
4320
- if (dir.deep) {
4321
- traverse(value);
4330
+ if (dir) {
4331
+ if (isFunction(dir)) {
4332
+ dir = {
4333
+ mounted: dir,
4334
+ updated: dir
4335
+ };
4336
+ }
4337
+ if (dir.deep) {
4338
+ traverse(value);
4339
+ }
4340
+ bindings.push({
4341
+ dir,
4342
+ instance,
4343
+ value,
4344
+ oldValue: void 0,
4345
+ arg,
4346
+ modifiers
4347
+ });
4322
4348
  }
4323
- bindings.push({
4324
- dir,
4325
- instance,
4326
- value,
4327
- oldValue: void 0,
4328
- arg,
4329
- modifiers
4330
- });
4331
4349
  }
4332
4350
  return vnode;
4333
4351
  }
@@ -5540,7 +5558,7 @@ var Vue = (function (exports) {
5540
5558
  if (validatePropName(normalizedKey)) {
5541
5559
  const opt = raw[key];
5542
5560
  const prop = (normalized[normalizedKey] =
5543
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
5561
+ isArray(opt) || isFunction(opt) ? { type: opt } : Object.assign({}, opt));
5544
5562
  if (prop) {
5545
5563
  const booleanIndex = getTypeIndex(Boolean, prop.type);
5546
5564
  const stringIndex = getTypeIndex(String, prop.type);
@@ -8877,6 +8895,9 @@ var Vue = (function (exports) {
8877
8895
  else if (key in publicPropertiesMap) {
8878
8896
  return publicPropertiesMap[key](instance);
8879
8897
  }
8898
+ },
8899
+ has(target, key) {
8900
+ return key in target || key in publicPropertiesMap;
8880
8901
  }
8881
8902
  })));
8882
8903
  }
@@ -9325,7 +9346,7 @@ var Vue = (function (exports) {
9325
9346
  }
9326
9347
 
9327
9348
  // Core API ------------------------------------------------------------------
9328
- const version = "3.2.41";
9349
+ const version = "3.2.43";
9329
9350
  /**
9330
9351
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
9331
9352
  * @internal
@@ -9844,7 +9865,7 @@ var Vue = (function (exports) {
9844
9865
  }
9845
9866
  }).observe(this, { attributes: true });
9846
9867
  const resolve = (def) => {
9847
- const { props, styles } = def;
9868
+ const { props = {}, styles } = def;
9848
9869
  const hasOptions = !isArray(props);
9849
9870
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
9850
9871
  // cast Number-type props set before resolve
@@ -9891,10 +9912,11 @@ var Vue = (function (exports) {
9891
9912
  }
9892
9913
  _setAttr(key) {
9893
9914
  let value = this.getAttribute(key);
9894
- if (this._numberProps && this._numberProps[key]) {
9915
+ const camelKey = camelize(key);
9916
+ if (this._numberProps && this._numberProps[camelKey]) {
9895
9917
  value = toNumber(value);
9896
9918
  }
9897
- this._setProp(camelize(key), value, false);
9919
+ this._setProp(camelKey, value, false);
9898
9920
  }
9899
9921
  /**
9900
9922
  * @internal
@@ -10275,11 +10297,11 @@ var Vue = (function (exports) {
10275
10297
  const styles = window.getComputedStyle(el);
10276
10298
  // JSDOM may return undefined for transition properties
10277
10299
  const getStyleProperties = (key) => (styles[key] || '').split(', ');
10278
- const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
10279
- const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
10300
+ const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
10301
+ const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
10280
10302
  const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
10281
- const animationDelays = getStyleProperties(ANIMATION + 'Delay');
10282
- const animationDurations = getStyleProperties(ANIMATION + 'Duration');
10303
+ const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
10304
+ const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
10283
10305
  const animationTimeout = getTimeout(animationDelays, animationDurations);
10284
10306
  let type = null;
10285
10307
  let timeout = 0;
@@ -10314,7 +10336,7 @@ var Vue = (function (exports) {
10314
10336
  : 0;
10315
10337
  }
10316
10338
  const hasTransform = type === TRANSITION &&
10317
- /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
10339
+ /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
10318
10340
  return {
10319
10341
  type,
10320
10342
  timeout,
@@ -11478,7 +11500,10 @@ var Vue = (function (exports) {
11478
11500
  // if doesn't override user provided keys
11479
11501
  const first = props.arguments[0];
11480
11502
  if (!isString(first) && first.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
11481
- first.properties.unshift(prop);
11503
+ // #6631
11504
+ if (!hasProp(prop, first)) {
11505
+ first.properties.unshift(prop);
11506
+ }
11482
11507
  }
11483
11508
  else {
11484
11509
  if (props.callee === TO_HANDLERS) {
@@ -11495,14 +11520,7 @@ var Vue = (function (exports) {
11495
11520
  !propsWithInjection && (propsWithInjection = props);
11496
11521
  }
11497
11522
  else if (props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
11498
- let alreadyExists = false;
11499
- // check existing key to avoid overriding user provided keys
11500
- if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
11501
- const propKeyName = prop.key.content;
11502
- alreadyExists = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
11503
- p.key.content === propKeyName);
11504
- }
11505
- if (!alreadyExists) {
11523
+ if (!hasProp(prop, props)) {
11506
11524
  props.properties.unshift(prop);
11507
11525
  }
11508
11526
  propsWithInjection = props;
@@ -11537,6 +11555,16 @@ var Vue = (function (exports) {
11537
11555
  }
11538
11556
  }
11539
11557
  }
11558
+ // check existing key to avoid overriding user provided keys
11559
+ function hasProp(prop, props) {
11560
+ let result = false;
11561
+ if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
11562
+ const propKeyName = prop.key.content;
11563
+ result = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
11564
+ p.key.content === propKeyName);
11565
+ }
11566
+ return result;
11567
+ }
11540
11568
  function toValidAssetId(name, type) {
11541
11569
  // see issue#4422, we need adding identifier on validAssetId if variable `name` has specific character
11542
11570
  return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
@@ -11799,13 +11827,18 @@ var Vue = (function (exports) {
11799
11827
  const next = nodes[i + 1];
11800
11828
  // Remove if:
11801
11829
  // - the whitespace is the first or last node, or:
11802
- // - (condense mode) the whitespace is adjacent to a comment, or:
11830
+ // - (condense mode) the whitespace is between twos comments, or:
11831
+ // - (condense mode) the whitespace is between comment and element, or:
11803
11832
  // - (condense mode) the whitespace is between two elements AND contains newline
11804
11833
  if (!prev ||
11805
11834
  !next ||
11806
11835
  (shouldCondense &&
11807
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
11808
- next.type === 3 /* NodeTypes.COMMENT */ ||
11836
+ ((prev.type === 3 /* NodeTypes.COMMENT */ &&
11837
+ next.type === 3 /* NodeTypes.COMMENT */) ||
11838
+ (prev.type === 3 /* NodeTypes.COMMENT */ &&
11839
+ next.type === 1 /* NodeTypes.ELEMENT */) ||
11840
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
11841
+ next.type === 3 /* NodeTypes.COMMENT */) ||
11809
11842
  (prev.type === 1 /* NodeTypes.ELEMENT */ &&
11810
11843
  next.type === 1 /* NodeTypes.ELEMENT */ &&
11811
11844
  /[\r\n]/.test(node.content))))) {
@@ -14914,7 +14947,7 @@ var Vue = (function (exports) {
14914
14947
  };
14915
14948
  }
14916
14949
 
14917
- const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
14950
+ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
14918
14951
  const transformOn = (dir, node, context, augmentor) => {
14919
14952
  const { loc, modifiers, arg } = dir;
14920
14953
  if (!dir.exp && !modifiers.length) {
@@ -14928,10 +14961,10 @@ var Vue = (function (exports) {
14928
14961
  if (rawName.startsWith('vue:')) {
14929
14962
  rawName = `vnode-${rawName.slice(4)}`;
14930
14963
  }
14931
- const eventString = node.tagType === 1 /* ElementTypes.COMPONENT */ ||
14964
+ const eventString = node.tagType !== 0 /* ElementTypes.ELEMENT */ ||
14932
14965
  rawName.startsWith('vnode') ||
14933
14966
  !/[A-Z]/.test(rawName)
14934
- ? // for component and vnode lifecycle event listeners, auto convert
14967
+ ? // for non-element and vnode lifecycle event listeners, auto convert
14935
14968
  // it to camelCase. See issue #2249
14936
14969
  toHandlerKey(camelize(rawName))
14937
14970
  : // preserve case for plain element listeners that have uppercase