|
1 | 1 | /*!
|
2 |
| - * Infinite Scroll PACKAGED v4.0.0 |
| 2 | + * Infinite Scroll PACKAGED v4.0.1 |
3 | 3 | * Automatically add next page
|
4 | 4 | *
|
5 | 5 | * Licensed GPLv3 for open source use
|
@@ -844,26 +844,30 @@ proto.loadNextPage = function() {
|
844 | 844 | this.isLoading = true;
|
845 | 845 | if ( typeof fetchOptions == 'function' ) fetchOptions = fetchOptions();
|
846 | 846 |
|
847 |
| - let fetchPromise = fetch( path, fetchOptions ).then( ( response ) => { |
848 |
| - if ( !response.ok ) { |
849 |
| - let error = new Error( response.statusText ); |
850 |
| - this.onPageError( error, path, response ); |
851 |
| - return { response }; |
852 |
| - } |
853 |
| - |
854 |
| - return response[ responseBody ]().then( ( body ) => { |
855 |
| - let canDomParse = responseBody == 'text' && domParseResponse; |
856 |
| - if ( canDomParse ) { |
857 |
| - body = domParser.parseFromString( body, 'text/html' ); |
858 |
| - } |
859 |
| - if ( response.status == 204 ) { |
860 |
| - this.lastPageReached( body, path ); |
861 |
| - return { body, response }; |
862 |
| - } else { |
863 |
| - return this.onPageLoad( body, path, response ); |
| 847 | + let fetchPromise = fetch( path, fetchOptions ) |
| 848 | + .then( ( response ) => { |
| 849 | + if ( !response.ok ) { |
| 850 | + let error = new Error( response.statusText ); |
| 851 | + this.onPageError( error, path, response ); |
| 852 | + return { response }; |
864 | 853 | }
|
| 854 | + |
| 855 | + return response[ responseBody ]().then( ( body ) => { |
| 856 | + let canDomParse = responseBody == 'text' && domParseResponse; |
| 857 | + if ( canDomParse ) { |
| 858 | + body = domParser.parseFromString( body, 'text/html' ); |
| 859 | + } |
| 860 | + if ( response.status == 204 ) { |
| 861 | + this.lastPageReached( body, path ); |
| 862 | + return { body, response }; |
| 863 | + } else { |
| 864 | + return this.onPageLoad( body, path, response ); |
| 865 | + } |
| 866 | + } ); |
| 867 | + } ) |
| 868 | + .catch( ( error ) => { |
| 869 | + this.onPageError( error, path ); |
865 | 870 | } );
|
866 |
| - } ); |
867 | 871 |
|
868 | 872 | this.dispatchEvent( 'request', null, [ path, fetchPromise ] );
|
869 | 873 |
|
|
0 commit comments