vue 2.7.12 → 2.7.14

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Vue.js v2.7.12
2
+ * Vue.js v2.7.14
3
3
  * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -751,77 +751,6 @@ methodsToPatch.forEach(function (method) {
751
751
  });
752
752
  });
753
753
 
754
- const rawMap = new WeakMap();
755
- function reactive(target) {
756
- makeReactive(target, false);
757
- return target;
758
- }
759
- /**
760
- * Return a shallowly-reactive copy of the original object, where only the root
761
- * level properties are reactive. It also does not auto-unwrap refs (even at the
762
- * root level).
763
- */
764
- function shallowReactive(target) {
765
- makeReactive(target, true);
766
- def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
767
- return target;
768
- }
769
- function makeReactive(target, shallow) {
770
- // if trying to observe a readonly proxy, return the readonly version.
771
- if (!isReadonly(target)) {
772
- {
773
- if (isArray(target)) {
774
- warn(`Avoid using Array as root value for ${shallow ? `shallowReactive()` : `reactive()`} as it cannot be tracked in watch() or watchEffect(). Use ${shallow ? `shallowRef()` : `ref()`} instead. This is a Vue-2-only limitation.`);
775
- }
776
- const existingOb = target && target.__ob__;
777
- if (existingOb && existingOb.shallow !== shallow) {
778
- warn(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
779
- }
780
- }
781
- const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
782
- if (!ob) {
783
- if (target == null || isPrimitive(target)) {
784
- warn(`value cannot be made reactive: ${String(target)}`);
785
- }
786
- if (isCollectionType(target)) {
787
- warn(`Vue 2 does not support reactive collection types such as Map or Set.`);
788
- }
789
- }
790
- }
791
- }
792
- function isReactive(value) {
793
- if (isReadonly(value)) {
794
- return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
795
- }
796
- return !!(value && value.__ob__);
797
- }
798
- function isShallow(value) {
799
- return !!(value && value.__v_isShallow);
800
- }
801
- function isReadonly(value) {
802
- return !!(value && value.__v_isReadonly);
803
- }
804
- function isProxy(value) {
805
- return isReactive(value) || isReadonly(value);
806
- }
807
- function toRaw(observed) {
808
- const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
809
- return raw ? toRaw(raw) : observed;
810
- }
811
- function markRaw(value) {
812
- if (isObject(value)) {
813
- rawMap.set(value, true);
814
- }
815
- return value;
816
- }
817
- /**
818
- * @internal
819
- */
820
- function isCollectionType(value) {
821
- const type = toRawType(value);
822
- return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
823
- }
824
-
825
754
  const arrayKeys = Object.getOwnPropertyNames(arrayMethods);
826
755
  const NO_INIITIAL_VALUE = {};
827
756
  /**
@@ -908,7 +837,6 @@ function observe(value, shallow, ssrMockReactivity) {
908
837
  (isArray(value) || isPlainObject(value)) &&
909
838
  Object.isExtensible(value) &&
910
839
  !value.__v_skip /* ReactiveFlags.SKIP */ &&
911
- !rawMap.has(value) &&
912
840
  !isRef(value) &&
913
841
  !(value instanceof VNode)) {
914
842
  return new Observer(value, shallow, ssrMockReactivity);
@@ -1081,6 +1009,77 @@ function dependArray(value) {
1081
1009
  }
1082
1010
  }
1083
1011
 
1012
+ function reactive(target) {
1013
+ makeReactive(target, false);
1014
+ return target;
1015
+ }
1016
+ /**
1017
+ * Return a shallowly-reactive copy of the original object, where only the root
1018
+ * level properties are reactive. It also does not auto-unwrap refs (even at the
1019
+ * root level).
1020
+ */
1021
+ function shallowReactive(target) {
1022
+ makeReactive(target, true);
1023
+ def(target, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
1024
+ return target;
1025
+ }
1026
+ function makeReactive(target, shallow) {
1027
+ // if trying to observe a readonly proxy, return the readonly version.
1028
+ if (!isReadonly(target)) {
1029
+ {
1030
+ if (isArray(target)) {
1031
+ warn(`Avoid using Array as root value for ${shallow ? `shallowReactive()` : `reactive()`} as it cannot be tracked in watch() or watchEffect(). Use ${shallow ? `shallowRef()` : `ref()`} instead. This is a Vue-2-only limitation.`);
1032
+ }
1033
+ const existingOb = target && target.__ob__;
1034
+ if (existingOb && existingOb.shallow !== shallow) {
1035
+ warn(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
1036
+ }
1037
+ }
1038
+ const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
1039
+ if (!ob) {
1040
+ if (target == null || isPrimitive(target)) {
1041
+ warn(`value cannot be made reactive: ${String(target)}`);
1042
+ }
1043
+ if (isCollectionType(target)) {
1044
+ warn(`Vue 2 does not support reactive collection types such as Map or Set.`);
1045
+ }
1046
+ }
1047
+ }
1048
+ }
1049
+ function isReactive(value) {
1050
+ if (isReadonly(value)) {
1051
+ return isReactive(value["__v_raw" /* ReactiveFlags.RAW */]);
1052
+ }
1053
+ return !!(value && value.__ob__);
1054
+ }
1055
+ function isShallow(value) {
1056
+ return !!(value && value.__v_isShallow);
1057
+ }
1058
+ function isReadonly(value) {
1059
+ return !!(value && value.__v_isReadonly);
1060
+ }
1061
+ function isProxy(value) {
1062
+ return isReactive(value) || isReadonly(value);
1063
+ }
1064
+ function toRaw(observed) {
1065
+ const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
1066
+ return raw ? toRaw(raw) : observed;
1067
+ }
1068
+ function markRaw(value) {
1069
+ // non-extensible objects won't be observed anyway
1070
+ if (Object.isExtensible(value)) {
1071
+ def(value, "__v_skip" /* ReactiveFlags.SKIP */, true);
1072
+ }
1073
+ return value;
1074
+ }
1075
+ /**
1076
+ * @internal
1077
+ */
1078
+ function isCollectionType(value) {
1079
+ const type = toRawType(value);
1080
+ return (type === 'Map' || type === 'WeakMap' || type === 'Set' || type === 'WeakSet');
1081
+ }
1082
+
1084
1083
  /**
1085
1084
  * @internal
1086
1085
  */
@@ -1216,8 +1215,8 @@ function toRef(object, key, defaultValue) {
1216
1215
  return ref;
1217
1216
  }
1218
1217
 
1219
- const rawToReadonlyMap = new WeakMap();
1220
- const rawToShallowReadonlyMap = new WeakMap();
1218
+ const rawToReadonlyFlag = `__v_rawToReadonly`;
1219
+ const rawToShallowReadonlyFlag = `__v_rawToShallowReadonly`;
1221
1220
  function readonly(target) {
1222
1221
  return createReadonly(target, false);
1223
1222
  }
@@ -1236,18 +1235,21 @@ function createReadonly(target, shallow) {
1236
1235
  }
1237
1236
  return target;
1238
1237
  }
1238
+ if (!Object.isExtensible(target)) {
1239
+ warn(`Vue 2 does not support creating readonly proxy for non-extensible object.`);
1240
+ }
1239
1241
  // already a readonly object
1240
1242
  if (isReadonly(target)) {
1241
1243
  return target;
1242
1244
  }
1243
1245
  // already has a readonly proxy
1244
- const map = shallow ? rawToShallowReadonlyMap : rawToReadonlyMap;
1245
- const existingProxy = map.get(target);
1246
+ const existingFlag = shallow ? rawToShallowReadonlyFlag : rawToReadonlyFlag;
1247
+ const existingProxy = target[existingFlag];
1246
1248
  if (existingProxy) {
1247
1249
  return existingProxy;
1248
1250
  }
1249
1251
  const proxy = Object.create(Object.getPrototypeOf(target));
1250
- map.set(target, proxy);
1252
+ def(target, existingFlag, proxy);
1251
1253
  def(proxy, "__v_isReadonly" /* ReactiveFlags.IS_READONLY */, true);
1252
1254
  def(proxy, "__v_raw" /* ReactiveFlags.RAW */, target);
1253
1255
  if (isRef(target)) {
@@ -1549,6 +1551,7 @@ function doWatch(source, cb, { immediate, deep, flush = 'pre', onTrack, onTrigge
1549
1551
  let activeEffectScope;
1550
1552
  class EffectScope {
1551
1553
  constructor(detached = false) {
1554
+ this.detached = detached;
1552
1555
  /**
1553
1556
  * @internal
1554
1557
  */
@@ -1561,8 +1564,8 @@ class EffectScope {
1561
1564
  * @internal
1562
1565
  */
1563
1566
  this.cleanups = [];
1567
+ this.parent = activeEffectScope;
1564
1568
  if (!detached && activeEffectScope) {
1565
- this.parent = activeEffectScope;
1566
1569
  this.index =
1567
1570
  (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
1568
1571
  }
@@ -1611,7 +1614,7 @@ class EffectScope {
1611
1614
  }
1612
1615
  }
1613
1616
  // nested scope, dereference from parent to avoid memory leaks
1614
- if (this.parent && !fromParent) {
1617
+ if (!this.detached && this.parent && !fromParent) {
1615
1618
  // optimized O(1) removal
1616
1619
  const last = this.parent.scopes.pop();
1617
1620
  if (last && last !== this) {
@@ -1619,6 +1622,7 @@ class EffectScope {
1619
1622
  last.index = this.index;
1620
1623
  }
1621
1624
  }
1625
+ this.parent = undefined;
1622
1626
  this.active = false;
1623
1627
  }
1624
1628
  }
@@ -3214,7 +3218,7 @@ function onErrorCaptured(hook, target = currentInstance) {
3214
3218
  /**
3215
3219
  * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
3216
3220
  */
3217
- const version = '2.7.12';
3221
+ const version = '2.7.14';
3218
3222
  /**
3219
3223
  * @internal type is manually declared in <root>/types/v3-define-component.d.ts
3220
3224
  */
@@ -3297,6 +3301,7 @@ function _traverse(val, seen) {
3297
3301
  let i, keys;
3298
3302
  const isA = isArray(val);
3299
3303
  if ((!isA && !isObject(val)) ||
3304
+ val.__v_skip /* ReactiveFlags.SKIP */ ||
3300
3305
  Object.isFrozen(val) ||
3301
3306
  val instanceof VNode) {
3302
3307
  return;
@@ -4631,7 +4636,7 @@ const strats = config.optionMergeStrategies;
4631
4636
  /**
4632
4637
  * Helper that recursively merges two data objects together.
4633
4638
  */
4634
- function mergeData(to, from) {
4639
+ function mergeData(to, from, recursive = true) {
4635
4640
  if (!from)
4636
4641
  return to;
4637
4642
  let key, toVal, fromVal;
@@ -4645,7 +4650,7 @@ function mergeData(to, from) {
4645
4650
  continue;
4646
4651
  toVal = to[key];
4647
4652
  fromVal = from[key];
4648
- if (!hasOwn(to, key)) {
4653
+ if (!recursive || !hasOwn(to, key)) {
4649
4654
  set(to, key, fromVal);
4650
4655
  }
4651
4656
  else if (toVal !== fromVal &&
@@ -4805,7 +4810,19 @@ strats.props =
4805
4810
  extend(ret, childVal);
4806
4811
  return ret;
4807
4812
  };
4808
- strats.provide = mergeDataOrFn;
4813
+ strats.provide = function (parentVal, childVal) {
4814
+ if (!parentVal)
4815
+ return childVal;
4816
+ return function () {
4817
+ const ret = Object.create(null);
4818
+ mergeData(ret, isFunction(parentVal) ? parentVal.call(this) : parentVal);
4819
+ if (childVal) {
4820
+ mergeData(ret, isFunction(childVal) ? childVal.call(this) : childVal, false // non-recursive
4821
+ );
4822
+ }
4823
+ return ret;
4824
+ };
4825
+ };
4809
4826
  /**
4810
4827
  * Default strategy.
4811
4828
  */