[whatwg] document.readyState and its initial value

Dan Fabulich dan at fabulich.com
Sun Jun 22 19:17:14 PDT 2008


Ian Hickson wrote:

> On Sun, 22 Jun 2008, Dan Fabulich wrote:
>>
>> The point is small and not very important because it's almost impossible
>> to encounter an HTML document in Internet Explorer in the
>> "uninitialized" state. But I think the fix is small and uncontroversial:
>
> Actually the testability is the most important aspect. Could you provide
> some tests that show when IE switches from "uninitialised" to "loading"
> and so on? At the moment the spec is as close as I could get to what IE
> actually does. (MSDN is woefully inaccurate when it comes to these things,
> so I wouldn't pay too much attention to it.)

As far as I know I can't exhibit a test demonstrating IE switching from 
"uninitialized" to "loading."  The document is normally in the "loading" 
state before you get your hands on it.  If testability is the top priority 
then the spec probably shouldn't change.

There is a way to get a document in the "uninitialized" state using 
document.createDocumentFragment().  IE erroneously creates a document in 
that case instead of a document fragment; the document has readyState 
"uninitialized".  However, there is no way to take that document and get 
it into a "loading" state as far as I know (obvious methods like .open() 
just throw errors instead).

Furthermore, MSDN *does* claim that "the states through which an object 
passes are determined by that object; an object can skip certain states 
(for example, interactive) if the state does not apply to that object."

So, the current state of the spec is certainly defensible.

However, I note that it would be legal under the terms of the MSDN 
specification if some future version of IE *did* expose a way to make an 
uninitialized document on which you could later call .open(), and the 
HTML5 spec as-is would make that illegal.

It's tempting to say that the readyState can start with either 
"uninitialized" or "loading"; certainly it's odd that we'd just hike it up 
to "loading" because our test mechanisms are usually too coarse-grained to 
detect a readyState in its "uninitialized" state.

But, oddity is par for the course in DOM, so I guess we'll just follow the 
HTML 5 spec as-is, initialize readyState to "loading" in the object 
constructor, and keep our fingers crossed.

-Dan



More information about the whatwg mailing list