Explorar o código

Use offsetWidth instead of clientWidth.

NaotoshiFujita %!s(int64=5) %!d(string=hai) anos
pai
achega
85e50d7b67
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      tests/functionality/autowidth.test.js

+ 2 - 1
tests/functionality/autowidth.test.js

@@ -12,6 +12,7 @@ describe( 'When the autoWidth option is true, ', () => {
 
 
 		Object.defineProperty( splide.root.querySelector( '.splide__track' ), 'clientWidth', { value: 800 } );
 		Object.defineProperty( splide.root.querySelector( '.splide__track' ), 'clientWidth', { value: 800 } );
 		splide.root.querySelectorAll( '.splide__slide' ).forEach( slide => {
 		splide.root.querySelectorAll( '.splide__slide' ).forEach( slide => {
+			Object.defineProperty( slide, 'offsetWidth', { value: parseInt( slide.style.width ) } );
 			Object.defineProperty( slide, 'clientWidth', { value: parseInt( slide.style.width ) } );
 			Object.defineProperty( slide, 'clientWidth', { value: parseInt( slide.style.width ) } );
 		} );
 		} );
 
 
@@ -21,7 +22,7 @@ describe( 'When the autoWidth option is true, ', () => {
 	test( 'Splide should move slides according to their width.', done => {
 	test( 'Splide should move slides according to their width.', done => {
 		splide.on( 'moved', () => {
 		splide.on( 'moved', () => {
 			const slide = splide.Components.Elements.slides[0];
 			const slide = splide.Components.Elements.slides[0];
-			expect( Math.abs( splide.Components.Track.position ) ).toBe( slide.clientWidth );
+			expect( Math.abs( splide.Components.Track.position ) ).toBe( slide.offsetWidth );
 			done();
 			done();
 		} );
 		} );