Hi Harbs

2018-03-13 13:34 GMT+01:00 Harbs <harbs.li...@gmail.com>:

>
> I don’t think you understood what Piotr was saying.
>
> The order of setting the *property* and *className* matters. He was not
> talking about the order of class names in a class list.
>
>
I think is what I did right? change order of "primary" with "className" and
show that doesn't matter.
I was the first to find that problem in 2016 and report it, as I said.


>
> > I'm referring with this to "the theme feature" effort, where we want to
> > easily change appearance in a Royale UI set.
> > Right now we need to implement for each control 2 methods like the
> > followings (code from MDL)
> >
> > COMPILE::JS
> > private function addOrRemove(classNameVal:String,add:Boolean):void
> > {
> > add ? _classList.add(classNameVal) : _classList.remove(classNameVal);
> > }
> > COMPILE::JS
> > override protected function computeFinalClassNames():String
> > {
> > return _classList.compute() + super.computeFinalClassNames();
> > }
> >
> > and use
> >
> > COMPILE::JS
> > {
> > addOrRemove("mdl-js-ripple-effect",value);
> > setClassName(computeFinalClassNames());
> > }
> >
> > In my Jewel class I only do this (no additional methods or overrides)
> >
> > COMPILE::JS
> > {
> > element.classList.toggle("primary", value);
> > }
> >
> > and that's all :)
>
> Again, part of the strength of Royale is that we control the properties.
> Setting the DOM properties directly causes us to lose that.
>
>
Harbs, sincerily, don't understand what you are trying to say. If I want to
set a class, as a user (or even developer) I want to do that in the more
straight forward way I can



> You can probably optimize the code even more than it was already optimized:
>
>
> COMPILE::JS
> private function addOrRemove(classNameVal:String,add:Boolean):void
> {
> add ? _classList.add(classNameVal) : _classList.remove(classNameVal);
> setClassName(computeFinalClassNames());
> }
> COMPILE::JS
> override protected function computeFinalClassNames():String
> {
> return _classList.compute() + super.computeFinalClassNames();
> }
>
> and use
>
> COMPILE::JS
> {
> addOrRemove("mdl-js-ripple-effect",value);
> }
>
> Which is pretty close to your:
> COMPILE::JS
> {
> element.classList.toggle("primary", value);
> }
>

That's ok, but you still have the two functions around


>
> If you use this a lot, you can probably factor out the boilerplate code
> from your classes.
>
>
Right, for me that's a framework task



> Harbs




-- 
Carlos Rovira
http://about.me/carlosrovira

Reply via email to