IE8 Crash – Inline-Block Scroll with DOM Append

02Mar

Was struggling for many hours today to figure out what has turned out to be a really stupid bug in IE8. In the hopes I can prevent even a single person from wasting their day like I have trying to figure out what is wrong with my code, I’ll explain below how the bug presents itself with examples.

I’m not 100% certain of every variable required to cause the bug, but it definitely works in this example:IE8 crash

In that example <body> has only the one direct child element and if you scroll it causing the appendTo() function to be called, IE8 crashes. (I’ve only tested this on Windows 7 machines. IE7 does not crash.)

This is the same example, but it works. The only difference is that a second <div> child was included within <body> but with that one change, the bug vanishes. Note that I’ve also tested this with multiple scrolling divs in body and the bug persists. It seems there must be at least one block element in <body> to prevent the bug.

Fortunately, it’s not often that one would create a page with just scrollable divs in the body.