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 = {
4848
4949 async : true ,
5050
51+ /**
52+ * Whether to warn against errors caught when evaluating
53+ * expressions.
54+ */
55+
56+ warnExpressionErrors : true ,
57+
5158 /**
5259 * Internal flag to indicate the delimiters have been
5360 * changed.
Original file line number Diff line number Diff line change @@ -225,10 +225,7 @@ function formatAccessor(key) {
225225 */
226226
227227exports . 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 ( '' )
232229 return new Function ( 'o' , body )
233230}
234231
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ var config = require('../config')
99enableDebug ( )
1010
1111function enableDebug ( ) {
12+
1213 var hasConsole = typeof console !== 'undefined'
1314
1415 /**
@@ -29,17 +30,20 @@ function enableDebug () {
2930 * @param {String } msg
3031 */
3132
33+ var warned = false
3234 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+ }
3442 console . warn ( '[Vue warn]: ' + msg )
3543 /* istanbul ignore if */
3644 if ( config . debug ) {
3745 /* jshint debug: true */
3846 debugger
39- } else {
40- console . log (
41- 'Set `Vue.config.debug = true` to enable debug mode.'
42- )
4347 }
4448 }
4549 }
Original file line number Diff line number Diff line change @@ -77,10 +77,12 @@ p.get = function () {
7777 try {
7878 value = this . getter . call ( vm , vm )
7979 } 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+ }
8486 }
8587 // "touch" every property so they are all tracked as
8688 // dependencies for deep watching
@@ -106,10 +108,12 @@ p.set = function (value) {
106108 try {
107109 this . setter . call ( vm , vm , value )
108110 } 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+ }
113117 }
114118}
115119
Original file line number Diff line number Diff line change @@ -3,16 +3,7 @@ var _ = require('../../../../src/util')
33
44var testCases = [
55 {
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
167 exp : 'a.b.d' ,
178 scope : {
189 a :{ b :{ d :123 } }
You can’t perform that action at this time.
0 commit comments