Open louisabraham opened 4 years ago
I don't know how to add tests, but I think it would be a nice thing if someone has a bit of time!
(also it looks that there are issues in master that prevent the tests from running)
See https://github.com/cssinjs/jss/issues/1335#issuecomment-727893215 regarding the syntax.
Would be great if someone added tests to rule-value-function package, so we can play with the implementation details and find a better way
Fix #1335
Implementation details
I attach an attribute
updateFun
to rules with type'global'
that have a function as declaration (i.e. rules that match both plugins).I already had to modify
RuleList.js
to prevent the special caserule.rules instanceof RuleList
from skipping the update, so I included the code that executesupdateFun
inRuleList.js
. An important choice (that is easily modifiable) is thatplugins.onUpdate
will not be launched on the global rule that is updated with a function: other plugins will not run on the updated properties.Another meaningful possibility would be to include the call to
updateFun
in theonUpdate
method of therule-value-function
. This would allow us to callplugins.onUpdate
fromRuleList.js
, so have other plugins run on the rule after update. I was not sure what interactions this could create with other plugins so I didn't handle it this way.It is my first contribution to a JS project, so please feel free to give me advice to improve my coding style :smiley:
Example
gives