Re: [webidl] Stringifiers should allow optional arguments

On 7/11/14, 4:44 AM, Anne van Kesteren wrote:
> On Wed, Jul 9, 2014 at 6:25 PM, Boris Zbarsky <bzbarsky@mit.edu> wrote:
>> With "serializer = { attribute };" (possibly with simpler syntax!) you
>> automatically get a toJSON with the behavior everyone would typically expect
>> toJSON to have here.  There's value in having that shortcut so spec authors
>> do not have to reinvent that wheel in prose.
>
> That applies equally to toString(). See e.g. URLUtils.

In cases when you do "stringifier attribute", sure.  It saves you the 
trouble of having:

   attribute DOMString foo;
   DOMString toString();

and prose that says that invoking toString() does the same thing as the 
foo getter.  Which is not very much trouble, imo, compared to what a 
typical toJSON prose description would need to do.

-Boris

Received on Friday, 11 July 2014 14:53:18 UTC