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 () {
32
32
exports . warn = function ( msg ) {
33
33
if ( hasConsole && ! config . silent ) {
34
34
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
+ )
37
43
}
38
44
}
39
45
}
Original file line number Diff line number Diff line change @@ -77,7 +77,10 @@ p.get = function () {
77
77
try {
78
78
value = this . getter . call ( vm , vm )
79
79
} catch ( e ) {
80
- _ . warn ( e )
80
+ _ . warn (
81
+ 'Error when evaluating expression "' +
82
+ this . expression + '":\n ' + e
83
+ )
81
84
}
82
85
// "touch" every property so they are all tracked as
83
86
// dependencies for deep watching
@@ -102,7 +105,12 @@ p.set = function (value) {
102
105
)
103
106
try {
104
107
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
+ }
106
114
}
107
115
108
116
/**
@@ -134,10 +142,10 @@ p.afterGet = function () {
134
142
*/
135
143
136
144
p . update = function ( ) {
137
- if ( config . async ) {
138
- batcher . push ( this )
139
- } else {
145
+ if ( ! config . async || config . debug ) {
140
146
this . run ( )
147
+ } else {
148
+ batcher . push ( this )
141
149
}
142
150
}
143
151
Original file line number Diff line number Diff line change @@ -40,15 +40,5 @@ if (typeof console !== 'undefined') {
40
40
expect ( console . warn ) . not . toHaveBeenCalled ( )
41
41
} )
42
42
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
- }
53
43
} )
54
44
}
Original file line number Diff line number Diff line change @@ -391,4 +391,10 @@ describe('Watcher', function () {
391
391
expect ( _ . warn ) . toHaveBeenCalled ( )
392
392
} )
393
393
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
+
394
400
} )
You can’t perform that action at this time.
0 commit comments