@vue/compat 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;
@@ -727,8 +731,9 @@ function trigger(target, type, key, newValue, oldValue, oldTarget) {
727
731
  deps = [...depsMap.values()];
728
732
  }
729
733
  else if (key === 'length' && isArray(target)) {
734
+ const newLength = toNumber(newValue);
730
735
  depsMap.forEach((dep, key) => {
731
- if (key === 'length' || key >= newValue) {
736
+ if (key === 'length' || key >= newLength) {
732
737
  deps.push(dep);
733
738
  }
734
739
  });
@@ -2806,7 +2811,7 @@ function emit$2(instance, event, ...rawArgs) {
2806
2811
  const modifiersKey = `${modelArg === 'modelValue' ? 'model' : modelArg}Modifiers`;
2807
2812
  const { number, trim } = props[modifiersKey] || EMPTY_OBJ;
2808
2813
  if (trim) {
2809
- args = rawArgs.map(a => a.trim());
2814
+ args = rawArgs.map(a => (isString(a) ? a.trim() : a));
2810
2815
  }
2811
2816
  if (number) {
2812
2817
  args = rawArgs.map(toNumber);
@@ -3913,7 +3918,8 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3913
3918
  };
3914
3919
  };
3915
3920
  // in SSR there is no need to setup an actual effect, and it should be noop
3916
- // unless it's eager
3921
+ // unless it's eager or sync flush
3922
+ let ssrCleanup;
3917
3923
  if (isInSSRComponentSetup) {
3918
3924
  // we will also not call the invalidate callback (+ runner is not set up)
3919
3925
  onCleanup = NOOP;
@@ -3927,9 +3933,17 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3927
3933
  onCleanup
3928
3934
  ]);
3929
3935
  }
3930
- return NOOP;
3936
+ if (flush === 'sync') {
3937
+ const ctx = useSSRContext();
3938
+ ssrCleanup = ctx.__watcherHandles || (ctx.__watcherHandles = []);
3939
+ }
3940
+ else {
3941
+ return NOOP;
3942
+ }
3931
3943
  }
3932
- let oldValue = isMultiSource ? [] : INITIAL_WATCHER_VALUE;
3944
+ let oldValue = isMultiSource
3945
+ ? new Array(source.length).fill(INITIAL_WATCHER_VALUE)
3946
+ : INITIAL_WATCHER_VALUE;
3933
3947
  const job = () => {
3934
3948
  if (!effect.active) {
3935
3949
  return;
@@ -3951,7 +3965,10 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3951
3965
  callWithAsyncErrorHandling(cb, instance, 3 /* ErrorCodes.WATCH_CALLBACK */, [
3952
3966
  newValue,
3953
3967
  // pass undefined as the old value when it's changed for the first time
3954
- oldValue === INITIAL_WATCHER_VALUE ? undefined : oldValue,
3968
+ oldValue === INITIAL_WATCHER_VALUE ||
3969
+ (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
3970
+ ? undefined
3971
+ : oldValue,
3955
3972
  onCleanup
3956
3973
  ]);
3957
3974
  oldValue = newValue;
@@ -3999,12 +4016,15 @@ function doWatch(source, cb, { immediate, deep, flush, onTrack, onTrigger } = EM
3999
4016
  else {
4000
4017
  effect.run();
4001
4018
  }
4002
- return () => {
4019
+ const unwatch = () => {
4003
4020
  effect.stop();
4004
4021
  if (instance && instance.scope) {
4005
4022
  remove(instance.scope.effects, effect);
4006
4023
  }
4007
4024
  };
4025
+ if (ssrCleanup)
4026
+ ssrCleanup.push(unwatch);
4027
+ return unwatch;
4008
4028
  }
4009
4029
  // this.$watch
4010
4030
  function instanceWatch(source, value, options) {
@@ -4189,7 +4209,11 @@ const BaseTransitionImpl = {
4189
4209
  // return placeholder node and queue update when leave finishes
4190
4210
  leavingHooks.afterLeave = () => {
4191
4211
  state.isLeaving = false;
4192
- instance.update();
4212
+ // #6835
4213
+ // it also needs to be updated when active is undefined
4214
+ if (instance.update.active !== false) {
4215
+ instance.update();
4216
+ }
4193
4217
  };
4194
4218
  return emptyPlaceholder(child);
4195
4219
  }
@@ -4718,7 +4742,8 @@ const KeepAliveImpl = {
4718
4742
  : comp);
4719
4743
  const { include, exclude, max } = props;
4720
4744
  if ((include && (!name || !matches(include, name))) ||
4721
- (exclude && name && matches(exclude, name))) {
4745
+ (exclude && name && matches(exclude, name)) ||
4746
+ ((process.env.NODE_ENV !== 'production') && hmrDirtyComponents.has(comp))) {
4722
4747
  current = vnode;
4723
4748
  return rawVNode;
4724
4749
  }
@@ -4998,23 +5023,25 @@ function withDirectives(vnode, directives) {
4998
5023
  const bindings = vnode.dirs || (vnode.dirs = []);
4999
5024
  for (let i = 0; i < directives.length; i++) {
5000
5025
  let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
5001
- if (isFunction(dir)) {
5002
- dir = {
5003
- mounted: dir,
5004
- updated: dir
5005
- };
5006
- }
5007
- if (dir.deep) {
5008
- traverse(value);
5026
+ if (dir) {
5027
+ if (isFunction(dir)) {
5028
+ dir = {
5029
+ mounted: dir,
5030
+ updated: dir
5031
+ };
5032
+ }
5033
+ if (dir.deep) {
5034
+ traverse(value);
5035
+ }
5036
+ bindings.push({
5037
+ dir,
5038
+ instance,
5039
+ value,
5040
+ oldValue: void 0,
5041
+ arg,
5042
+ modifiers
5043
+ });
5009
5044
  }
5010
- bindings.push({
5011
- dir,
5012
- instance,
5013
- value,
5014
- oldValue: void 0,
5015
- arg,
5016
- modifiers
5017
- });
5018
5045
  }
5019
5046
  return vnode;
5020
5047
  }
@@ -6851,7 +6878,7 @@ function normalizePropsOptions(comp, appContext, asMixin = false) {
6851
6878
  if (validatePropName(normalizedKey)) {
6852
6879
  const opt = raw[key];
6853
6880
  const prop = (normalized[normalizedKey] =
6854
- isArray(opt) || isFunction(opt) ? { type: opt } : opt);
6881
+ isArray(opt) || isFunction(opt) ? { type: opt } : Object.assign({}, opt));
6855
6882
  if (prop) {
6856
6883
  const booleanIndex = getTypeIndex(Boolean, prop.type);
6857
6884
  const stringIndex = getTypeIndex(String, prop.type);
@@ -7223,7 +7250,7 @@ function createCompatVue(createApp, createSingletonApp) {
7223
7250
  return vm;
7224
7251
  }
7225
7252
  }
7226
- Vue.version = `2.6.14-compat:${"3.2.41"}`;
7253
+ Vue.version = `2.6.14-compat:${"3.2.42"}`;
7227
7254
  Vue.config = singletonApp.config;
7228
7255
  Vue.use = (p, ...options) => {
7229
7256
  if (p && isFunction(p.install)) {
@@ -10851,6 +10878,9 @@ function getExposeProxy(instance) {
10851
10878
  else if (key in publicPropertiesMap) {
10852
10879
  return publicPropertiesMap[key](instance);
10853
10880
  }
10881
+ },
10882
+ has(target, key) {
10883
+ return key in target || key in publicPropertiesMap;
10854
10884
  }
10855
10885
  })));
10856
10886
  }
@@ -11304,7 +11334,7 @@ function isMemoSame(cached, memo) {
11304
11334
  }
11305
11335
 
11306
11336
  // Core API ------------------------------------------------------------------
11307
- const version = "3.2.41";
11337
+ const version = "3.2.42";
11308
11338
  const _ssrUtils = {
11309
11339
  createComponentInstance,
11310
11340
  setupComponent,
@@ -11877,7 +11907,7 @@ class VueElement extends BaseClass {
11877
11907
  }
11878
11908
  }).observe(this, { attributes: true });
11879
11909
  const resolve = (def) => {
11880
- const { props, styles } = def;
11910
+ const { props = {}, styles } = def;
11881
11911
  const hasOptions = !isArray(props);
11882
11912
  const rawKeys = props ? (hasOptions ? Object.keys(props) : props) : [];
11883
11913
  // cast Number-type props set before resolve
@@ -11924,10 +11954,11 @@ class VueElement extends BaseClass {
11924
11954
  }
11925
11955
  _setAttr(key) {
11926
11956
  let value = this.getAttribute(key);
11927
- if (this._numberProps && this._numberProps[key]) {
11957
+ const camelKey = camelize(key);
11958
+ if (this._numberProps && this._numberProps[camelKey]) {
11928
11959
  value = toNumber(value);
11929
11960
  }
11930
- this._setProp(camelize(key), value, false);
11961
+ this._setProp(camelKey, value, false);
11931
11962
  }
11932
11963
  /**
11933
11964
  * @internal
@@ -12358,11 +12389,11 @@ function getTransitionInfo(el, expectedType) {
12358
12389
  const styles = window.getComputedStyle(el);
12359
12390
  // JSDOM may return undefined for transition properties
12360
12391
  const getStyleProperties = (key) => (styles[key] || '').split(', ');
12361
- const transitionDelays = getStyleProperties(TRANSITION + 'Delay');
12362
- const transitionDurations = getStyleProperties(TRANSITION + 'Duration');
12392
+ const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
12393
+ const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
12363
12394
  const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
12364
- const animationDelays = getStyleProperties(ANIMATION + 'Delay');
12365
- const animationDurations = getStyleProperties(ANIMATION + 'Duration');
12395
+ const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
12396
+ const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
12366
12397
  const animationTimeout = getTimeout(animationDelays, animationDurations);
12367
12398
  let type = null;
12368
12399
  let timeout = 0;
@@ -12397,7 +12428,7 @@ function getTransitionInfo(el, expectedType) {
12397
12428
  : 0;
12398
12429
  }
12399
12430
  const hasTransform = type === TRANSITION &&
12400
- /\b(transform|all)(,|$)/.test(styles[TRANSITION + 'Property']);
12431
+ /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
12401
12432
  return {
12402
12433
  type,
12403
12434
  timeout,
@@ -13838,7 +13869,10 @@ function injectProp(node, prop, context) {
13838
13869
  // if doesn't override user provided keys
13839
13870
  const first = props.arguments[0];
13840
13871
  if (!isString(first) && first.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
13841
- first.properties.unshift(prop);
13872
+ // #6631
13873
+ if (!hasProp(prop, first)) {
13874
+ first.properties.unshift(prop);
13875
+ }
13842
13876
  }
13843
13877
  else {
13844
13878
  if (props.callee === TO_HANDLERS) {
@@ -13855,14 +13889,7 @@ function injectProp(node, prop, context) {
13855
13889
  !propsWithInjection && (propsWithInjection = props);
13856
13890
  }
13857
13891
  else if (props.type === 15 /* NodeTypes.JS_OBJECT_EXPRESSION */) {
13858
- let alreadyExists = false;
13859
- // check existing key to avoid overriding user provided keys
13860
- if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
13861
- const propKeyName = prop.key.content;
13862
- alreadyExists = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
13863
- p.key.content === propKeyName);
13864
- }
13865
- if (!alreadyExists) {
13892
+ if (!hasProp(prop, props)) {
13866
13893
  props.properties.unshift(prop);
13867
13894
  }
13868
13895
  propsWithInjection = props;
@@ -13897,6 +13924,16 @@ function injectProp(node, prop, context) {
13897
13924
  }
13898
13925
  }
13899
13926
  }
13927
+ // check existing key to avoid overriding user provided keys
13928
+ function hasProp(prop, props) {
13929
+ let result = false;
13930
+ if (prop.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */) {
13931
+ const propKeyName = prop.key.content;
13932
+ result = props.properties.some(p => p.key.type === 4 /* NodeTypes.SIMPLE_EXPRESSION */ &&
13933
+ p.key.content === propKeyName);
13934
+ }
13935
+ return result;
13936
+ }
13900
13937
  function toValidAssetId(name, type) {
13901
13938
  // see issue#4422, we need adding identifier on validAssetId if variable `name` has specific character
13902
13939
  return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
@@ -14169,13 +14206,18 @@ function parseChildren(context, mode, ancestors) {
14169
14206
  const next = nodes[i + 1];
14170
14207
  // Remove if:
14171
14208
  // - the whitespace is the first or last node, or:
14172
- // - (condense mode) the whitespace is adjacent to a comment, or:
14209
+ // - (condense mode) the whitespace is between twos comments, or:
14210
+ // - (condense mode) the whitespace is between comment and element, or:
14173
14211
  // - (condense mode) the whitespace is between two elements AND contains newline
14174
14212
  if (!prev ||
14175
14213
  !next ||
14176
14214
  (shouldCondense &&
14177
- (prev.type === 3 /* NodeTypes.COMMENT */ ||
14178
- next.type === 3 /* NodeTypes.COMMENT */ ||
14215
+ ((prev.type === 3 /* NodeTypes.COMMENT */ &&
14216
+ next.type === 3 /* NodeTypes.COMMENT */) ||
14217
+ (prev.type === 3 /* NodeTypes.COMMENT */ &&
14218
+ next.type === 1 /* NodeTypes.ELEMENT */) ||
14219
+ (prev.type === 1 /* NodeTypes.ELEMENT */ &&
14220
+ next.type === 3 /* NodeTypes.COMMENT */) ||
14179
14221
  (prev.type === 1 /* NodeTypes.ELEMENT */ &&
14180
14222
  next.type === 1 /* NodeTypes.ELEMENT */ &&
14181
14223
  /[\r\n]/.test(node.content))))) {
@@ -16104,9 +16146,9 @@ function processIf(node, dir, context, processCodegen) {
16104
16146
  let i = siblings.indexOf(node);
16105
16147
  while (i-- >= -1) {
16106
16148
  const sibling = siblings[i];
16107
- if ((process.env.NODE_ENV !== 'production') && sibling && sibling.type === 3 /* NodeTypes.COMMENT */) {
16149
+ if (sibling && sibling.type === 3 /* NodeTypes.COMMENT */) {
16108
16150
  context.removeNode(sibling);
16109
- comments.unshift(sibling);
16151
+ (process.env.NODE_ENV !== 'production') && comments.unshift(sibling);
16110
16152
  continue;
16111
16153
  }
16112
16154
  if (sibling &&
@@ -17390,7 +17432,7 @@ function processSlotOutlet(node, context) {
17390
17432
  };
17391
17433
  }
17392
17434
 
17393
- const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
17435
+ const fnExpRE = /^\s*([\w$_]+|(async\s*)?\([^)]*?\))\s*(:[^=]+)?=>|^\s*(async\s+)?function(?:\s+[\w$]+)?\s*\(/;
17394
17436
  const transformOn = (dir, node, context, augmentor) => {
17395
17437
  const { loc, modifiers, arg } = dir;
17396
17438
  if (!dir.exp && !modifiers.length) {
@@ -17404,10 +17446,10 @@ const transformOn = (dir, node, context, augmentor) => {
17404
17446
  if (rawName.startsWith('vue:')) {
17405
17447
  rawName = `vnode-${rawName.slice(4)}`;
17406
17448
  }
17407
- const eventString = node.tagType === 1 /* ElementTypes.COMPONENT */ ||
17449
+ const eventString = node.tagType !== 0 /* ElementTypes.ELEMENT */ ||
17408
17450
  rawName.startsWith('vnode') ||
17409
17451
  !/[A-Z]/.test(rawName)
17410
- ? // for component and vnode lifecycle event listeners, auto convert
17452
+ ? // for non-element and vnode lifecycle event listeners, auto convert
17411
17453
  // it to camelCase. See issue #2249
17412
17454
  toHandlerKey(camelize(rawName))
17413
17455
  : // preserve case for plain element listeners that have uppercase