This refactors the runtime service for readability and testability.
There's two new classes:
StyleEvaluator - Turns the arguments into a list of styles specified by the code and runtime state that are active on the element.
StyleResolver - Turns a list of styles into a fully resolved list of styles based on the relationships between styles that are declared in the blocks' code.
Note that the underlying implementation of the resolver was changed from a set to a graph to properly support style requirements and the ability to safely remove styles that have requirement conditions that aren't met.
In this implementation, because the nodes of the graph in the StyleResolver are just unique numbers, we don't explicitly create "node objects". Instead we infer their existence from the existence of an edge that connects to it. Directed edges are represented by a Map of a "from" node to a Set of "to" nodes.
This refactors the runtime service for readability and testability.
There's two new classes:
StyleEvaluator
- Turns the arguments into a list of styles specified by the code and runtime state that are active on the element.StyleResolver
- Turns a list of styles into a fully resolved list of styles based on the relationships between styles that are declared in the blocks' code.Note that the underlying implementation of the resolver was changed from a set to a graph to properly support style requirements and the ability to safely remove styles that have requirement conditions that aren't met.
In this implementation, because the nodes of the graph in the
StyleResolver
are just unique numbers, we don't explicitly create "node objects". Instead we infer their existence from the existence of an edge that connects to it. Directed edges are represented by aMap
of a "from" node to aSet
of "to" nodes.