vue 2.7.13 → 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.13
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)) {
@@ -3216,7 +3218,7 @@ function onErrorCaptured(hook, target = currentInstance) {
3216
3218
  /**
3217
3219
  * Note: also update dist/vue.runtime.mjs when adding new exports to this file.
3218
3220
  */
3219
- const version = '2.7.13';
3221
+ const version = '2.7.14';
3220
3222
  /**
3221
3223
  * @internal type is manually declared in <root>/types/v3-define-component.d.ts
3222
3224
  */
@@ -4634,7 +4636,7 @@ const strats = config.optionMergeStrategies;
4634
4636
  /**
4635
4637
  * Helper that recursively merges two data objects together.
4636
4638
  */
4637
- function mergeData(to, from) {
4639
+ function mergeData(to, from, recursive = true) {
4638
4640
  if (!from)
4639
4641
  return to;
4640
4642
  let key, toVal, fromVal;
@@ -4648,7 +4650,7 @@ function mergeData(to, from) {
4648
4650
  continue;
4649
4651
  toVal = to[key];
4650
4652
  fromVal = from[key];
4651
- if (!hasOwn(to, key)) {
4653
+ if (!recursive || !hasOwn(to, key)) {
4652
4654
  set(to, key, fromVal);
4653
4655
  }
4654
4656
  else if (toVal !== fromVal &&
@@ -4808,7 +4810,19 @@ strats.props =
4808
4810
  extend(ret, childVal);
4809
4811
  return ret;
4810
4812
  };
4811
- 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
+ };
4812
4826
  /**
4813
4827
  * Default strategy.
4814
4828
  */