mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-05 05:27:59 +08:00
* refactor: add empty v-bind warnings re #7973 * Update index.js
This commit is contained in:
parent
db7287c23b
commit
1b69cbde74
@ -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
|
||||
|
@ -510,6 +510,11 @@ describe('parser', () => {
|
||||
expect(ast.props[0].value).toBe('msg')
|
||||
})
|
||||
|
||||
it('empty v-bind expression', () => {
|
||||
parse('<div :empty-msg=""></div>', 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('<video muted></video>', baseOptions)
|
||||
|
Loading…
Reference in New Issue
Block a user