Originally posted by Ardesco
View Post
However, before they are in view, use of MS's DOM inspector reveals that the browser thinks they are somewhere up by the top left of the window (not the page, but the actual top left of the window, as if they had "position: fixed;" set), although it's unable to render their actual content there, and they don't appear in any z-index related stacking order.
The fix is to also toggle a garbage className on the parent element of the things it's having trouble re-rendering. This forces it to do a reflow on that element before attempting to reflow the outermost container, which allows it to get its internal data structures (the ones below the level of the DOM structures exposed to the outside via COM) into a coherent state, with the result that everything works properly again. This also has the virtue of having no unpleasant side effects on other browsers (assuming the garbage className isn't one referenced in any CSS, of course - something like "sodding-ie-reflow-trigger" does nicely ).
Interestingly, it's the second time I've come across virtually the same bug in IE 7 in the last two weeks, although the last one wasn't a crasher; this is why I need to work on producing a minimal test case to allow me to determine the precise trigger(s) before publishing my findings.
Once I realised that I needed to force the rendering engine to do an unnecessary reflow, I thought of the dummy className technique. Then, today, I found that it also worked to fix a problem IE 6 was having with something different, so it's a potentially useful technique in a number of situations.
And, because all browsers have a similar need to do a reflow when dynamic stuff happens, it's quite possible that it might be useful for dealing with odd layout problems in other ones - after all, none of them are perfect
Leave a comment: