bbc / Imager.js

Responsive images while we wait for srcset to finish cooking
Apache License 2.0
3.84k stars 224 forks source link

JS error: Cannot call method 'replaceChild' of null --- Upon Scroll only #82

Closed hi-im-si closed 9 years ago

hi-im-si commented 10 years ago

After implementing imager, a JS error is logged upon scroll. I have implemented imager with lazyload only.

the error i receive is as follows:

Uncaught TypeError: Cannot call method 'replaceChild' of null imager.js:193
Imager.createGif imager.js:193
(anonymous function) imager.js:204
applyEach imager.js:20
Imager.changeDivsToEmptyImages imager.js:201
Imager.scrollCheck imager.js:163
(anonymous function) imager.js:353

Can anyone shed any light on what could be causing this issue. Thanks.

thom4parisot commented 10 years ago

This is located here: https://github.com/BBC-News/Imager.js/blob/f0626740a65e6380f9d9f1dccdf673bae9d81264/Imager.js#L193

For some reason the parentNode is null. If you inspect the value of element it might give us a hint when it comes to this behaviour.

thom4parisot commented 10 years ago

@hi-im-si did you have time to look at my answer? Has it solved your issue?

thom4parisot commented 9 years ago

In 0.3.1 (released later today), Imager will handle scrollCheck in a nicer way so let us know if you still encounter the problem.

addyosmani commented 9 years ago

:+1: