This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 25007 - [imports]: Want New LinkImport method to return a promise.
Summary: [imports]: Want New LinkImport method to return a promise.
Status: RESOLVED MOVED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 23278
  Show dependency treegraph
 
Reported: 2014-03-11 17:23 UTC by Morrita Hajime
Modified: 2015-07-06 08:03 UTC (History)
4 users (show)

See Also:


Attachments

Description Morrita Hajime 2014-03-11 17:23:31 UTC
There should be a way to wait an import being loaded using Promise.
This might be better to be a part of HTML standard, but it's fine to start from here.
Comment 1 Jake Archibald 2014-03-14 10:17:06 UTC
Some details from the discussion at http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2014-March/042201.html

* This should be .loaded(), "ready" will be used for non-load events, such as document.ready()
* This should reject with InvalidStateError if href isn't set

Should promise-vending functions without arguments take onFulfilled & onRejected callbacks?

Eg, it's currently:

var promise = link.loaded().then(onFulfilled, onRejected);

Should we allow:

var promise = link.loaded(onFulfilled, onRejected);
Comment 2 Domenic Denicola 2014-03-14 14:35:01 UTC
> Should promise-vending functions without arguments take onFulfilled & onRejected callbacks?

I don't like this. It's a needless inconsistency in the platform that sometimes you'll be interfacing with promise objects through the normal interface and sometimes you'll be bypassing that.
Comment 3 Dimitri Glazkov 2014-04-30 19:16:54 UTC
Maybe replace .import with this?
Comment 4 Jake Archibald 2014-05-01 08:00:22 UTC
I'm hoping we can get .loaded() on other link types (CSS, rel=preload), see http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2014-March/042201.html

Not against .import() vending a promise though, especially if a general .loaded() method meets resistance or apathy.
Comment 5 Jake Archibald 2014-05-20 10:22:19 UTC
In http://dev.w3.org/csswg/css-font-loading/#dom-fontface-loaded .loaded is a property, not a method.

link.loaded should be a property for consistency.
Comment 6 Hayato Ito 2015-07-06 08:03:20 UTC
Moved to https://github.com/w3c/webcomponents/issues/212