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

Function stateMixin

static/vuejs/vue.common.js:2870–2912  ·  view source on GitHub ↗
(Vue)

Source from the content-addressed store, hash-verified

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

Callers 1

vue.common.jsFile · 0.70

Calls 1

warnFunction · 0.50

Tested by

no test coverage detected