File tree Expand file tree Collapse file tree 4 files changed +27
-17
lines changed Expand file tree Collapse file tree 4 files changed +27
-17
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,14 @@ function enableDebug () {
3232 exports . warn = function ( msg ) {
3333 if ( hasConsole && ! config . silent ) {
3434 console . warn ( '[Vue warn]: ' + msg )
35- if ( config . debug && console . trace ) {
36- console . trace ( )
35+ /* istanbul ignore if */
36+ if ( config . debug ) {
37+ /* jshint debug: true */
38+ debugger
39+ } else {
40+ console . log (
41+ 'Set `Vue.config.debug = true` to enable debug mode.'
42+ )
3743 }
3844 }
3945 }
Original file line number Diff line number Diff line change @@ -77,7 +77,10 @@ p.get = function () {
7777 try {
7878 value = this . getter . call ( vm , vm )
7979 } catch ( e ) {
80- _ . warn ( e )
80+ _ . warn (
81+ 'Error when evaluating expression "' +
82+ this . expression + '":\n ' + e
83+ )
8184 }
8285 // "touch" every property so they are all tracked as
8386 // dependencies for deep watching
@@ -102,7 +105,12 @@ p.set = function (value) {
102105 )
103106 try {
104107 this . setter . call ( vm , vm , value )
105- } catch ( e ) { }
108+ } catch ( e ) {
109+ _ . warn (
110+ 'Error when evaluating setter "' +
111+ this . expression + '":\n ' + e
112+ )
113+ }
106114}
107115
108116/**
@@ -134,10 +142,10 @@ p.afterGet = function () {
134142 */
135143
136144p . update = function ( ) {
137- if ( config . async ) {
138- batcher . push ( this )
139- } else {
145+ if ( ! config . async || config . debug ) {
140146 this . run ( )
147+ } else {
148+ batcher . push ( this )
141149 }
142150}
143151
Original file line number Diff line number Diff line change @@ -40,15 +40,5 @@ if (typeof console !== 'undefined') {
4040 expect ( console . warn ) . not . toHaveBeenCalled ( )
4141 } )
4242
43- if ( console . trace ) {
44- it ( 'trace when not silent and debugging' , function ( ) {
45- config . debug = true
46- config . silent = false
47- _ . warn ( 'haha' )
48- expect ( console . trace ) . toHaveBeenCalled ( )
49- config . debug = false
50- config . silent = true
51- } )
52- }
5343 } )
5444}
Original file line number Diff line number Diff line change @@ -391,4 +391,10 @@ describe('Watcher', function () {
391391 expect ( _ . warn ) . toHaveBeenCalled ( )
392392 } )
393393
394+ it ( 'warn setter errors' , function ( ) {
395+ var watcher = new Watcher ( vm , 'a + b' , spy )
396+ watcher . set ( 123 )
397+ expect ( _ . warn ) . toHaveBeenCalled ( )
398+ } )
399+
394400} )
You can’t perform that action at this time.
0 commit comments