File tree Expand file tree Collapse file tree 5 files changed +30
-27
lines changed Expand file tree Collapse file tree 5 files changed +30
-27
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,13 @@ module.exports = {
48
48
49
49
async : true ,
50
50
51
+ /**
52
+ * Whether to warn against errors caught when evaluating
53
+ * expressions.
54
+ */
55
+
56
+ warnExpressionErrors : true ,
57
+
51
58
/**
52
59
* Internal flag to indicate the delimiters have been
53
60
* changed.
Original file line number Diff line number Diff line change @@ -225,10 +225,7 @@ function formatAccessor(key) {
225
225
*/
226
226
227
227
exports . compileGetter = function ( path ) {
228
- var body =
229
- 'try{return o' +
230
- path . map ( formatAccessor ) . join ( '' ) +
231
- '}catch(e){};'
228
+ var body = 'return o' + path . map ( formatAccessor ) . join ( '' )
232
229
return new Function ( 'o' , body )
233
230
}
234
231
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ var config = require('../config')
9
9
enableDebug ( )
10
10
11
11
function enableDebug ( ) {
12
+
12
13
var hasConsole = typeof console !== 'undefined'
13
14
14
15
/**
@@ -29,17 +30,20 @@ function enableDebug () {
29
30
* @param {String } msg
30
31
*/
31
32
33
+ var warned = false
32
34
exports . warn = function ( msg ) {
33
- if ( hasConsole && ! config . silent ) {
35
+ if ( hasConsole && ( ! config . silent || config . debug ) ) {
36
+ if ( ! config . debug && ! warned ) {
37
+ warned = true
38
+ console . log (
39
+ 'Set `Vue.config.debug = true` to enable debug mode.'
40
+ )
41
+ }
34
42
console . warn ( '[Vue warn]: ' + msg )
35
43
/* istanbul ignore if */
36
44
if ( config . debug ) {
37
45
/* jshint debug: true */
38
46
debugger
39
- } else {
40
- console . log (
41
- 'Set `Vue.config.debug = true` to enable debug mode.'
42
- )
43
47
}
44
48
}
45
49
}
Original file line number Diff line number Diff line change @@ -77,10 +77,12 @@ p.get = function () {
77
77
try {
78
78
value = this . getter . call ( vm , vm )
79
79
} catch ( e ) {
80
- _ . warn (
81
- 'Error when evaluating expression "' +
82
- this . expression + '":\n ' + e
83
- )
80
+ if ( config . warnExpressionErrors ) {
81
+ _ . warn (
82
+ 'Error when evaluating expression "' +
83
+ this . expression + '":\n ' + e
84
+ )
85
+ }
84
86
}
85
87
// "touch" every property so they are all tracked as
86
88
// dependencies for deep watching
@@ -106,10 +108,12 @@ p.set = function (value) {
106
108
try {
107
109
this . setter . call ( vm , vm , value )
108
110
} catch ( e ) {
109
- _ . warn (
110
- 'Error when evaluating setter "' +
111
- this . expression + '":\n ' + e
112
- )
111
+ if ( config . warnExpressionErrors ) {
112
+ _ . warn (
113
+ 'Error when evaluating setter "' +
114
+ this . expression + '":\n ' + e
115
+ )
116
+ }
113
117
}
114
118
}
115
119
Original file line number Diff line number Diff line change @@ -3,16 +3,7 @@ var _ = require('../../../../src/util')
3
3
4
4
var testCases = [
5
5
{
6
- // simple path that doesn't exist
7
- exp : 'a.b.c' ,
8
- scope : {
9
- a : { }
10
- } ,
11
- expected : undefined ,
12
- paths : [ 'a' ]
13
- } ,
14
- {
15
- // simple path that exists
6
+ // simple path
16
7
exp : 'a.b.d' ,
17
8
scope : {
18
9
a :{ b :{ d :123 } }
You can’t perform that action at this time.
0 commit comments