W3C home > Mailing lists > Public > public-html@w3.org > September 2007

2.3.2. DOMTokenList

From: Marek Paw這wski <marekp.w3c@gmail.com>
Date: Wed, 5 Sep 2007 09:32:55 +0200
Message-ID: <cc36d2760709050032l37b51ca8i84d4af33f8c46d47@mail.gmail.com>
To: public-html@w3.org
(This is part of my detailed review of the Document Object Model section.)

1. I suggest DOMTokenList methods add() and remove() return
DOMTokenList itself. This would allow for useful function chaining,
f.e.:

   myDiv.classList.add('toFront').toggle('maximized');

Consider that jQuery already uses similiar approach. I'm not sure if
this would be useful on other objects which use DOMTokenList interface
but certainly it is for classList. I'd even consider such behavior for
toggle() but I don't have strong opinion about that.

2. Anyway, I know that this was discussed on WHATWG list but why not
extend className instead of adding classList? Is this producing some
serious compatibility problems? As I understand current spec classList
stringify to the same value as className.


3. I'm not sure if it is intended but with current algorithms for
adding token in add() and toggle() methods when DOMTokenList object's
underlying string is  empty it ends up with value of  U+0020 SPACE +
token. Shouldn't there be condition that if underlying string is empty
then append only token? I believe that today's common way of obtaining
classList is via:

   classArray = myDiv.classList.split(' ');

With current algorithm it will lead to array with additional empty
elemets and could cause some compatibility problems with existing
pages.

-- 
Best regards,
Marek Paw這wski
Received on Wednesday, 5 September 2007 13:01:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 9 May 2012 00:16:07 GMT