Skip to content

Commit 7ef024f

Browse files
committed
👷‍♀️ build v3.0.4
1 parent 9d042b1 commit 7ef024f

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

dist/infinite-scroll.pkgd.js

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Infinite Scroll PACKAGED v3.0.3
2+
* Infinite Scroll PACKAGED v3.0.4
33
* Automatically add next page
44
*
55
* Licensed GPLv3 for open source use
@@ -321,7 +321,7 @@ return EvEmitter;
321321
}));
322322

323323
/**
324-
* Fizzy UI utils v2.0.5
324+
* Fizzy UI utils v2.0.7
325325
* MIT license
326326
*/
327327

@@ -376,23 +376,27 @@ utils.modulo = function( num, div ) {
376376

377377
// ----- makeArray ----- //
378378

379+
var arraySlice = Array.prototype.slice;
380+
379381
// turn element or nodeList into an array
380382
utils.makeArray = function( obj ) {
381-
var ary = [];
382383
if ( Array.isArray( obj ) ) {
383384
// use object if already an array
384-
ary = obj;
385-
} else if ( obj && typeof obj == 'object' &&
386-
typeof obj.length == 'number' ) {
385+
return obj;
386+
}
387+
// return empty array if undefined or null. #6
388+
if ( obj === null || obj === undefined ) {
389+
return [];
390+
}
391+
392+
var isArrayLike = typeof obj == 'object' && typeof obj.length == 'number';
393+
if ( isArrayLike ) {
387394
// convert nodeList to array
388-
for ( var i=0; i < obj.length; i++ ) {
389-
ary.push( obj[i] );
390-
}
391-
} else {
392-
// array of single index
393-
ary.push( obj );
395+
return arraySlice.call( obj );
394396
}
395-
return ary;
397+
398+
// array of single index
399+
return [ obj ];
396400
};
397401

398402
// ----- removeFrom ----- //
@@ -471,22 +475,21 @@ utils.filterFindElements = function( elems, selector ) {
471475
// ----- debounceMethod ----- //
472476

473477
utils.debounceMethod = function( _class, methodName, threshold ) {
478+
threshold = threshold || 100;
474479
// original method
475480
var method = _class.prototype[ methodName ];
476481
var timeoutName = methodName + 'Timeout';
477482

478483
_class.prototype[ methodName ] = function() {
479484
var timeout = this[ timeoutName ];
480-
if ( timeout ) {
481-
clearTimeout( timeout );
482-
}
483-
var args = arguments;
485+
clearTimeout( timeout );
484486

487+
var args = arguments;
485488
var _this = this;
486489
this[ timeoutName ] = setTimeout( function() {
487490
method.apply( _this, args );
488491
delete _this[ timeoutName ];
489-
}, threshold || 100 );
492+
}, threshold );
490493
};
491494
};
492495

@@ -650,8 +653,9 @@ proto.create = function() {
650653
this.pageIndex = 1; // default to first page
651654
this.loadCount = 0;
652655
this.updateGetPath();
653-
// bail if getPath not set
654-
if ( !this.getPath ) {
656+
// bail if getPath not set, or returns falsey #776
657+
var hasPath = this.getPath && this.getPath();
658+
if ( !hasPath ) {
655659
console.error('Disabling InfiniteScroll');
656660
return;
657661
}
@@ -798,7 +802,7 @@ proto.updateGetPathTemplate = function( optPath ) {
798802
var match = location.href.match( templateRe );
799803
if ( match ) {
800804
this.pageIndex = parseInt( match[1], 10 );
801-
this.log( 'pageIndex', this.pageIndex, 'template string' );
805+
this.log( 'pageIndex', [ this.pageIndex, 'template string' ] );
802806
}
803807
};
804808

@@ -1078,6 +1082,8 @@ function refreshScripts( fragment ) {
10781082
var script = scripts[i];
10791083
var freshScript = document.createElement('script');
10801084
copyAttributes( script, freshScript );
1085+
// copy inner script code. #718, #782
1086+
freshScript.innerHTML = script.innerHTML;
10811087
script.parentNode.replaceChild( freshScript, script );
10821088
}
10831089
}
@@ -1200,7 +1206,7 @@ proto.getPrefillDistance = function() {
12001206
};
12011207

12021208
proto.stopPrefill = function() {
1203-
console.log('stopping prefill');
1209+
this.log('stopPrefill');
12041210
this.off( 'append', this.prefill );
12051211
};
12061212

@@ -1462,6 +1468,10 @@ proto.destroyHistory = function() {
14621468
// ----- append history ----- //
14631469

14641470
proto.onAppendHistory = function( response, path, items ) {
1471+
// do not proceed if no items. #779
1472+
if ( !items || !items.length ) {
1473+
return;
1474+
}
14651475
var firstItem = items[0];
14661476
var elemScrollY = this.getElementScrollY( firstItem );
14671477
// resolve path
@@ -1538,7 +1548,7 @@ proto.setHistory = function( title, path ) {
15381548
};
15391549

15401550
// scroll to top to prevent initial scroll-reset after page refresh
1541-
// http://stackoverflow.com/a/18633915/182183
1551+
// https://stackoverflow.com/a/18633915/182183
15421552
proto.onUnload = function() {
15431553
var pageIndex = this.scrollPageIndex;
15441554
if ( pageIndex === 0 ) {
@@ -1768,7 +1778,7 @@ return InfiniteScroll;
17681778
}));
17691779

17701780
/*!
1771-
* Infinite Scroll v3.0.3
1781+
* Infinite Scroll v3.0.4
17721782
* Automatically add next page
17731783
*
17741784
* Licensed GPLv3 for open source use

0 commit comments

Comments
 (0)