W3C home > Mailing lists > Public > www-style@w3.org > June 2014

[css-font-loading] replacing [[ReadyPromise]]

From: Cameron McCormack <cam@mcc.id.au>
Date: Mon, 30 Jun 2014 12:07:31 +1000
Message-ID: <53B0C663.4040708@mcc.id.au>
To: "www-style@w3.org" <www-style@w3.org>
The spec says, when a font in the FontFaceSet begins loading, to replace 
[[ReadyPromise]] with a freshly created pending Promise object if 
[[ReadyPromise]] is already fulfilled.

First, I notice  that it says "fulfilled" rather than "settled". 
Although the spec never rejects [[ReadyPromise]], script could.  Is it 
worth making document.fonts.ready resilient to that?

Second, detecting if [[ReadyPromise]] holds a fulfilled promise is not 
really something you can do with the Promise API.  Well, you could do 
this (maybe?):

   var fulfilled = false;
   readyPromise.then(function() { fulfilled = true; });
   setTimeout(function() {
     if (fulfilled) {
       readyPromise = new Promise(...);
     }
   }, 0);

but I'm not really sure if this is an idiomatic use of Promises.
Received on Monday, 30 June 2014 02:06:01 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:41 UTC