html-parser icon indicating copy to clipboard operation
html-parser copied to clipboard

Set video "muted" attribute as property in Parser.Util.toVirtualDom

Open meowgorithm opened this issue 5 years ago • 0 comments

This is a small change to allow parsed <video> elements to play in Chrome with the bundled toVirtualDom utility.

Chrome needs to set the muted attribute on <video> elements as a property in order for autoplay to work (See this thread on Elm Discourse). Note that this is only a Chrome requirement; videos will autoplay in Firefox and Safari with the current implementation.

So in short, this PR will allow the following to autoplay with Utils.toVirtualDom:

<video autoplay muted loop>
    <source src="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" type="video/mp4">
</video>

I was careful to apply this change only to video elements. I know the code looks a bit funky; totally open if you prefer a different style of implementation.

meowgorithm avatar Sep 15 '20 00:09 meowgorithm