Skip to content

Commit 482fdc0

Browse files
author
Evan You
committed
fix utils.warn not stripped in prod build
1 parent a8d5a35 commit 482fdc0

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

src/directive.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ Directive.split = function (exp) {
191191
Directive.parse = function (dirname, expression, compiler, node) {
192192

193193
var dir = compiler.getOption('directives', dirname) || directives[dirname]
194-
if (!dir) return utils.warn('unknown directive: ' + dirname)
194+
if (!dir) {
195+
utils.warn('unknown directive: ' + dirname)
196+
return
197+
}
195198

196199
var rawKey
197200
if (expression.indexOf('|') > -1) {
@@ -204,9 +207,11 @@ Directive.parse = function (dirname, expression, compiler, node) {
204207
}
205208

206209
// have a valid raw key, or be an empty directive
207-
return (rawKey || expression === '')
208-
? new Directive(dirname, dir, expression, rawKey, compiler, node)
209-
: utils.warn('invalid directive expression: ' + expression)
210+
if (rawKey || expression === '') {
211+
return new Directive(dirname, dir, expression, rawKey, compiler, node)
212+
} else {
213+
utils.warn('invalid directive expression: ' + expression)
214+
}
210215
}
211216

212217
module.exports = Directive

src/directives/on.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
var warn = require('../utils').warn
1+
var utils = require('../utils'),
2+
noBubble = ['blur', 'focus', 'load']
23

34
module.exports = {
45

@@ -7,15 +8,16 @@ module.exports = {
78
bind: function () {
89
// blur and focus events do not bubble
910
// so they can't be delegated
10-
this.bubbles = this.arg !== 'blur' && this.arg !== 'focus'
11+
this.bubbles = noBubble.indexOf(this.arg) === -1
1112
if (this.bubbles) {
1213
this.binding.compiler.addListener(this)
1314
}
1415
},
1516

1617
update: function (handler) {
1718
if (typeof handler !== 'function') {
18-
return warn('Directive "on" expects a function value.')
19+
utils.warn('Directive "on" expects a function value.')
20+
return
1921
}
2022
var targetVM = this.vm,
2123
ownerVM = this.binding.compiler.vm,

src/directives/partial.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ module.exports = {
1313
var partial = id === 'yield'
1414
? this.compiler.rawContent
1515
: this.compiler.getOption('partials', id)
16+
1617
if (!partial) {
17-
return utils.warn('Unknown partial: ' + id)
18+
utils.warn('Unknown partial: ' + id)
19+
return
1820
}
1921

2022
// comment ref node means inline partial

src/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ ViewModel.use = function (plugin) {
6363
try {
6464
plugin = require(plugin)
6565
} catch (e) {
66-
return utils.warn('Cannot find plugin: ' + plugin)
66+
utils.warn('Cannot find plugin: ' + plugin)
67+
return
6768
}
6869
}
6970

0 commit comments

Comments
 (0)