fix lazy load selector error
This commit is contained in:
parent
e67dc9251a
commit
207b0c71ed
@ -2723,7 +2723,7 @@
|
|||||||
slide.style.display = 'block';
|
slide.style.display = 'block';
|
||||||
|
|
||||||
// Media elements with data-src attributes
|
// 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.setAttribute( 'src', element.getAttribute( 'data-src' ) );
|
||||||
element.removeAttribute( 'data-src' );
|
element.removeAttribute( 'data-src' );
|
||||||
} );
|
} );
|
||||||
|
@ -22,6 +22,8 @@
|
|||||||
<section data-background-image="examples/assets/image1.png">
|
<section data-background-image="examples/assets/image1.png">
|
||||||
<h1>1</h1>
|
<h1>1</h1>
|
||||||
<img data-src="fake-url.png">
|
<img data-src="fake-url.png">
|
||||||
|
<video data-src="fake-url.mp4"></video>
|
||||||
|
<audio data-src="fake-url.mp3"></audio>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -495,6 +495,14 @@ Reveal.addEventListener( 'ready', function() {
|
|||||||
strictEqual( document.querySelectorAll( '.reveal section img[src]' ).length, 1, 'Image source has been set' );
|
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() {
|
test( 'iframe with data-src', function() {
|
||||||
Reveal.slide( 0, 0 );
|
Reveal.slide( 0, 0 );
|
||||||
strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 0, 'Iframe source is not set' );
|
strictEqual( document.querySelectorAll( '.reveal section iframe[src]' ).length, 0, 'Iframe source is not set' );
|
||||||
|
Loading…
Reference in New Issue
Block a user