(vm, computed)
| 2756 | var computedWatcherOptions = { lazy: true }; |
| 2757 | |
| 2758 | function initComputed (vm, computed) { |
| 2759 | var watchers = vm._computedWatchers = Object.create(null); |
| 2760 | |
| 2761 | for (var key in computed) { |
| 2762 | var userDef = computed[key]; |
| 2763 | var getter = typeof userDef === 'function' ? userDef : userDef.get; |
| 2764 | if (process.env.NODE_ENV !== 'production') { |
| 2765 | if (getter === undefined) { |
| 2766 | warn( |
| 2767 | ("No getter function has been defined for computed property \"" + key + "\"."), |
| 2768 | vm |
| 2769 | ); |
| 2770 | getter = noop; |
| 2771 | } |
| 2772 | } |
| 2773 | // create internal watcher for the computed property. |
| 2774 | watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions); |
| 2775 | |
| 2776 | // component-defined computed properties are already defined on the |
| 2777 | // component prototype. We only need to define computed properties defined |
| 2778 | // at instantiation here. |
| 2779 | if (!(key in vm)) { |
| 2780 | defineComputed(vm, key, userDef); |
| 2781 | } |
| 2782 | } |
| 2783 | } |
| 2784 | |
| 2785 | function defineComputed (target, key, userDef) { |
| 2786 | if (typeof userDef === 'function') { |
no test coverage detected