MCPcopy Create free account
hub / github.com/TruthHun/BookStack / stateMixin

Function stateMixin

static/vuejs/vue.runtime.esm.js:2864–2906  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

2862}
2863
2864function stateMixin (Vue) {
2865 // flow somehow has problems with directly declared definition object
2866 // when using Object.defineProperty, so we have to procedurally build up
2867 // the object here.
2868 var dataDef = {};
2869 dataDef.get = function () { return this._data };
2870 var propsDef = {};
2871 propsDef.get = function () { return this._props };
2872 if (process.env.NODE_ENV !== 'production') {
2873 dataDef.set = function (newData) {
2874 warn(
2875 'Avoid replacing instance root $data. ' +
2876 'Use nested data properties instead.',
2877 this
2878 );
2879 };
2880 propsDef.set = function () {
2881 warn("$props is readonly.", this);
2882 };
2883 }
2884 Object.defineProperty(Vue.prototype, '$data', dataDef);
2885 Object.defineProperty(Vue.prototype, '$props', propsDef);
2886
2887 Vue.prototype.$set = set;
2888 Vue.prototype.$delete = del;
2889
2890 Vue.prototype.$watch = function (
2891 expOrFn,
2892 cb,
2893 options
2894 ) {
2895 var vm = this;
2896 options = options || {};
2897 options.user = true;
2898 var watcher = new Watcher(vm, expOrFn, cb, options);
2899 if (options.immediate) {
2900 cb.call(vm, watcher.value);
2901 }
2902 return function unwatchFn () {
2903 watcher.teardown();
2904 }
2905 };
2906}
2907
2908/* */
2909

Callers 1

vue.runtime.esm.jsFile · 0.70

Calls 1

warnFunction · 0.50

Tested by

no test coverage detected