Re: [img-conversion] Convert to spec (#14)

>        </p>
>        <pre class='example highlight'>
> -function ImageDataToBlob(imageData)
> -{
> -        return imageData.toBlob();              // implied "image/png" format
> -};
> +var type = (Image.canEncodeType("image/jpg")) ? "image/jpg" : "image/png";
> +imageData.toBlob(type).then((blob) =&gt; {
> +  const img = new Image();
> +  img.src = URL.createObjectURL(blob);
> +  document.body.appendChild(img);

Appending children to the end of body from async funcs can be... not so great, since you're racing against other scripts adding things to the DOM.

---
Reply to this email directly or view it on GitHub:
https://github.com/WICG/img-conversion/pull/14/files#r40104529

Received on Tuesday, 22 September 2015 15:56:38 UTC