tubalmartin / riloadr

Riloadr - A cross-browser framework-independent responsive images loader written in Javascript.
MIT License
646 stars 41 forks source link

IE8 falls into infinit loop in getViewportWidthInCssPixels() #23

Closed tokkonopapa closed 10 years ago

tokkonopapa commented 10 years ago

In IE8, the variable widths looks like [null, 600, 800, 600] and will be [600, 800, 600] by widths.splice(i, 1);. But the variable l is still 4. So i will refer to the out of range.

The below code can fix this issue.

function getViewportWidthInCssPixels() {
...
    for (; i < l; i++) {
        // If not a number remove it
        if (isNaN(widths[i])) {
            widths.splice(i, 1);
            i--;
            l--; // need decrement
        }
    }
...
}
tubalmartin commented 10 years ago

Thank you for spotting that bug. It's already fixed in 1.5.3. Could you give it a try?

tokkonopapa commented 10 years ago

I tested 1.5.3 using IE8 and found everything is fine! Thanks for quick update!!