@vue/compat 3.5.0-beta.3 → 3.5.0

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.
package/dist/vue.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.0-beta.3
2
+ * @vue/compat v3.5.0
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -331,6 +331,13 @@ function escapeHtml(string) {
331
331
  }
332
332
  return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
333
333
  }
334
+ const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
335
+ function getEscapedCssVarName(key, doubleEscape) {
336
+ return key.replace(
337
+ cssVarNameEscapeSymbolsRE,
338
+ (s) => `\\${s}`
339
+ );
340
+ }
334
341
 
335
342
  function looseCompareArrays(a, b) {
336
343
  if (a.length !== b.length) return false;
@@ -455,12 +462,13 @@ class EffectScope {
455
462
  pause() {
456
463
  if (this._active) {
457
464
  this._isPaused = true;
465
+ let i, l;
458
466
  if (this.scopes) {
459
- for (let i = 0, l = this.scopes.length; i < l; i++) {
467
+ for (i = 0, l = this.scopes.length; i < l; i++) {
460
468
  this.scopes[i].pause();
461
469
  }
462
470
  }
463
- for (let i = 0, l = this.effects.length; i < l; i++) {
471
+ for (i = 0, l = this.effects.length; i < l; i++) {
464
472
  this.effects[i].pause();
465
473
  }
466
474
  }
@@ -472,12 +480,13 @@ class EffectScope {
472
480
  if (this._active) {
473
481
  if (this._isPaused) {
474
482
  this._isPaused = false;
483
+ let i, l;
475
484
  if (this.scopes) {
476
- for (let i = 0, l = this.scopes.length; i < l; i++) {
485
+ for (i = 0, l = this.scopes.length; i < l; i++) {
477
486
  this.scopes[i].resume();
478
487
  }
479
488
  }
480
- for (let i = 0, l = this.effects.length; i < l; i++) {
489
+ for (i = 0, l = this.effects.length; i < l; i++) {
481
490
  this.effects[i].resume();
482
491
  }
483
492
  }
@@ -670,11 +679,9 @@ function startBatch() {
670
679
  batchDepth++;
671
680
  }
672
681
  function endBatch() {
673
- if (batchDepth > 1) {
674
- batchDepth--;
682
+ if (--batchDepth > 0) {
675
683
  return;
676
684
  }
677
- batchDepth--;
678
685
  let error;
679
686
  while (batchedEffect) {
680
687
  let e = batchedEffect;
@@ -1191,7 +1198,7 @@ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1191
1198
  const needsWrap = arr !== self && !isShallow(self);
1192
1199
  const methodFn = arr[method];
1193
1200
  if (methodFn !== arrayProto[method]) {
1194
- const result2 = methodFn.apply(arr, args);
1201
+ const result2 = methodFn.apply(self, args);
1195
1202
  return needsWrap ? toReactive(result2) : result2;
1196
1203
  }
1197
1204
  let wrappedFn = fn;
@@ -1333,7 +1340,12 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1333
1340
  }
1334
1341
  }
1335
1342
  const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
1336
- const result = Reflect.set(target, key, value, receiver);
1343
+ const result = Reflect.set(
1344
+ target,
1345
+ key,
1346
+ value,
1347
+ isRef(target) ? target : receiver
1348
+ );
1337
1349
  if (target === toRaw(receiver)) {
1338
1350
  if (!hadKey) {
1339
1351
  trigger(target, "add", key, value);
@@ -2146,18 +2158,25 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
2146
2158
  const depth = deep === true ? Infinity : deep;
2147
2159
  getter = () => traverse(baseGetter(), depth);
2148
2160
  }
2161
+ const scope = getCurrentScope();
2162
+ const watchHandle = () => {
2163
+ effect.stop();
2164
+ if (scope) {
2165
+ remove(scope.effects, effect);
2166
+ }
2167
+ };
2149
2168
  if (once) {
2150
2169
  if (cb) {
2151
2170
  const _cb = cb;
2152
2171
  cb = (...args) => {
2153
2172
  _cb(...args);
2154
- effect.stop();
2173
+ watchHandle();
2155
2174
  };
2156
2175
  } else {
2157
2176
  const _getter = getter;
2158
2177
  getter = () => {
2159
2178
  _getter();
2160
- effect.stop();
2179
+ watchHandle();
2161
2180
  };
2162
2181
  }
2163
2182
  }
@@ -2226,13 +2245,6 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
2226
2245
  } else {
2227
2246
  effect.run();
2228
2247
  }
2229
- const scope = getCurrentScope();
2230
- const watchHandle = () => {
2231
- effect.stop();
2232
- if (scope) {
2233
- remove(scope.effects, effect);
2234
- }
2235
- };
2236
2248
  watchHandle.pause = effect.pause.bind(effect);
2237
2249
  watchHandle.resume = effect.resume.bind(effect);
2238
2250
  watchHandle.stop = watchHandle;
@@ -4212,7 +4224,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
4212
4224
  // @__NO_SIDE_EFFECTS__
4213
4225
  function defineComponent(options, extraOptions) {
4214
4226
  return isFunction(options) ? (
4215
- // #8326: extend call and options.name access are considered side-effects
4227
+ // #8236: extend call and options.name access are considered side-effects
4216
4228
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
4217
4229
  /* @__PURE__ */ (() => extend({ name: options.name }, extraOptions, { setup: options }))()
4218
4230
  ) : options;
@@ -4648,8 +4660,7 @@ Server rendered element contains more child nodes than client vdom.`
4648
4660
  const isText = vnode.type === Text;
4649
4661
  if (node) {
4650
4662
  if (isText && !optimized) {
4651
- let next = children[i + 1];
4652
- if (next && (next = normalizeVNode(next)).type === Text) {
4663
+ if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) {
4653
4664
  insert(
4654
4665
  createText(
4655
4666
  node.data.slice(vnode.children.length)
@@ -4905,7 +4916,10 @@ function resolveCssVars(instance, vnode, expectedMap) {
4905
4916
  if (instance.getCssVars && (vnode === root || root && root.type === Fragment && root.children.includes(vnode))) {
4906
4917
  const cssVars = instance.getCssVars();
4907
4918
  for (const key in cssVars) {
4908
- expectedMap.set(`--${key}`, String(cssVars[key]));
4919
+ expectedMap.set(
4920
+ `--${getEscapedCssVarName(key)}`,
4921
+ String(cssVars[key])
4922
+ );
4909
4923
  }
4910
4924
  }
4911
4925
  if (vnode === root && instance.parent) {
@@ -5339,6 +5353,7 @@ const KeepAliveImpl = {
5339
5353
  );
5340
5354
  const { include, exclude, max } = props;
5341
5355
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
5356
+ vnode.shapeFlag &= ~256;
5342
5357
  current = vnode;
5343
5358
  return rawVNode;
5344
5359
  }
@@ -7087,7 +7102,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
7087
7102
  return vm;
7088
7103
  }
7089
7104
  }
7090
- Vue.version = `2.6.14-compat:${"3.5.0-beta.3"}`;
7105
+ Vue.version = `2.6.14-compat:${"3.5.0"}`;
7091
7106
  Vue.config = singletonApp.config;
7092
7107
  Vue.use = (plugin, ...options) => {
7093
7108
  if (plugin && isFunction(plugin.install)) {
@@ -12223,7 +12238,7 @@ function isMemoSame(cached, memo) {
12223
12238
  return true;
12224
12239
  }
12225
12240
 
12226
- const version = "3.5.0-beta.3";
12241
+ const version = "3.5.0";
12227
12242
  const warn = warn$1 ;
12228
12243
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
12229
12244
  const devtools = devtools$1 ;
@@ -12856,15 +12871,20 @@ function compatCoerceAttr(el, key, value, instance = null) {
12856
12871
 
12857
12872
  function patchDOMProp(el, key, value, parentComponent) {
12858
12873
  if (key === "innerHTML" || key === "textContent") {
12859
- if (value == null) return;
12860
- el[key] = value;
12874
+ if (value != null) {
12875
+ el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
12876
+ }
12861
12877
  return;
12862
12878
  }
12863
12879
  const tag = el.tagName;
12864
12880
  if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
12865
12881
  !tag.includes("-")) {
12866
12882
  const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
12867
- const newValue = value == null ? "" : String(value);
12883
+ const newValue = value == null ? (
12884
+ // #11647: value should be set as empty string for null and undefined,
12885
+ // but <input type="checkbox"> should be set as 'on'.
12886
+ el.type === "checkbox" ? "on" : ""
12887
+ ) : String(value);
12868
12888
  if (oldValue !== newValue || !("_value" in el)) {
12869
12889
  el.value = newValue;
12870
12890
  }
@@ -13300,6 +13320,9 @@ class VueElement extends BaseClass {
13300
13320
  delete this._props[key];
13301
13321
  } else {
13302
13322
  this._props[key] = val;
13323
+ if (key === "key" && this._app) {
13324
+ this._app._ceVNode.key = val;
13325
+ }
13303
13326
  }
13304
13327
  if (shouldUpdate && this._instance) {
13305
13328
  this._update();
@@ -13747,12 +13770,16 @@ const vModelCheckbox = {
13747
13770
  };
13748
13771
  function setChecked(el, { value, oldValue }, vnode) {
13749
13772
  el._modelValue = value;
13773
+ let checked;
13750
13774
  if (isArray(value)) {
13751
- el.checked = looseIndexOf(value, vnode.props.value) > -1;
13775
+ checked = looseIndexOf(value, vnode.props.value) > -1;
13752
13776
  } else if (isSet(value)) {
13753
- el.checked = value.has(vnode.props.value);
13754
- } else if (value !== oldValue) {
13755
- el.checked = looseEqual(value, getCheckboxValue(el, true));
13777
+ checked = value.has(vnode.props.value);
13778
+ } else {
13779
+ checked = looseEqual(value, getCheckboxValue(el, true));
13780
+ }
13781
+ if (el.checked !== checked) {
13782
+ el.checked = checked;
13756
13783
  }
13757
13784
  }
13758
13785
  const vModelRadio = {
@@ -18051,7 +18078,7 @@ function genNode(node, context) {
18051
18078
  case 26:
18052
18079
  genReturnStatement(node, context);
18053
18080
  break;
18054
- /* istanbul ignore next */
18081
+ /* v8 ignore start */
18055
18082
  case 10:
18056
18083
  break;
18057
18084
  default:
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compat v3.5.0-beta.3
2
+ * @vue/compat v3.5.0
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -379,12 +379,13 @@ class EffectScope {
379
379
  pause() {
380
380
  if (this._active) {
381
381
  this._isPaused = true;
382
+ let i, l;
382
383
  if (this.scopes) {
383
- for (let i = 0, l = this.scopes.length; i < l; i++) {
384
+ for (i = 0, l = this.scopes.length; i < l; i++) {
384
385
  this.scopes[i].pause();
385
386
  }
386
387
  }
387
- for (let i = 0, l = this.effects.length; i < l; i++) {
388
+ for (i = 0, l = this.effects.length; i < l; i++) {
388
389
  this.effects[i].pause();
389
390
  }
390
391
  }
@@ -396,12 +397,13 @@ class EffectScope {
396
397
  if (this._active) {
397
398
  if (this._isPaused) {
398
399
  this._isPaused = false;
400
+ let i, l;
399
401
  if (this.scopes) {
400
- for (let i = 0, l = this.scopes.length; i < l; i++) {
402
+ for (i = 0, l = this.scopes.length; i < l; i++) {
401
403
  this.scopes[i].resume();
402
404
  }
403
405
  }
404
- for (let i = 0, l = this.effects.length; i < l; i++) {
406
+ for (i = 0, l = this.effects.length; i < l; i++) {
405
407
  this.effects[i].resume();
406
408
  }
407
409
  }
@@ -583,11 +585,9 @@ function startBatch() {
583
585
  batchDepth++;
584
586
  }
585
587
  function endBatch() {
586
- if (batchDepth > 1) {
587
- batchDepth--;
588
+ if (--batchDepth > 0) {
588
589
  return;
589
590
  }
590
- batchDepth--;
591
591
  let error;
592
592
  while (batchedEffect) {
593
593
  let e = batchedEffect;
@@ -1064,7 +1064,7 @@ function apply(self, method, fn, thisArg, wrappedRetFn, args) {
1064
1064
  const needsWrap = arr !== self && !isShallow(self);
1065
1065
  const methodFn = arr[method];
1066
1066
  if (methodFn !== arrayProto[method]) {
1067
- const result2 = methodFn.apply(arr, args);
1067
+ const result2 = methodFn.apply(self, args);
1068
1068
  return needsWrap ? toReactive(result2) : result2;
1069
1069
  }
1070
1070
  let wrappedFn = fn;
@@ -1206,7 +1206,12 @@ class MutableReactiveHandler extends BaseReactiveHandler {
1206
1206
  }
1207
1207
  }
1208
1208
  const hadKey = isArray(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
1209
- const result = Reflect.set(target, key, value, receiver);
1209
+ const result = Reflect.set(
1210
+ target,
1211
+ key,
1212
+ value,
1213
+ isRef(target) ? target : receiver
1214
+ );
1210
1215
  if (target === toRaw(receiver)) {
1211
1216
  if (!hadKey) {
1212
1217
  trigger(target, "add", key, value);
@@ -1937,18 +1942,25 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
1937
1942
  const depth = deep === true ? Infinity : deep;
1938
1943
  getter = () => traverse(baseGetter(), depth);
1939
1944
  }
1945
+ const scope = getCurrentScope();
1946
+ const watchHandle = () => {
1947
+ effect.stop();
1948
+ if (scope) {
1949
+ remove(scope.effects, effect);
1950
+ }
1951
+ };
1940
1952
  if (once) {
1941
1953
  if (cb) {
1942
1954
  const _cb = cb;
1943
1955
  cb = (...args) => {
1944
1956
  _cb(...args);
1945
- effect.stop();
1957
+ watchHandle();
1946
1958
  };
1947
1959
  } else {
1948
1960
  const _getter = getter;
1949
1961
  getter = () => {
1950
1962
  _getter();
1951
- effect.stop();
1963
+ watchHandle();
1952
1964
  };
1953
1965
  }
1954
1966
  }
@@ -2013,13 +2025,6 @@ function watch$1(source, cb, options = EMPTY_OBJ) {
2013
2025
  } else {
2014
2026
  effect.run();
2015
2027
  }
2016
- const scope = getCurrentScope();
2017
- const watchHandle = () => {
2018
- effect.stop();
2019
- if (scope) {
2020
- remove(scope.effects, effect);
2021
- }
2022
- };
2023
2028
  watchHandle.pause = effect.pause.bind(effect);
2024
2029
  watchHandle.resume = effect.resume.bind(effect);
2025
2030
  watchHandle.stop = watchHandle;
@@ -3297,7 +3302,7 @@ function getTransitionRawChildren(children, keepComment = false, parentKey) {
3297
3302
  // @__NO_SIDE_EFFECTS__
3298
3303
  function defineComponent(options, extraOptions) {
3299
3304
  return isFunction(options) ? (
3300
- // #8326: extend call and options.name access are considered side-effects
3305
+ // #8236: extend call and options.name access are considered side-effects
3301
3306
  // by Rollup, so we have to wrap it in a pure-annotated IIFE.
3302
3307
  /* @__PURE__ */ (() => extend$1({ name: options.name }, extraOptions, { setup: options }))()
3303
3308
  ) : options;
@@ -3689,8 +3694,7 @@ function createHydrationFunctions(rendererInternals) {
3689
3694
  const isText = vnode.type === Text;
3690
3695
  if (node) {
3691
3696
  if (isText && !optimized) {
3692
- let next = children[i + 1];
3693
- if (next && (next = normalizeVNode(next)).type === Text) {
3697
+ if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) {
3694
3698
  insert(
3695
3699
  createText(
3696
3700
  node.data.slice(vnode.children.length)
@@ -4225,6 +4229,7 @@ const KeepAliveImpl = {
4225
4229
  );
4226
4230
  const { include, exclude, max } = props;
4227
4231
  if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
4232
+ vnode.shapeFlag &= ~256;
4228
4233
  current = vnode;
4229
4234
  return rawVNode;
4230
4235
  }
@@ -5697,7 +5702,7 @@ function createCompatVue$1(createApp, createSingletonApp) {
5697
5702
  return vm;
5698
5703
  }
5699
5704
  }
5700
- Vue.version = `2.6.14-compat:${"3.5.0-beta.3"}`;
5705
+ Vue.version = `2.6.14-compat:${"3.5.0"}`;
5701
5706
  Vue.config = singletonApp.config;
5702
5707
  Vue.use = (plugin, ...options) => {
5703
5708
  if (plugin && isFunction(plugin.install)) {
@@ -9833,7 +9838,7 @@ function isMemoSame(cached, memo) {
9833
9838
  return true;
9834
9839
  }
9835
9840
 
9836
- const version = "3.5.0-beta.3";
9841
+ const version = "3.5.0";
9837
9842
  const warn$1 = NOOP;
9838
9843
  const ErrorTypeStrings = ErrorTypeStrings$1 ;
9839
9844
  const devtools = void 0;
@@ -10451,15 +10456,20 @@ function compatCoerceAttr(el, key, value, instance = null) {
10451
10456
 
10452
10457
  function patchDOMProp(el, key, value, parentComponent) {
10453
10458
  if (key === "innerHTML" || key === "textContent") {
10454
- if (value == null) return;
10455
- el[key] = value;
10459
+ if (value != null) {
10460
+ el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
10461
+ }
10456
10462
  return;
10457
10463
  }
10458
10464
  const tag = el.tagName;
10459
10465
  if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
10460
10466
  !tag.includes("-")) {
10461
10467
  const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
10462
- const newValue = value == null ? "" : String(value);
10468
+ const newValue = value == null ? (
10469
+ // #11647: value should be set as empty string for null and undefined,
10470
+ // but <input type="checkbox"> should be set as 'on'.
10471
+ el.type === "checkbox" ? "on" : ""
10472
+ ) : String(value);
10463
10473
  if (oldValue !== newValue || !("_value" in el)) {
10464
10474
  el.value = newValue;
10465
10475
  }
@@ -10860,6 +10870,9 @@ class VueElement extends BaseClass {
10860
10870
  delete this._props[key];
10861
10871
  } else {
10862
10872
  this._props[key] = val;
10873
+ if (key === "key" && this._app) {
10874
+ this._app._ceVNode.key = val;
10875
+ }
10863
10876
  }
10864
10877
  if (shouldUpdate && this._instance) {
10865
10878
  this._update();
@@ -11257,12 +11270,16 @@ const vModelCheckbox = {
11257
11270
  };
11258
11271
  function setChecked(el, { value, oldValue }, vnode) {
11259
11272
  el._modelValue = value;
11273
+ let checked;
11260
11274
  if (isArray(value)) {
11261
- el.checked = looseIndexOf(value, vnode.props.value) > -1;
11275
+ checked = looseIndexOf(value, vnode.props.value) > -1;
11262
11276
  } else if (isSet(value)) {
11263
- el.checked = value.has(vnode.props.value);
11264
- } else if (value !== oldValue) {
11265
- el.checked = looseEqual(value, getCheckboxValue(el, true));
11277
+ checked = value.has(vnode.props.value);
11278
+ } else {
11279
+ checked = looseEqual(value, getCheckboxValue(el, true));
11280
+ }
11281
+ if (el.checked !== checked) {
11282
+ el.checked = checked;
11266
11283
  }
11267
11284
  }
11268
11285
  const vModelRadio = {