Skip to main content

Bug Tracker

Side navigation

#10077 closed bug (invalid)

Opened August 17, 2011 04:47PM UTC

Closed September 07, 2011 07:58AM UTC

Last modified October 24, 2011 03:32PM UTC

Ready doesn't work when multiple calls made after readState = complete

Reported by: rgavel@echo.com Owned by: rgavel@echo.com
Priority: undecided Milestone:
Component: event Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:
Description

I am using Internet Explorer 9 and have multiple included javascript files that contain there own $(function () { ... } calls. However, they are not getting called. In debugging into ready, I have found that at the time of invoking bindReady, document.readyState is "complete". From my reading of bindReady, in this case, the first run will invoke the internal ready function after 1 sec (by which time the external ready call will have added the callback function to readyList). However, a subsquent call to bindReady will consider itself bound and never schedule the internal ready function again.

Attachments (0)
Change History (6)

Changed August 17, 2011 05:05PM UTC by rwaldron comment:1

component: unfiledevent
milestone: None1.6.3
owner: → rgavel@echo.com
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/

Open the link and click to "Fork" (in the top menu) to get started.

Changed August 17, 2011 05:11PM UTC by rgavel@echo.com comment:2

status: pendingnew

FYI, I will try and use jsFiddle to provide test case. However, I did find a fix in moving the readyState check from bindReady to the ready after the callback function is added to the readyList.Done collection:

	ready: function( fn ) {
		// Attach the listeners
		jQuery.bindReady();

		// Add the callback
		readyList.done( fn );

		// Catch cases where $(document).ready() is called after the
		// browser event has already occurred.
		if (document.readyState === "complete") {
		    // Handle it asynchronously to allow scripts the opportunity to delay ready
		    return setTimeout(jQuery.ready, 1);
		}

		return this;
	},

Changed August 18, 2011 06:15AM UTC by addyosmani comment:3

status: newpending

Thanks for the proposed fix. Ideally, patches are best submitted in the form of pull-requests with tests attached so that the rest of the team can verify a) the patch is worth using and b) it doesn't have any negative side-effects upon existing functionality. If you could post a test case to jsFiddle shortly we can look into this further.

Changed August 23, 2011 03:53PM UTC by dmethvin comment:4

milestone: 1.6.3

We definitely need a test case for this. If you look at bindReady() it already has a check for readyState that should have handled this case.

Changed September 07, 2011 07:58AM UTC by trac-o-bot comment:5

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Changed October 24, 2011 03:32PM UTC by anonymous comment:6

Replying to [comment:4 dmethvin]:

We definitely need a test case for this. If you look at bindReady() it already has a check for readyState that should have handled this case.

I know I still need to provide a test case for this. Lost track because I hacked our local copy of jQuery.js to work. The issue with bindReady is this: The first call to ready (and therefore bindReady) will cause readyList to be instantiated. Any subsequent calls will short-circuit return from bindReady since the readyList is non-null.