diff --git a/js/reveal.js b/js/reveal.js index 3bd292a5971cbe94fa6440b570bf5f64a4dc778e..ecba3a96f0c2e0fdd10bd5ff8aae21625fb13756 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -2723,7 +2723,7 @@ slide.style.display = 'block'; // Media elements with data-src attributes - toArray( slide.querySelectorAll( 'img[data-src]', 'video[data-src]', 'audio[data-src]' ) ).forEach( function( element ) { + toArray( slide.querySelectorAll( 'img[data-src], video[data-src], audio[data-src]' ) ).forEach( function( element ) { element.setAttribute( 'src', element.getAttribute( 'data-src' ) ); element.removeAttribute( 'data-src' ); } ); diff --git a/test/test.html b/test/test.html index 93de5b12f0ed64178c7e6118aae3ce06ec9868f3..34cf8328b8e4d159b66207b4c0779cd6a8f8dbcf 100644 --- a/test/test.html +++ b/test/test.html @@ -22,6 +22,8 @@ <section data-background-image="examples/assets/image1.png"> <h1>1</h1> <img data-src="fake-url.png"> + <video data-src="fake-url.mp4"></video> + <audio data-src="fake-url.mp3"></audio> </section> <section> diff --git a/test/test.js b/test/test.js index ff32ee86f3d99b7b8d5d3f96aa925f4de475a075..79ff81ef9504e99316340fe139fbc4b7cd17bc7f 100644 --- a/test/test.js +++ b/test/test.js @@ -495,6 +495,14 @@ Reveal.addEventListener( 'ready', function() { strictEqual( document.querySelectorAll( '.reveal section img[src]' ).length, 1, 'Image source has been set' ); }); + test( 'video with data-src', function() { + strictEqual( document.querySelectorAll( '.reveal section video[src]' ).length, 1, 'Video source has been set' ); + }); + + test( 'audio with data-src', function() { + strictEqual( document.querySelectorAll( '.reveal section audio[src]' ).length, 1, 'Audio source has been set' ); + }); + test( 'iframe with data-src', function() { Reveal.slide( 0, 0 ); strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 0, 'Iframe source is not set' );