[whatwg] toDataURL() and unsupported formats

Anne van Kesteren fora at annevankesteren.nl
Sun May 21 05:24:02 PDT 2006

Quoting Ian Hickson <ian at hixie.ch>:
>> http://whatwg.org/specs/web-apps/current-work/#todataurl0 defines that
>> for unsupported values UAs must return PNG. How about returning null
>> instead for unsupported types? Where there any reasons to go with
>> something else?
> If you want a data: URL, you primarily want a data: URL. The type is
> secondary. Thus getting null is never useful.

If you want data: URL of a specific type, you primarily want a data:  
URL of a specific type. (Otherwise you would just do toDataURL()  
without mentioning the type at all and get a nice PNG back.) Doing  
string checks to see if that succeeded is more error prone than just  
doing `if(c.toDataURL(test))` or a try/catch(e) statement.

Anne van Kesteren

More information about the whatwg mailing list