vue 2.7.2 → 2.7.3

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.2
2
+ * Vue.js v2.7.3
3
3
  * (c) 2014-2022 Evan You
4
4
  * Released under the MIT License.
5
5
  */
@@ -336,7 +336,9 @@ const LIFECYCLE_HOOKS = [
336
336
  'activated',
337
337
  'deactivated',
338
338
  'errorCaptured',
339
- 'serverPrefetch'
339
+ 'serverPrefetch',
340
+ 'renderTracked',
341
+ 'renderTriggered'
340
342
  ];
341
343
 
342
344
  var config = {
@@ -844,7 +846,7 @@ function makeReactive(target, shallow) {
844
846
  warn$2(`Target is already a ${existingOb.shallow ? `` : `non-`}shallow reactive object, and cannot be converted to ${shallow ? `` : `non-`}shallow.`);
845
847
  }
846
848
  }
847
- const ob = observe(target, shallow);
849
+ const ob = observe(target, shallow, isServerRendering() /* ssr mock reactivity */);
848
850
  if (!ob) {
849
851
  if (target == null || isPrimitive(target)) {
850
852
  warn$2(`value cannot be made reactive: ${String(target)}`);
@@ -906,7 +908,7 @@ function createRef(rawValue, shallow) {
906
908
  const ref = {};
907
909
  def(ref, RefFlag, true);
908
910
  def(ref, "__v_isShallow" /* ReactiveFlags.IS_SHALLOW */, true);
909
- ref.dep = defineReactive(ref, 'value', rawValue, null, shallow);
911
+ def(ref, 'dep', defineReactive(ref, 'value', rawValue, null, shallow, isServerRendering()));
910
912
  return ref;
911
913
  }
912
914
  function triggerRef(ref) {
@@ -4603,7 +4605,7 @@ const onServerPrefetch = createLifeCycle('serverPrefetch');
4603
4605
  const onRenderTracked = createLifeCycle('renderTracked');
4604
4606
  const onRenderTriggered = createLifeCycle('renderTriggered');
4605
4607
 
4606
- const version = '2.7.2';
4608
+ const version = '2.7.3';
4607
4609
  /**
4608
4610
  * @internal type is manually declared in <root>/types/v3-define-component.d.ts
4609
4611
  */
@@ -4679,6 +4681,13 @@ let shouldObserve = true;
4679
4681
  function toggleObserving(value) {
4680
4682
  shouldObserve = value;
4681
4683
  }
4684
+ // ssr mock dep
4685
+ const mockDep = {
4686
+ notify: noop,
4687
+ depend: noop,
4688
+ addSub: noop,
4689
+ removeSub: noop
4690
+ };
4682
4691
  /**
4683
4692
  * Observer class that is attached to each observed
4684
4693
  * object. Once attached, the observer converts the target
@@ -4686,76 +4695,60 @@ function toggleObserving(value) {
4686
4695
  * collect dependencies and dispatch updates.
4687
4696
  */
4688
4697
  class Observer {
4689
- constructor(value, shallow = false) {
4698
+ constructor(value, shallow = false, mock = false) {
4690
4699
  this.value = value;
4691
4700
  this.shallow = shallow;
4701
+ this.mock = mock;
4692
4702
  // this.value = value
4693
- this.dep = new Dep();
4703
+ this.dep = mock ? mockDep : new Dep();
4694
4704
  this.vmCount = 0;
4695
4705
  def(value, '__ob__', this);
4696
4706
  if (isArray(value)) {
4697
- if (hasProto) {
4698
- protoAugment(value, arrayMethods);
4699
- }
4700
- else {
4701
- copyAugment(value, arrayMethods, arrayKeys);
4707
+ if (!mock) {
4708
+ if (hasProto) {
4709
+ value.__proto__ = arrayMethods;
4710
+ /* eslint-enable no-proto */
4711
+ }
4712
+ else {
4713
+ for (let i = 0, l = arrayKeys.length; i < l; i++) {
4714
+ const key = arrayKeys[i];
4715
+ def(value, key, arrayMethods[key]);
4716
+ }
4717
+ }
4702
4718
  }
4703
4719
  if (!shallow) {
4704
4720
  this.observeArray(value);
4705
4721
  }
4706
4722
  }
4707
4723
  else {
4708
- this.walk(value, shallow);
4709
- }
4710
- }
4711
- /**
4712
- * Walk through all properties and convert them into
4713
- * getter/setters. This method should only be called when
4714
- * value type is Object.
4715
- */
4716
- walk(obj, shallow) {
4717
- const keys = Object.keys(obj);
4718
- for (let i = 0; i < keys.length; i++) {
4719
- const key = keys[i];
4720
- defineReactive(obj, key, NO_INIITIAL_VALUE, undefined, shallow);
4724
+ /**
4725
+ * Walk through all properties and convert them into
4726
+ * getter/setters. This method should only be called when
4727
+ * value type is Object.
4728
+ */
4729
+ const keys = Object.keys(value);
4730
+ for (let i = 0; i < keys.length; i++) {
4731
+ const key = keys[i];
4732
+ defineReactive(value, key, NO_INIITIAL_VALUE, undefined, shallow, mock);
4733
+ }
4721
4734
  }
4722
4735
  }
4723
4736
  /**
4724
4737
  * Observe a list of Array items.
4725
4738
  */
4726
- observeArray(items) {
4727
- for (let i = 0, l = items.length; i < l; i++) {
4728
- observe(items[i]);
4739
+ observeArray(value) {
4740
+ for (let i = 0, l = value.length; i < l; i++) {
4741
+ observe(value[i], false, this.mock);
4729
4742
  }
4730
4743
  }
4731
4744
  }
4732
4745
  // helpers
4733
- /**
4734
- * Augment a target Object or Array by intercepting
4735
- * the prototype chain using __proto__
4736
- */
4737
- function protoAugment(target, src) {
4738
- /* eslint-disable no-proto */
4739
- target.__proto__ = src;
4740
- /* eslint-enable no-proto */
4741
- }
4742
- /**
4743
- * Augment a target Object or Array by defining
4744
- * hidden properties.
4745
- */
4746
- /* istanbul ignore next */
4747
- function copyAugment(target, src, keys) {
4748
- for (let i = 0, l = keys.length; i < l; i++) {
4749
- const key = keys[i];
4750
- def(target, key, src[key]);
4751
- }
4752
- }
4753
4746
  /**
4754
4747
  * Attempt to create an observer instance for a value,
4755
4748
  * returns the new observer if successfully observed,
4756
4749
  * or the existing observer if the value already has one.
4757
4750
  */
4758
- function observe(value, shallow) {
4751
+ function observe(value, shallow, ssrMockReactivity) {
4759
4752
  if (!isObject(value) || isRef(value) || value instanceof VNode) {
4760
4753
  return;
4761
4754
  }
@@ -4764,18 +4757,18 @@ function observe(value, shallow) {
4764
4757
  ob = value.__ob__;
4765
4758
  }
4766
4759
  else if (shouldObserve &&
4767
- !isServerRendering() &&
4760
+ (ssrMockReactivity || !isServerRendering()) &&
4768
4761
  (isArray(value) || isPlainObject(value)) &&
4769
4762
  Object.isExtensible(value) &&
4770
- !value.__v_skip) {
4771
- ob = new Observer(value, shallow);
4763
+ !value.__v_skip /* ReactiveFlags.SKIP */) {
4764
+ ob = new Observer(value, shallow, ssrMockReactivity);
4772
4765
  }
4773
4766
  return ob;
4774
4767
  }
4775
4768
  /**
4776
4769
  * Define a reactive property on an Object.
4777
4770
  */
4778
- function defineReactive(obj, key, val, customSetter, shallow) {
4771
+ function defineReactive(obj, key, val, customSetter, shallow, mock) {
4779
4772
  const dep = new Dep();
4780
4773
  const property = Object.getOwnPropertyDescriptor(obj, key);
4781
4774
  if (property && property.configurable === false) {
@@ -4788,7 +4781,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
4788
4781
  (val === NO_INIITIAL_VALUE || arguments.length === 2)) {
4789
4782
  val = obj[key];
4790
4783
  }
4791
- let childOb = !shallow && observe(val);
4784
+ let childOb = !shallow && observe(val, false, mock);
4792
4785
  Object.defineProperty(obj, key, {
4793
4786
  enumerable: true,
4794
4787
  configurable: true,
@@ -4833,7 +4826,7 @@ function defineReactive(obj, key, val, customSetter, shallow) {
4833
4826
  else {
4834
4827
  val = newVal;
4835
4828
  }
4836
- childOb = !shallow && observe(newVal);
4829
+ childOb = !shallow && observe(newVal, false, mock);
4837
4830
  {
4838
4831
  dep.notify({
4839
4832
  type: "set" /* TriggerOpTypes.SET */,
@@ -4855,16 +4848,20 @@ function set(target, key, val) {
4855
4848
  warn$2(`Set operation on key "${key}" failed: target is readonly.`);
4856
4849
  return;
4857
4850
  }
4851
+ const ob = target.__ob__;
4858
4852
  if (isArray(target) && isValidArrayIndex(key)) {
4859
4853
  target.length = Math.max(target.length, key);
4860
4854
  target.splice(key, 1, val);
4855
+ // when mocking for SSR, array methods are not hijacked
4856
+ if (!ob.shallow && ob.mock) {
4857
+ observe(val, false, true);
4858
+ }
4861
4859
  return val;
4862
4860
  }
4863
4861
  if (key in target && !(key in Object.prototype)) {
4864
4862
  target[key] = val;
4865
4863
  return val;
4866
4864
  }
4867
- const ob = target.__ob__;
4868
4865
  if (target._isVue || (ob && ob.vmCount)) {
4869
4866
  warn$2('Avoid adding reactive properties to a Vue instance or its root $data ' +
4870
4867
  'at runtime - declare it upfront in the data option.');
@@ -4874,7 +4871,7 @@ function set(target, key, val) {
4874
4871
  target[key] = val;
4875
4872
  return val;
4876
4873
  }
4877
- defineReactive(ob.value, key, val);
4874
+ defineReactive(ob.value, key, val, undefined, ob.shallow, ob.mock);
4878
4875
  {
4879
4876
  ob.dep.notify({
4880
4877
  type: "add" /* TriggerOpTypes.ADD */,