Skip to content

Commit fe27197

Browse files
committed
better warning messages
1 parent e15cfe2 commit fe27197

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

src/compiler.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,11 @@ CompilerProto.compile = function (node, root) {
370370
*/
371371
CompilerProto.checkPriorityDir = function (dirname, node, root) {
372372
var expression, directive, Ctor
373-
if (dirname === 'component' && root !== true && (Ctor = this.resolveComponent(node, undefined, true))) {
373+
if (
374+
dirname === 'component' &&
375+
root !== true &&
376+
(Ctor = this.resolveComponent(node, undefined, true))
377+
) {
374378
directive = Directive.parse(dirname, '', this, node)
375379
directive.Ctor = Ctor
376380
} else {
@@ -379,7 +383,10 @@ CompilerProto.checkPriorityDir = function (dirname, node, root) {
379383
}
380384
if (directive) {
381385
if (root === true) {
382-
utils.warn('Directive v-' + dirname + ' cannot be used on manually instantiated root node.')
386+
utils.warn(
387+
'Directive v-' + dirname + ' cannot be used on an already instantiated ' +
388+
'VM\'s root node. Use it from the parent\'s template instead.'
389+
)
383390
return
384391
}
385392
this.deferred.push(directive)

src/directive.js

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

192192
var dir = compiler.getOption('directives', dirname) || directives[dirname]
193193
if (!dir) {
194-
utils.warn('unknown directive: ' + dirname)
194+
utils.warn('Unknown directive: ' + dirname)
195195
return
196196
}
197197

@@ -209,7 +209,7 @@ Directive.parse = function (dirname, expression, compiler, node) {
209209
if (rawKey || expression === '') {
210210
return new Directive(dirname, dir, expression, rawKey, compiler, node)
211211
} else {
212-
utils.warn('invalid directive expression: ' + expression)
212+
utils.warn('Invalid directive expression: ' + expression)
213213
}
214214
}
215215

src/directives/if.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ module.exports = {
1313
this.parent.removeChild(this.el)
1414

1515
if (utils.attr(this.el, 'view')) {
16-
utils.warn('Conflict: v-if cannot be used together with v-view')
16+
utils.warn(
17+
'Conflict: v-if cannot be used together with v-view. ' +
18+
'Just set v-view\'s binding value to empty string to empty it.'
19+
)
1720
}
1821
if (utils.attr(this.el, 'repeat')) {
19-
utils.warn('Conflict: v-if cannot be used together with v-repeat')
22+
utils.warn(
23+
'Conflict: v-if cannot be used together with v-repeat. ' +
24+
'Use `v-show` or the `filterBy` filter instead.'
25+
)
2026
}
2127
},
2228

src/directives/on.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports = {
1212

1313
update: function (handler) {
1414
if (typeof handler !== 'function') {
15-
utils.warn('Directive "on" expects a function value.')
15+
utils.warn('Directive "v-on:' + this.expression + '" expects a method.')
1616
return
1717
}
1818
this._unbind()

0 commit comments

Comments
 (0)