[Webkit-unassigned] [Bug 46841] Using classList to add or remove classes is too slow

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Sep 29 15:26:06 PDT 2010


https://bugs.webkit.org/show_bug.cgi?id=46841


Erik Arvidsson <arv at chromium.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #1 from Erik Arvidsson <arv at chromium.org>  2010-09-29 15:26:06 PST ---
This test is flawed for a few reasons. Please see the spec for how DOMTokenList is supposed to work.

A few things stands out in the JS implementation

1. None of the methods validate the token.
2. Remove sets the wrong className in the presence of whitespace.
3. Add always adds an extra space. It should only add a space when the last character is not already a space.

Once the JS implementations passes the tests in http://trac.webkit.org/browser/trunk/LayoutTests/fast/dom/HTMLElement/script-tests/class-list.js and if the native one is slower than the JS implementation then we definitely need to reopen this.

There is room for improvement in the current implementation, we are not smart about reusing the SpaceSplitString when adding or removing tokens.

On a different note, I think that the spec for DOMTokenList could be relaxed a bit to allow simplification of implementation without any loss of functionality for classList. For example 2 in the list above is kind of silly a requirement and minimizing the whitespace changes has no real value for classList.

In Chromium we have JS implementation that is a bit closer to the spec (it still does not do the complicated whitespace preserving in remove)

http://www.google.com/codesearch/p?hl=en#OAMlx_jo-ck/src/chrome/browser/resources/shared/js/class_list.js&q=class_list%5C.js&exact_package=chromium&sa=N&cd=1&ct=rc

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list