HeapsIO / domkit

CSS Components based strictly typed UI framework for Haxe
MIT License
84 stars 20 forks source link

Fix applyStyleRec sometimes applying the same property multiple times #54

Closed Speedphoenix closed 9 months ago

Speedphoenix commented 9 months ago

This PR makes it so properties are set only once per applyStyle.

Before this, when a property was set twice from the css style, if it was not alone in the css block it would be set twice on every applyStyle. For exemple pad-focusable here:

my-flow {
    base-button {
        pad-focusable: false;
    }
    base-button {
        recursive-propagate: true;
    }
    &.enabled {
        base-button {
            pad-focusable: true;
        }
    }
}

^ with the class .enabled, set_padFocusable was called only once (true)

my-flow {
    base-button {
        pad-focusable: false;
        recursive-propagate: true;
    }
    &.enabled {
        base-button {
            pad-focusable: true;
        }
    }
}

^ with the class .enabled, set_padFocusable was called twice (false then true)

This may have some side effects for code that assumed the setter was called twice, for example where same-frame transitions are concerned.

The question remains as to whether only the highest priority rule should be applied or if every rule should be applied every time in increasing priority order.

Speedphoenix commented 9 months ago

"apply once only" vs "apply all every time" could be an option in compile flags, or in the metadata next to @:p, or possibly even directly in the css, like

recursive-propagate: true !always-apply;