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

Glenn Maynard glenn at zewt.org
Fri Oct 28 14:03:53 PDT 2011


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"))
    ...

-- 
Glenn Maynard



More information about the whatwg mailing list