Pārlūkot izejas kodu

rename errorHandler config

Evan You 10 gadi atpakaļ
vecāks
revīzija
1fc251cfa4

+ 1 - 1
src/core/config.js

@@ -36,7 +36,7 @@ const config: Config = {
   /**
    * Error handler for watcher errors
    */
-  watcherErrorHandler: null,
+  errorHandler: null,
 
   /**
    * Check if a tag is reserved so that it cannot be registered as a

+ 1 - 1
src/core/observer/watcher.js

@@ -103,7 +103,7 @@ export default class Watcher {
           )
         }
         // throw the error on next tick so that it doesn't break the whole app
-        ;(config.watcherErrorHandler || defaultErrorHandler)(e, this.vm)
+        ;(config.errorHandler || defaultErrorHandler)(e, this.vm)
       }
       // return old value when evaluation fails so the current UI is preserved
       value = this.value

+ 4 - 2
test/unit/modules/observer/watcher.spec.js

@@ -199,17 +199,18 @@ describe('Watcher', () => {
   })
 
   it('catch getter error', () => {
-    Vue.config.watcherErrorHandler = spy
+    Vue.config.errorHandler = spy
     const err = new Error()
     const vm = new Vue({
       render () { throw err }
     }).$mount()
     expect('Error during component render').toHaveBeenWarned()
     expect(spy).toHaveBeenCalledWith(err, vm)
+    Vue.config.errorHandler = null
   })
 
   it('catch user watcher error', () => {
-    Vue.config.watcherErrorHandler = spy
+    Vue.config.errorHandler = spy
     new Watcher(vm, function () {
       return this.a.b.c
     }, () => {}, { user: true })
@@ -217,5 +218,6 @@ describe('Watcher', () => {
     expect(spy).toHaveBeenCalled()
     expect(spy.calls.argsFor(0)[0] instanceof TypeError).toBe(true)
     expect(spy.calls.argsFor(0)[1]).toBe(vm)
+    Vue.config.errorHandler = null
   })
 })