Skip to content

Commit f2e00f7

Browse files
committed
fix: special case for static muted attribute in firefox
fix #6887
1 parent 350f578 commit f2e00f7

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/compiler/parser/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,13 @@ function processAttrs (el) {
556556
}
557557
}
558558
addAttr(el, name, JSON.stringify(value))
559+
// #6887 firefox doesn't update muted state if set via attribute
560+
// even immediately after element creation
561+
if (!el.component &&
562+
platformMustUseProp(el.tag, el.attrsMap.type, name) &&
563+
name === 'muted') {
564+
addProp(el, name, 'true')
565+
}
559566
}
560567
}
561568
}

test/ssr/ssr-string.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,15 @@ describe('SSR: renderToString', () => {
10001000
done()
10011001
})
10021002
})
1003+
1004+
it('render muted properly', done => {
1005+
renderVmWithOptions({
1006+
template: '<video muted></video>'
1007+
}, result => {
1008+
expect(result).toContain('<video muted="muted" data-server-rendered="true"></video>')
1009+
done()
1010+
})
1011+
})
10031012
})
10041013

10051014
function renderVmWithOptions (options, cb) {

test/unit/modules/compiler/parser.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,15 @@ describe('parser', () => {
395395
expect(ast.props[0].value).toBe('msg')
396396
})
397397

398+
// #6887
399+
it('special case static attribute that must be props', () => {
400+
const ast = parse('<video muted></video>', baseOptions)
401+
expect(ast.attrs[0].name).toBe('muted')
402+
expect(ast.attrs[0].value).toBe('""')
403+
expect(ast.props[0].name).toBe('muted')
404+
expect(ast.props[0].value).toBe('true')
405+
})
406+
398407
it('attribute with v-on', () => {
399408
const ast = parse('<input type="text" name="field1" :value="msg" @input="onInput">', baseOptions)
400409
expect(ast.events.input.value).toBe('onInput')

0 commit comments

Comments
 (0)