From 207b0c71ede4a37ec06797802c22e7c5d61346f6 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Wed, 6 May 2015 11:25:50 +0200 Subject: [PATCH] fix lazy load selector error --- js/reveal.js | 2 +- test/test.html | 2 ++ test/test.js | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/js/reveal.js b/js/reveal.js index 3bd292a..ecba3a9 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 93de5b1..34cf832 100644 --- a/test/test.html +++ b/test/test.html @@ -22,6 +22,8 @@

1

+ +
diff --git a/test/test.js b/test/test.js index ff32ee8..79ff81e 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' );