I wanted to ask for your opinion on an improvement I wanted to push.
The Jewel InputButtonSize bead creates a custom selector (its name is a time
token) and adds it to the "royale_dynamic_css" sheet, with addDynamicSelector,
and then assigns it to strand replacing the "className" property which
overrides any previous value that was indicated in this property.
To override this behavior I have used "removeClass" and "addClass" but I have a
question... is it worth removing the selectors that have been created and
become unused? (I have created the "removeDynamicSelector" class)
This is the current code block of the bead:
/**
* @private
* @royaleignorecoercion
org.apache.royale.jewel.CheckBox
*/
COMPILE::JS
private function
sizeChangeHandler(event:Event):void
{
var ruleName:String;
var beforeSelector:String = "";
if(width || height) {
ruleName =
"inpbtn" + ((new Date()).getTime() + "-" + Math.floor(Math.random()*1000));
(host as
StyledUIBase).className = ruleName;
}
And this is the same block with my modifications:
private var ruleName:String = "";
/**
* @private
* @royaleignorecoercion
org.apache.royale.jewel.CheckBox
*/
COMPILE::JS
private function
sizeChangeHandler(event:Event):void
{
var beforeSelector:String = "";
if(width || height) {
if(ruleName!="")
{
removeDynamicSelector(".jewel." + ruleName + " input+span::before");
removeDynamicSelector(".jewel." + ruleName + " input+span::after");
if ((host as StyledUIBase).containsClass(ruleName) )
(host as StyledUIBase).removeClass(ruleName);
}
ruleName =
"inpbtn" + ((new Date()).getTime() + "-" + Math.floor(Math.random()*1000));
// (host as
StyledUIBase).className = ruleName;
(host as
StyledUIBase).addClass(ruleName);
}
Thx.
Hiedra