W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2011

[whatwg] DOMTokenList methods would be more useful with a space separated token list

From: Ojan Vafai <ojan@chromium.org>
Date: Fri, 28 Oct 2011 14:11:26 -0700
Message-ID: <CANMdWTuf3o9C7zaq5ppdii_i1jz1QZTr0Onqy2O5F-9rmY14ow@mail.gmail.com>
On Fri, Oct 28, 2011 at 2:03 PM, Glenn Maynard <glenn at zewt.org> wrote:

> On Fri, Oct 28, 2011 at 4:55 PM, Ojan Vafai <ojan at chromium.org> wrote:
>
>>  I agree in general. Changing add/remove is definitely worth doing. In
>> the
>> case of toggle, WebKit already returns a boolean. Returning the
>> DOMTokenList
>> is clearly preferable IMO. It's a new enough API that maybe the web
>> doesn't
>> yet depend on the return value of toggle?
>>
>
> The return value of toggle() seems more useful than chaining.
>
> if(foo.toggle("purple"))
>     alert("now purple");
> else
>     alert("no longer purple");
>
> This is preferable to me over the following, because the token ("purple")
> doesn't have to be duplicated:
>
> foo.toggle("purple");
> if(foo.has("purple"))
>     ...
>

The counterargument is that it's possibly more confusing to have some of
these methods allow chaining and some return a boolean. It's not clear to me
which is better in this case. I don't feel strongly about it either way.
Leaving toggle alone would have the benefit of avoiding any web compat
concerns.
Received on Friday, 28 October 2011 14:11:26 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:37 UTC