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

David Håsäther hasather at gmail.com
Fri Oct 28 03:58:01 PDT 2011


It would be more useful if the DOMTokenList methods (contains, add,
remove, toggle) would take a space separated list of tokens. This is
the behavior most DOM libraries have when dealing with class names.

So, when setting two classes, instead of

  ele.classList.add("hey");
  ele.classList.add("ho");

you could do

    ele.classList.add("hey ho");

Currently, the latter results in an INVALID_CHARACTER_ERR.

The behavior of all methods should be obvious I guess.

-- 
David Håsäther


More information about the whatwg mailing list