@vue/runtime-dom 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.
@@ -509,7 +509,7 @@ class VueElement extends BaseClass {
509
509
  }
510
510
  }).observe(this, { attributes: true });
511
511
  const resolve = (def) => {
512
- const { props, styles } = def;
512
+ const { props = {}, styles } = def;
513
513
  const hasOptions = !shared.isArray(props);
514
514
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
515
515
  // cast Number-type props set before resolve
@@ -556,10 +556,11 @@ class VueElement extends BaseClass {
556
556
  }
557
557
  _setAttr(key) {
558
558
  let value = this.getAttribute(key);
559
- if (this._numberProps && this._numberProps[key]) {
559
+ const camelKey = shared.camelize(key);
560
+ if (this._numberProps && this._numberProps[camelKey]) {
560
561
  value = shared.toNumber(value);
561
562
  }
562
- this._setProp(shared.camelize(key), value, false);
563
+ this._setProp(camelKey, value, false);
563
564
  }
564
565
  /**
565
566
  * @internal
@@ -902,11 +903,11 @@ function getTransitionInfo(el, expectedType) {
902
903
  const styles = window.getComputedStyle(el);
903
904
  // JSDOM may return undefined for transition properties
904
905
  const getStyleProperties = (key) => (styles[key] || '').split(', ');
905
- const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
906
- const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
906
+ const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
907
+ const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
907
908
  const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
908
- const animationDelays = getStyleProperties(ANIMATION + 'Delay');
909
- const animationDurations = getStyleProperties(ANIMATION + 'Duration');
909
+ const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
910
+ const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
910
911
  const animationTimeout = getTimeout(animationDelays, animationDurations);
911
912
  let type = null;
912
913
  let timeout = 0;
@@ -941,7 +942,7 @@ function getTransitionInfo(el, expectedType) {
941
942
  : 0;
942
943
  }
943
944
  const hasTransform = type === TRANSITION &&
944
- /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
945
+ /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
945
946
  return {
946
947
  type,
947
948
  timeout,
@@ -500,7 +500,7 @@ class VueElement extends BaseClass {
500
500
  }
501
501
  }).observe(this, { attributes: true });
502
502
  const resolve = (def) => {
503
- const { props, styles } = def;
503
+ const { props = {}, styles } = def;
504
504
  const hasOptions = !shared.isArray(props);
505
505
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
506
506
  // cast Number-type props set before resolve
@@ -547,10 +547,11 @@ class VueElement extends BaseClass {
547
547
  }
548
548
  _setAttr(key) {
549
549
  let value = this.getAttribute(key);
550
- if (this._numberProps && this._numberProps[key]) {
550
+ const camelKey = shared.camelize(key);
551
+ if (this._numberProps && this._numberProps[camelKey]) {
551
552
  value = shared.toNumber(value);
552
553
  }
553
- this._setProp(shared.camelize(key), value, false);
554
+ this._setProp(camelKey, value, false);
554
555
  }
555
556
  /**
556
557
  * @internal
@@ -857,11 +858,11 @@ function getTransitionInfo(el, expectedType) {
857
858
  const styles = window.getComputedStyle(el);
858
859
  // JSDOM may return undefined for transition properties
859
860
  const getStyleProperties = (key) => (styles[key] || '').split(', ');
860
- const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
861
- const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
861
+ const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
862
+ const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
862
863
  const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
863
- const animationDelays = getStyleProperties(ANIMATION + 'Delay');
864
- const animationDurations = getStyleProperties(ANIMATION + 'Duration');
864
+ const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
865
+ const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
865
866
  const animationTimeout = getTimeout(animationDelays, animationDurations);
866
867
  let type = null;
867
868
  let timeout = 0;
@@ -896,7 +897,7 @@ function getTransitionInfo(el, expectedType) {
896
897
  : 0;
897
898
  }
898
899
  const hasTransform = type === TRANSITION &&
899
- /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
900
+ /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
900
901
  return {
901
902
  type,
902
903
  timeout,
@@ -1,4 +1,5 @@
1
1
  import { BaseTransitionProps } from '@vue/runtime-core';
2
+ import { ComponentInjectOptions } from '@vue/runtime-core';
2
3
  import { ComponentInternalInstance } from '@vue/runtime-core';
3
4
  import { ComponentOptionsMixin } from '@vue/runtime-core';
4
5
  import { ComponentOptionsWithArrayProps } from '@vue/runtime-core';
@@ -21,6 +22,8 @@ import { SetupContext } from '@vue/runtime-core';
21
22
 
22
23
  declare const ANIMATION = "animation";
23
24
 
25
+ declare type AnimationTypes = typeof TRANSITION | typeof ANIMATION;
26
+
24
27
  declare type AssignerFn = (value: any) => void;
25
28
 
26
29
  declare const BaseClass: {
@@ -34,17 +37,17 @@ export declare const createSSRApp: CreateAppFunction<Element>;
34
37
 
35
38
  export declare function defineCustomElement<Props, RawBindings = object>(setup: (props: Readonly<Props>, ctx: SetupContext) => RawBindings | RenderFunction): VueElementConstructor<Props>;
36
39
 
37
- export declare function defineCustomElement<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string>(options: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, Mixin, Extends, E, EE> & {
40
+ export declare function defineCustomElement<Props = {}, RawBindings = {}, D = {}, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = EmitsOptions, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithoutProps<Props, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II> & {
38
41
  styles?: string[];
39
42
  }): VueElementConstructor<Props>;
40
43
 
41
- export declare function defineCustomElement<PropNames extends string, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record<string, any>, EE extends string = string>(options: ComponentOptionsWithArrayProps<PropNames, RawBindings, D, C, M, Mixin, Extends, E, EE> & {
44
+ export declare function defineCustomElement<PropNames extends string, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record<string, any>, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithArrayProps<PropNames, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II> & {
42
45
  styles?: string[];
43
46
  }): VueElementConstructor<{
44
47
  [K in PropNames]: any;
45
48
  }>;
46
49
 
47
- export declare function defineCustomElement<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record<string, any>, EE extends string = string>(options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE> & {
50
+ export declare function defineCustomElement<PropsOptions extends Readonly<ComponentPropsOptions>, RawBindings, D, C extends ComputedOptions = {}, M extends MethodOptions = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, E extends EmitsOptions = Record<string, any>, EE extends string = string, I extends ComponentInjectOptions = {}, II extends string = string>(options: ComponentOptionsWithObjectProps<PropsOptions, RawBindings, D, C, M, Mixin, Extends, E, EE, I, II> & {
48
51
  styles?: string[];
49
52
  }): VueElementConstructor<ExtractPropTypes<PropsOptions>>;
50
53
 
@@ -83,7 +86,7 @@ export declare type TransitionGroupProps = Omit<TransitionProps, 'mode'> & {
83
86
 
84
87
  export declare interface TransitionProps extends BaseTransitionProps<Element> {
85
88
  name?: string;
86
- type?: typeof TRANSITION | typeof ANIMATION;
89
+ type?: AnimationTypes;
87
90
  css?: boolean;
88
91
  duration?: number | {
89
92
  enter: number;
@@ -1469,7 +1472,7 @@ export interface Events {
1469
1472
  }
1470
1473
 
1471
1474
  type EventHandlers<E> = {
1472
- [K in keyof E]?: E[K] extends Function ? E[K] : (payload: E[K]) => void
1475
+ [K in keyof E]?: E[K] extends (...args: any) => any ? E[K] : (payload: E[K]) => void
1473
1476
  }
1474
1477
 
1475
1478
  // use namespace import to avoid collision with generated types which use
@@ -19,27 +19,6 @@ const GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,p
19
19
  'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';
20
20
  const isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);
21
21
 
22
- /**
23
- * On the client we only need to offer special cases for boolean attributes that
24
- * have different names from their corresponding dom properties:
25
- * - itemscope -> N/A
26
- * - allowfullscreen -> allowFullscreen
27
- * - formnovalidate -> formNoValidate
28
- * - ismap -> isMap
29
- * - nomodule -> noModule
30
- * - novalidate -> noValidate
31
- * - readonly -> readOnly
32
- */
33
- const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
34
- const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
35
- /**
36
- * Boolean attributes should be included if the value is truthy or ''.
37
- * e.g. `<select multiple>` compiles to `{ multiple: '' }`
38
- */
39
- function includeBooleanAttr(value) {
40
- return !!value || value === '';
41
- }
42
-
43
22
  function normalizeStyle(value) {
44
23
  if (isArray(value)) {
45
24
  const res = {};
@@ -64,10 +43,14 @@ function normalizeStyle(value) {
64
43
  }
65
44
  }
66
45
  const listDelimiterRE = /;(?![^(]*\))/g;
67
- const propertyDelimiterRE = /:(.+)/;
46
+ const propertyDelimiterRE = /:([^]+)/;
47
+ const styleCommentRE = /\/\*.*?\*\//gs;
68
48
  function parseStringStyle(cssText) {
69
49
  const ret = {};
70
- cssText.split(listDelimiterRE).forEach(item => {
50
+ cssText
51
+ .replace(styleCommentRE, '')
52
+ .split(listDelimiterRE)
53
+ .forEach(item => {
71
54
  if (item) {
72
55
  const tmp = item.split(propertyDelimiterRE);
73
56
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -143,6 +126,27 @@ const isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);
143
126
  */
144
127
  const isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);
145
128
 
129
+ /**
130
+ * On the client we only need to offer special cases for boolean attributes that
131
+ * have different names from their corresponding dom properties:
132
+ * - itemscope -> N/A
133
+ * - allowfullscreen -> allowFullscreen
134
+ * - formnovalidate -> formNoValidate
135
+ * - ismap -> isMap
136
+ * - nomodule -> noModule
137
+ * - novalidate -> noValidate
138
+ * - readonly -> readOnly
139
+ */
140
+ const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
141
+ const isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);
142
+ /**
143
+ * Boolean attributes should be included if the value is truthy or ''.
144
+ * e.g. `<select multiple>` compiles to `{ multiple: '' }`
145
+ */
146
+ function includeBooleanAttr(value) {
147
+ return !!value || value === '';
148
+ }
149
+
146
150
  function looseCompareArrays(a, b) {
147
151
  if (a.length !== b.length)
148
152
  return false;
@@ -646,8 +650,9 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
646
650
  deps = [...depsMap.values()];
647
651
  }
648
652
  else if (key === 'length' && isArray(target)) {
653
+ const newLength = toNumber(newValue);
649
654
  depsMap.forEach((dep, key) => {
650
- if (key === 'length' || key >= newValue) {
655
+ if (key === 'length' || key >= newLength) {
651
656
  deps.push(dep);
652
657
  }
653
658
  });
@@ -2182,7 +2187,7 @@ function emit$1(instance, event, ...rawArgs) {
2182
2187
  const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
2183
2188
  const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
2184
2189
  if (trim) {
2185
- args = rawArgs.map(a => a.trim());
2190
+ args = rawArgs.map(a => (isString(a) ? a.trim() : a));
2186
2191
  }
2187
2192
  if (number) {
2188
2193
  args = rawArgs.map(toNumber);
@@ -3244,7 +3249,9 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3244
3249
  callWithErrorHandling(fn, instance, 4 /* ErrorCodes.WATCH_CLEANUP */);
3245
3250
  };
3246
3251
  };
3247
- let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
3252
+ let oldValue = isMultiSource
3253
+ ? new Array(source.length).fill(INITIAL_WATCHER_VALUE)
3254
+ : INITIAL_WATCHER_VALUE;
3248
3255
  const job = () => {
3249
3256
  if (!effect.active) {
3250
3257
  return;
@@ -3265,7 +3272,10 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3265
3272
  callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
3266
3273
  newValue,
3267
3274
  // pass undefined as the old value when it's changed for the first time
3268
- oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
3275
+ oldValue === INITIAL_WATCHER_VALUE ||
3276
+ (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3277
+ ? undefined
3278
+ : oldValue,
3269
3279
  onCleanup
3270
3280
  ]);
3271
3281
  oldValue = newValue;
@@ -3313,12 +3323,13 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3313
3323
  else {
3314
3324
  effect.run();
3315
3325
  }
3316
- return () => {
3326
+ const unwatch = () => {
3317
3327
  effect.stop();
3318
3328
  if (instance && instance.scope) {
3319
3329
  remove(instance.scope.effects, effect);
3320
3330
  }
3321
3331
  };
3332
+ return unwatch;
3322
3333
  }
3323
3334
  // this.$watch
3324
3335
  function instanceWatch(source, value, options) {
@@ -3500,7 +3511,11 @@ const BaseTransitionImpl = {
3500
3511
  // return placeholder node and queue update when leave finishes
3501
3512
  leavingHooks.afterLeave = () => {
3502
3513
  state.isLeaving = false;
3503
- instance.update();
3514
+ // #6835
3515
+ // it also needs to be updated when active is undefined
3516
+ if (instance.update.active !== false) {
3517
+ instance.update();
3518
+ }
3504
3519
  };
3505
3520
  return emptyPlaceholder(child);
3506
3521
  }
@@ -4018,7 +4033,8 @@ const KeepAliveImpl = {
4018
4033
  : comp);
4019
4034
  const { include, exclude, max } = props;
4020
4035
  if ((include && (!name || !matches(include, name))) ||
4021
- (exclude && name && matches(exclude, name))) {
4036
+ (exclude && name && matches(exclude, name)) ||
4037
+ (hmrDirtyComponents.has(comp))) {
4022
4038
  current = vnode;
4023
4039
  return rawVNode;
4024
4040
  }
@@ -4230,23 +4246,25 @@ function withDirectives(vnode, directives) {
4230
4246
  const bindings = vnode.dirs || (vnode.dirs = []);
4231
4247
  for (let i = 0; i < directives.length; i++) {
4232
4248
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
4233
- if (isFunction(dir)) {
4234
- dir = {
4235
- mounted: dir,
4236
- updated: dir
4237
- };
4238
- }
4239
- if (dir.deep) {
4240
- traverse(value);
4249
+ if (dir) {
4250
+ if (isFunction(dir)) {
4251
+ dir = {
4252
+ mounted: dir,
4253
+ updated: dir
4254
+ };
4255
+ }
4256
+ if (dir.deep) {
4257
+ traverse(value);
4258
+ }
4259
+ bindings.push({
4260
+ dir,
4261
+ instance,
4262
+ value,
4263
+ oldValue: void 0,
4264
+ arg,
4265
+ modifiers
4266
+ });
4241
4267
  }
4242
- bindings.push({
4243
- dir,
4244
- instance,
4245
- value,
4246
- oldValue: void 0,
4247
- arg,
4248
- modifiers
4249
- });
4250
4268
  }
4251
4269
  return vnode;
4252
4270
  }
@@ -5459,7 +5477,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
5459
5477
  if (validatePropName(normalizedKey)) {
5460
5478
  const opt = raw[key];
5461
5479
  const prop = (normalized[normalizedKey] =
5462
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
5480
+ isArray(opt) || isFunction(opt) ? { type: opt } : Object.assign({}, opt));
5463
5481
  if (prop) {
5464
5482
  const booleanIndex = getTypeIndex(Boolean, prop.type);
5465
5483
  const stringIndex = getTypeIndex(String, prop.type);
@@ -8796,6 +8814,9 @@ function getExposeProxy(instance) {
8796
8814
  else if (key in publicPropertiesMap) {
8797
8815
  return publicPropertiesMap[key](instance);
8798
8816
  }
8817
+ },
8818
+ has(target, key) {
8819
+ return key in target || key in publicPropertiesMap;
8799
8820
  }
8800
8821
  })));
8801
8822
  }
@@ -9249,7 +9270,7 @@ function isMemoSame(cached, memo) {
9249
9270
  }
9250
9271
 
9251
9272
  // Core API ------------------------------------------------------------------
9252
- const version = "3.2.41";
9273
+ const version = "3.2.42";
9253
9274
  /**
9254
9275
  * SSR utils for \@vue/server-renderer. Only exposed in ssr-possible builds.
9255
9276
  * @internal
@@ -9768,7 +9789,7 @@ class VueElement extends BaseClass {
9768
9789
  }
9769
9790
  }).observe(this, { attributes: true });
9770
9791
  const resolve = (def) => {
9771
- const { props, styles } = def;
9792
+ const { props = {}, styles } = def;
9772
9793
  const hasOptions = !isArray(props);
9773
9794
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
9774
9795
  // cast Number-type props set before resolve
@@ -9815,10 +9836,11 @@ class VueElement extends BaseClass {
9815
9836
  }
9816
9837
  _setAttr(key) {
9817
9838
  let value = this.getAttribute(key);
9818
- if (this._numberProps && this._numberProps[key]) {
9839
+ const camelKey = camelize(key);
9840
+ if (this._numberProps && this._numberProps[camelKey]) {
9819
9841
  value = toNumber(value);
9820
9842
  }
9821
- this._setProp(camelize(key), value, false);
9843
+ this._setProp(camelKey, value, false);
9822
9844
  }
9823
9845
  /**
9824
9846
  * @internal
@@ -10211,11 +10233,11 @@ function getTransitionInfo(el, expectedType) {
10211
10233
  const styles = window.getComputedStyle(el);
10212
10234
  // JSDOM may return undefined for transition properties
10213
10235
  const getStyleProperties = (key) => (styles[key] || '').split(', ');
10214
- const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
10215
- const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
10236
+ const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
10237
+ const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
10216
10238
  const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
10217
- const animationDelays = getStyleProperties(ANIMATION + 'Delay');
10218
- const animationDurations = getStyleProperties(ANIMATION + 'Duration');
10239
+ const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
10240
+ const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
10219
10241
  const animationTimeout = getTimeout(animationDelays, animationDurations);
10220
10242
  let type = null;
10221
10243
  let timeout = 0;
@@ -10250,7 +10272,7 @@ function getTransitionInfo(el, expectedType) {
10250
10272
  : 0;
10251
10273
  }
10252
10274
  const hasTransform = type === TRANSITION &&
10253
- /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
10275
+ /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
10254
10276
  return {
10255
10277
  type,
10256
10278
  timeout,