W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2014

Re: [whatwg] Promise-vending loaded() & ready() methods on various elements

From: Jake Archibald <jaffathecake@gmail.com>
Date: Wed, 12 Mar 2014 13:32:37 +0000
Message-ID: <CAJ5xic8BHEKXf5iyVS-D56SwOXWSFFzv-8Tm44hPjwf7JiOBTg@mail.gmail.com>
To: Boris Zbarsky <bzbarsky@mit.edu>
Cc: "whatwg@lists.whatwg.org" <whatwg@lists.whatwg.org>
On 12 March 2014 13:15, Boris Zbarsky <bzbarsky@mit.edu> wrote:

> On 3/12/14 7:23 AM, Jake Archibald wrote:
>
>> == img/link/script/document/iframe .loaded() ==
>>
>> If the element hasn't loaded or is loading, vend a promise that
>> resolves/rejects on its load/error event.
>> If the element has fired load/error and isn't loading due to a source
>> change, vend a resolved/rejected promise.
>>
>
> This seems fundamentally racy, no?  In particular, the fact that a new
> load can start (and maybe finish?) between the loaded() call and the time
> when the promise notifies its consumers is a bit worrying.


You're right, I was short on detail for that case.

img.src = foo;
var promise1 = img.loaded();
img.src = bar;

I expect promise1 to reject with an AbortError.
Received on Wednesday, 12 March 2014 13:33:01 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:17 UTC