Hi Harb, thanks for replying. > Did you do any profiling? I haven't done any isolated tests. I haven't really noticed a significant difference before and after modifying the bead, mainly because, although I use it actively, I don't change the size after creation.
I'm going to push the changes, I think it's important to allow the use of the className and your phrase "If it's quick and efficient to remove the rule, I'd do it" has convinced me 😝 Anyway, I was also thinking about fixing the CSS selector because I have only 2 sizes: 16, 20 and I assumed this would improve performance, so I'm going to follow your advice. If I experience any significant changes I'll share them with the @dev. Thx Harb. Hiedra -----Mensaje original----- De: Harbs <harbs.li...@gmail.com> Enviado el: domingo, 28 de julio de 2024 20:14 Para: Apache Royale Development <dev@royale.apache.org> Asunto: Re: Jewel InputButtonSize and modifying the "royale_dynamic_css" stylesheet Did you do any profiling? If it’s quick and efficient to remove the rule, I’d do it. If it’s expensive, it’s likely better to leave it. It would take a lot of lookups to make a measurable difference in performance. I’d actually make an optimization there: It looks like it’s adding a class rule for **every** instance added. It would be much better to create one rule for each size, so if you have 100 instances that are all the same size, there would only be a single lookup. If you do that, you’re definitely better off leaving the rule. Thanks, Harbs > On Jul 28, 2024, at 2:08 AM, Maria Jose Esteve <mjest...@iest.com> wrote: > > 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 >