Re: [FileAPI] createObjectURL isReusable proposal

2012/1/30 Bronislav Klučka <Bronislav.Klucka@bauglir.com>

> And how? Using src attribute? that would have to be changed to accept both
> string and Blob object? What it would return on get operation? Libraries
> managing images (lightboxes) would have to consider, what does src mean? Or
> do you propose other attribute? What would then be in src?


img1 = document.getElementById("my-image");
img1.src = myBlob;
assert(img1.src == myBlob);
img2 = document.getElementById("my-other-image");
img2.src = img1.src; // works as always; you can't do this with
auto-releasing object URLs

This is trivially simple for users to understand, and doesn't raise any of
the hard issues that auto-releasing object URLs do.

The main question is innerHTML/outerHTML, where the object can't be
represented; it would need to be exposed as a placeholder string.
 (However, auto-release object URLs break many uses of these too, since the
URL is no longer valid!)  It means you can't use this with most approaches
to HTML templating in JS, which is annoying.  That said, there have been
various suggestions for augmenting HTML-like templating, and it could be
made possible, eg.:

document.createTemplatedElement("<img width=${width} height=${height}
src=${myImage}>", {myImage: myBlob, width: 800, height: 600});

What if I change that blob? Should image change immediately as well? What
> if this was video playing?
>

You can't change a blob.

-- 
Glenn Maynard

Received on Monday, 30 January 2012 15:14:42 UTC