You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by Bob Schellink <sa...@gmail.com> on 2010/07/10 08:51:39 UTC

Control Attribute enhancements

I think we have a chance to improve performance in the AbstractControl (AC) implementation. AC
provides the following API:

getAttributes
getAttribute
setAttribute
hasAttributes
addCssClass
removeCssClass
hasStyles (deprecated for now)
setStyle
getStyle
getStyles (deprecated for now)

This API is all about manipulating the HTML attributes of a Control. The API is optimized for
setAttribute/getAttribute but not for "class" and "style" attributes which are both String based.

I'm thinking we can create an Attributes class that encapsulates this API and have some smarts on
handling "class" and "style" attributes as a Set and Map instead. The Attributes class needs to be
smart enough to handle edge cases such as 'setAttribute("class", "blue red");' and getAttributes()
which will return *all* attributes including "style" and "class".

I've done some performance tests in the past[1] and have settled on the String based approach simply
because I thought set/getAttributes would be more common for "class" and "style" manipulation.
However with CSS3 and JS libs its quite common to have multiple css classes per control so I think
this change will generally have a positive performance improvement.

Anyone got time to implement something like this? Otherwise I'll attempt it after the next release.

Bob

[1]: https://issues.apache.org/jira/browse/CLK-249