Skip to content

Commit

Permalink
fix: special case for static muted attribute in firefox
Browse files Browse the repository at this point in the history
fix #6887
  • Loading branch information
yyx990803 committed Nov 2, 2017
1 parent 350f578 commit f2e00f7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/compiler/parser/index.js
Expand Up @@ -556,6 +556,13 @@ function processAttrs (el) {
}
}
addAttr(el, name, JSON.stringify(value))
// #6887 firefox doesn't update muted state if set via attribute
// even immediately after element creation
if (!el.component &&
platformMustUseProp(el.tag, el.attrsMap.type, name) &&
name === 'muted') {
addProp(el, name, 'true')
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions test/ssr/ssr-string.spec.js
Expand Up @@ -1000,6 +1000,15 @@ describe('SSR: renderToString', () => {
done()
})
})

it('render muted properly', done => {
renderVmWithOptions({
template: '<video muted></video>'
}, result => {
expect(result).toContain('<video muted="muted" data-server-rendered="true"></video>')
done()
})
})
})

function renderVmWithOptions (options, cb) {
Expand Down
9 changes: 9 additions & 0 deletions test/unit/modules/compiler/parser.spec.js
Expand Up @@ -395,6 +395,15 @@ describe('parser', () => {
expect(ast.props[0].value).toBe('msg')
})

// #6887
it('special case static attribute that must be props', () => {
const ast = parse('<video muted></video>', baseOptions)
expect(ast.attrs[0].name).toBe('muted')
expect(ast.attrs[0].value).toBe('""')
expect(ast.props[0].name).toBe('muted')
expect(ast.props[0].value).toBe('true')
})

it('attribute with v-on', () => {
const ast = parse('<input type="text" name="field1" :value="msg" @input="onInput">', baseOptions)
expect(ast.events.input.value).toBe('onInput')
Expand Down

0 comments on commit f2e00f7

Please sign in to comment.