* Helper to register an event/watch callback. * * @param {Vue} vm * @param {String} action * @param {String} key * @param {Function|String|Object} handler * @param {Object} [options]
(vm, action, key, handler, options)
| 8147 | */ |
| 8148 | |
| 8149 | function register(vm, action, key, handler, options) { |
| 8150 | var type = typeof handler; |
| 8151 | if (type === 'function') { |
| 8152 | vm[action](key, handler, options); |
| 8153 | } else if (type === 'string') { |
| 8154 | var methods = vm.$options.methods; |
| 8155 | var method = methods && methods[handler]; |
| 8156 | if (method) { |
| 8157 | vm[action](key, method, options); |
| 8158 | } else { |
| 8159 | 'development' !== 'production' && warn('Unknown method: "' + handler + '" when ' + 'registering callback for ' + action + ': "' + key + '".', vm); |
| 8160 | } |
| 8161 | } else if (handler && type === 'object') { |
| 8162 | register(vm, action, key, handler.handler, handler); |
| 8163 | } |
| 8164 | } |
| 8165 | |
| 8166 | /** |
| 8167 | * Setup recursive attached/detached calls |
no test coverage detected