diff --git a/src/compiler/parser/index.js b/src/compiler/parser/index.js index a603b36bb55..c62358909de 100644 --- a/src/compiler/parser/index.js +++ b/src/compiler/parser/index.js @@ -528,6 +528,14 @@ function processAttrs (el) { name = name.replace(bindRE, '') value = parseFilters(value) isProp = false + if ( + process.env.NODE_ENV !== 'production' && + value.trim().length === 0 + ) { + warn( + `The value for a v-bind expression cannot be empty. Found in "v-bind:${name}"` + ) + } if (modifiers) { if (modifiers.prop) { isProp = true diff --git a/test/unit/modules/compiler/parser.spec.js b/test/unit/modules/compiler/parser.spec.js index 750e371105f..5e701bba5d3 100644 --- a/test/unit/modules/compiler/parser.spec.js +++ b/test/unit/modules/compiler/parser.spec.js @@ -510,6 +510,11 @@ describe('parser', () => { expect(ast.props[0].value).toBe('msg') }) + it('empty v-bind expression', () => { + parse('
', baseOptions) + expect('The value for a v-bind expression cannot be empty. Found in "empty-msg"').toHaveBeenWarned() + }) + // #6887 it('special case static attribute that must be props', () => { const ast = parse('', baseOptions)