Skip to content

Commit 4643216

Browse files
committed
Merge remote-tracking branch 'origin/gh-pages' into gh-pages
2 parents b15d27c + 55f936b commit 4643216

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

lazysizes-umd.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
(function(window, factory) {
2-
var lazySizes = factory(window, window.document);
2+
var lazySizes = factory(window, window.document, Date);
33
if(typeof module == 'object' && module.exports){
44
module.exports = lazySizes;
55
} else if (typeof define == 'function' && define.amd) {
66
define(lazySizes);
77
} else {
88
window.lazySizes = lazySizes;
99
}
10-
}(window, function l(window, document) {
10+
}(window, function l(window, document, Date) {
1111
'use strict';
1212
/*jshint eqnull:true */
1313

@@ -58,15 +58,13 @@
5858

5959
var docElem = document.documentElement;
6060

61-
var Date = window.Date;
62-
6361
var supportPicture = window.HTMLPictureElement;
6462

6563
var _addEventListener = 'addEventListener';
6664

6765
var _getAttribute = 'getAttribute';
6866

69-
var addEventListener = window[_addEventListener];
67+
var addEventListener = window[_addEventListener].bind(window);
7068

7169
var setTimeout = window.setTimeout;
7270

lazysizes.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
(function(window, factory) {
2-
var lazySizes = factory(window, window.document);
2+
var lazySizes = factory(window, window.document, Date);
33
window.lazySizes = lazySizes;
44
if(typeof module == 'object' && module.exports){
55
module.exports = lazySizes;
66
}
77
}(typeof window != 'undefined' ?
8-
window : {}, function l(window, document) {
8+
window : {}, function l(window, document, Date) {
99
'use strict';
1010
/*jshint eqnull:true */
1111

@@ -56,15 +56,13 @@
5656

5757
var docElem = document.documentElement;
5858

59-
var Date = window.Date;
60-
6159
var supportPicture = window.HTMLPictureElement;
6260

6361
var _addEventListener = 'addEventListener';
6462

6563
var _getAttribute = 'getAttribute';
6664

67-
var addEventListener = window[_addEventListener];
65+
var addEventListener = window[_addEventListener].bind(window);
6866

6967
var setTimeout = window.setTimeout;
7068

src/common.wrapper

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(function(window, factory) {
2-
var lazySizes = factory(window, window.document);
2+
var lazySizes = factory(window, window.document, Date);
33
window.lazySizes = lazySizes;
44
if(typeof module == 'object' && module.exports){
55
module.exports = lazySizes;

src/lazysizes-core.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function l(window, document) {
1+
function l(window, document, Date) { // Pass in the windoe Date function also for SSR because the Date class can be lost
22
'use strict';
33
/*jshint eqnull:true */
44

@@ -49,15 +49,17 @@ function l(window, document) {
4949

5050
var docElem = document.documentElement;
5151

52-
var Date = window.Date;
53-
5452
var supportPicture = window.HTMLPictureElement;
5553

5654
var _addEventListener = 'addEventListener';
5755

5856
var _getAttribute = 'getAttribute';
5957

60-
var addEventListener = window[_addEventListener];
58+
/**
59+
* Update to bind to window because 'this' becomes null during SSR
60+
* builds.
61+
*/
62+
var addEventListener = window[_addEventListener].bind(window);
6163

6264
var setTimeout = window.setTimeout;
6365

src/lazysizes-intersection.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
if(typeof module == 'object' && module.exports){
33
module.exports = lazySizes;
44
} else {
5-
window.lazySizes = factory(window, window.document);
5+
window.lazySizes = factory(window, window.document, Date);
66
}
7-
}(window, function l(window, document) {
7+
}(window, function l(window, document, Date) {
88
'use strict';
99

1010
/*jshint eqnull:true */
@@ -14,15 +14,13 @@
1414

1515
var docElem = document.documentElement;
1616

17-
var Date = window.Date;
18-
1917
var supportPicture = window.HTMLPictureElement;
2018

2119
var _addEventListener = 'addEventListener';
2220

2321
var _getAttribute = 'getAttribute';
2422

25-
var addEventListener = window[_addEventListener];
23+
var addEventListener = window[_addEventListener].bind(window);
2624

2725
var setTimeout = window.setTimeout;
2826

0 commit comments

Comments
 (0)