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