MCPcopy
hub / github.com/HumanSignal/label-studio / initComputed

Function initComputed

docs/themes/htx/source/js/vue.js:3323–3354  ·  view source on GitHub ↗
(vm, computed)

Source from the content-addressed store, hash-verified

3321 var computedWatcherOptions = { lazy: true };
3322
3323 function initComputed(vm, computed) {
3324 // $flow-disable-line
3325 var watchers = (vm._computedWatchers = Object.create(null));
3326 // computed properties are just getters during SSR
3327 var isSSR = isServerRendering();
3328
3329 for (var key in computed) {
3330 var userDef = computed[key];
3331 var getter = typeof userDef === "function" ? userDef : userDef.get;
3332 if ("development" !== "production" && getter == null) {
3333 warn('Getter is missing for computed property "' + key + '".', vm);
3334 }
3335
3336 if (!isSSR) {
3337 // create internal watcher for the computed property.
3338 watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
3339 }
3340
3341 // component-defined computed properties are already defined on the
3342 // component prototype. We only need to define computed properties defined
3343 // at instantiation here.
3344 if (!(key in vm)) {
3345 defineComputed(vm, key, userDef);
3346 } else {
3347 if (key in vm.$data) {
3348 warn('The computed property "' + key + '" is already defined in data.', vm);
3349 } else if (vm.$options.props && key in vm.$options.props) {
3350 warn('The computed property "' + key + '" is already defined as a prop.', vm);
3351 }
3352 }
3353 }
3354 }
3355
3356 function defineComputed(target, key, userDef) {
3357 var shouldCache = !isServerRendering();

Callers 1

initStateFunction · 0.85

Calls 3

isServerRenderingFunction · 0.85
defineComputedFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected