javascript - Should a video that is not attached to the DOM autoplay? -


here 3 scenarios:

  1. document.adoptnode,
  2. document.importnode ,
  3. document.createelement+assign props.

in each case video autoplays though it's not attached dom. inconsistent behavior of <script> element wouldn't eval/download until it's attached dom.

should video autoplay?

https://gist.run/?id=cb657718c3b6b34c043b34f3356d5a84

<!doctype html> <html lang="en"> <head>   <meta charset="utf-8">   <title>gistrun</title> </head> <body>   <template>     <video src="http://video.webmfiles.org/big-buck-bunny_trailer.webm"            loop controls autoplay>     </video>   </template>   <script>     let template = document.queryselector('template');      // scenario 1: (causes autoplay)     document.adoptnode(template.content);      // scenario 2: (causes autoplay) //    document.importnode(template.content, true);      // scenario 3: (causes autoplay) //    let video = document.createelement('video'); //    video.autoplay = 'autoplay'; //    video.controls = 'controls'; //    video.loop = 'loop'; //    video.src = 'http://video.webmfiles.org/big-buck-bunny_trailer.webm';   </script> </body> </html> 

it's copy vs cut difference.

in adoptnode you're cutting out interpreted, if will, whereas in importnode you're copying node (i.e. producing description of other thing), , using description implement on dom itself.

so correct behavior? both are; 1 cut, other copy. autoplay can happen thing, rather description of thing. whatever operation has furnished description (rather thing), operation not 1 autoplay applies.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo