- const title = escapeHTML(embedTitle)
-
- return '<iframe width="560" height="315" ' +
- 'sandbox="allow-same-origin allow-scripts allow-popups" ' +
- 'title="' + title + '" ' +
- 'src="' + embedUrl + '" ' +
- 'frameborder="0" allowfullscreen>' +
- '</iframe>'
+ const iframe = document.createElement('iframe')
+
+ iframe.title = embedTitle
+ iframe.width = '560'
+ iframe.height = '315'
+ iframe.src = embedUrl
+ iframe.frameBorder = '0'
+ iframe.allowFullscreen = true
+ iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups')
+
+ return iframe.outerHTML