- From: Ojan Vafai <ojan@chromium.org>
- Date: Fri, 28 Oct 2011 13:55:34 -0700
On Fri, Oct 28, 2011 at 1:23 PM, Jonas Sicking <jonas at sicking.cc> wrote: > On Fri, Oct 28, 2011 at 9:42 AM, Aryeh Gregor <ayg at aryeh.name> wrote: > > On Fri, Oct 28, 2011 at 12:07 PM, Mike Taylor > > <michaelaarontaylor at gmail.com> wrote: > >> I would prefer if it returned the DOMTokenList, to enable chaining like: > >> > >> foo.toggle('bar baz').remove('bat'); > >> > >> Same for the rest of the DOMTokenList methods, as well. > >> > >> foo.add('bar').remove('baz'); > >> > >> See also https://github.com/jquery/standards/issues/13 for relevant > >> discussion. > > > > This is not how existing DOM methods tend to behave, but in general I > > support adding it in more places, because it's very useful for methods > > that mutate the object they're called on. > > Agreed! "That's not how things used to be" is a terrible argument. > Especially for something that had such bad (== java-esq) design as the > DOM originally had and to a great extent still has. > 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? Ojan
Received on Friday, 28 October 2011 13:55:34 UTC