[whatwg] Extend DataTransfer::getData/setData to handle Blobs

Daniel Cheng dcheng at google.com
Mon Jun 28 13:58:09 PDT 2010

It's pretty common for there to be non-text data in a drag-and-drop
operation or copy-and-paste operation. DataTransfer doesn't allow for that
currently, since it only sets and returns DOMStrings.

It'd be nice if we could extend setData/getData to allow for Blobs. Some
random thoughts:
1. Add a bool parameter to setData/getData. If false, treat the data as a
DOMString; if true, treat the data as a Blob.
2. Add an encoding parameter to setData/getData. Encoding can be a string
value naming a text encoding like UTF-8 or ISO-8859-1, or it can be the
string value "binary". If encoding names a text encoding, the UA will
transcode the requested data into/from a DOMString. Otherwise, if the
encoding value is "binary", the UA will treat data as a Blob.
3. Create new DataTransfer functions instead of overloading them, e.g.
setDataBlob, getDataBlob.

I'm not sure which one is the preferred approach. It seems like it'd be nice
to have native support for whatever text encodings the browser understands,
but it seems complicated and I'm not sure it's necessary. Thoughts?

Also, if I wanted to go ahead and implement a prototype in WebKit, should I
prefix it with a UA-specific string, e.g. webkitSetDataBlob?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100628/5beb0654/attachment-0001.htm>

More information about the whatwg mailing list