[jQuery] Dom ready premature execution in IE
Hi, all!
I've found a case of $(document).ready(fn) prematurely calling fn in IE(6 and 7).
It seems that the issue will occur when innerHTML modification is performed before the document finish loading.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">
<html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery domReady premature execution</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function() {
alert($('#div2').size()); //expected to alert 1
});
</script>
</head>
<body>
<div id="div1">div1</div>
<script type="text/javascript">
var d = document.getElementById('div1');
d.innerHTML = d.innerHTML; //innerHTML modification before page loads
</script>
<div id="div2">div2</div>
</body>
</html>
<br clear="all">Run the page in IE, refresh and again. It will alert 0 in most times. Firefox and Opera don't have this problem. Safari is not tested yet.
I'll submit it as a ticket after more testing.
--
Arrix
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/