MCPcopy Create free account
hub / github.com/TruthHun/BookStack / defineReactive$$1

Function defineReactive$$1

static/vuejs/vue.common.js:818–871  ·  view source on GitHub ↗

* Define a reactive property on an Object.

(
  obj,
  key,
  val,
  customSetter
)

Source from the content-addressed store, hash-verified

816 * Define a reactive property on an Object.
817 */
818function defineReactive$$1 (
819 obj,
820 key,
821 val,
822 customSetter
823) {
824 var dep = new Dep();
825
826 var property = Object.getOwnPropertyDescriptor(obj, key);
827 if (property && property.configurable === false) {
828 return
829 }
830
831 // cater for pre-defined getter/setters
832 var getter = property && property.get;
833 var setter = property && property.set;
834
835 var childOb = observe(val);
836 Object.defineProperty(obj, key, {
837 enumerable: true,
838 configurable: true,
839 get: function reactiveGetter () {
840 var value = getter ? getter.call(obj) : val;
841 if (Dep.target) {
842 dep.depend();
843 if (childOb) {
844 childOb.dep.depend();
845 }
846 if (Array.isArray(value)) {
847 dependArray(value);
848 }
849 }
850 return value
851 },
852 set: function reactiveSetter (newVal) {
853 var value = getter ? getter.call(obj) : val;
854 /* eslint-disable no-self-compare */
855 if (newVal === value || (newVal !== newVal && value !== value)) {
856 return
857 }
858 /* eslint-enable no-self-compare */
859 if (process.env.NODE_ENV !== 'production' && customSetter) {
860 customSetter();
861 }
862 if (setter) {
863 setter.call(obj, newVal);
864 } else {
865 val = newVal;
866 }
867 childOb = observe(newVal);
868 dep.notify();
869 }
870 });
871}
872
873/**
874 * Set a property on an object. Adds the new property and

Callers 3

vue.common.jsFile · 0.70
setFunction · 0.70
loopFunction · 0.70

Calls 2

observeFunction · 0.70
dependArrayFunction · 0.70

Tested by

no test coverage detected