A number of thoughts:

1. You did not address my question on whether using classList is really more 
efficient. https://plus.google.com/+PaulIrish/posts/APArpwWqew3 
<https://plus.google.com/+PaulIrish/posts/APArpwWqew3> was published in 2012. 
That was six years ago. In the meantime 
https://jsperf.com/classname-vs-classlist-showdown/5 
<https://jsperf.com/classname-vs-classlist-showdown/5> seems to indicate that 
just replacing the class name is much more efficient in modern browsers. It’s 
possible that there’s something wrong with the test, but it looks accurate to 
me.

2. Calling setClassName(computeFinalClassNames()); both when className assigned 
and when addedToParent() is called will result in the classNames being set at 
least twice for every component.

3. Adding “remove” and “removeAll” and “toggle" to every UIBase does not seem 
very PAYG.

4. “removeAll” looks very inefficient. Simply zeroing out the className of the 
element should be much more efficient than looping over the collection.

5. There’s no way to get the (full) classNames of a component using your 
methods.

6. I don’t think there’s a need to use trim and even if there would, the native 
JS String.prototype.trim() works fine. The StringUtil is only really useful for 
cross-platform code.

Harbs

> On Mar 15, 2018, at 4:06 PM, Carlos Rovira <[email protected]> wrote:
> 
> Hi,
> 
> I code the API we talked about in the previous email. Is in the UIBase copy
> in Jewel lib
> 
> Some things to notice as you review:
> 
> * I put COMPILE::JS in each method, but maybe the methods should be for all
> platforms and use COMPILE::XX in the body
> 
> * typeNames comes back as a public var without getter/setters
> 
> * In addedToParent I call setClassName(computeFinalClassNames())
> (this makes the components with properties reach sooner than this call, is
> there some way to make this reach the first?)
> 
> * className setter as well calls setClassName(computeFinalClassNames())
> 
> * computeFinalClassNames has a StringUtil.trim, maybe this could be a
> problem but don't know other way to ensure there's no spaces left, since if
> not this comes a problem for the latter split
> 
> * setClassName calls new API "addStyles"
> 
> * New API is composed of:
> addStyles -> is where all complicated logic is, this is the point where all
> converges, is this the best way to get this? some better alterantive? let
> me know. Here I care for empty strings and for one style strings vs
> multiple separated by spaces
> removeStyles -> the counterpart to the previous method
> toggleStyles -> this is straight forward
> removeAllStyles -> This loop seems to be more performant than className=""
> and I'm taking care of not removing typeNames in the process
> 
> (I didn't create versions for contains and item classList methods since it
> seems not useful for us)
> 
> Thoughts?
> 
> 
> -- 
> Carlos Rovira
> http://about.me/carlosrovira

Reply via email to