When using DOMParser
, <video>
tag is not working in Safari, its preview is rendered but without controls and without the ability to play:
const parser = new DOMParser()
const parsed = parser.parseFromString(
document.querySelector('video').outerHTML,
'text/html'
)
document.body.appendChild(parsed.querySelector('body').childNodes[0])
<video
width="250"
controls
playsinline
src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.mp4#t=0.001"
></video>
The code above works as expected in Chrome:
But Safari renders this (both macOS and iOS):
There are no controls and it's impossible to play the second video which was produced by DOMParser.
Is that some kind of security feature or a bug? Is there any workaround for this behavior?