whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
7.99k stars 2.61k forks source link

Promise version of toBlob? #2608

Open saschanaz opened 7 years ago

saschanaz commented 7 years ago

Previously #379 discussed about this but is closed because of Chrome implementation.

I think an overload to return Promise is still doable, what do you think?

void toBlob(FileCallback? _callback, optional DOMString type, any... arguments);
Promise<Blob> toBlob(optional DOMString type, any... arguments);
domenic commented 7 years ago

Yeah, it's a good idea, it just needs implementer interest. @junov? @grorg? Not sure about who from Mozilla/Microsoft works on canvas stuff.

annevk commented 7 years ago

I'm told @nical or @mstange can help decide for Mozilla.

(Instead of overloading, should we go with blob() just as Response does?)

junov commented 7 years ago

This was discussed before. For OffscreenCanvas, because this is a new interface, we did not have to worry about backwards compat, so we did a complete reboot of toBlob. We made it promise-based, and we replaced the "any... arguments" with a dictionary. To avoid confusion with the existing toBlob, it got named convertToBlob. The idea was to use OffscreenCanvas as a proving ground for convertToBlob, and copy-paste it to HTMLCanvasElement once there is proven demand.

mstange commented 7 years ago

The idea was to use OffscreenCanvas as a proving ground for convertToBlob, and copy-paste it to HTMLCanvasElement once there is proven demand.

This sounds good to me.