-
-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make rule-value-function and global work together #1427
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,16 +200,22 @@ export default class RuleList { | |
sheet | ||
} = this.options | ||
|
||
// updateFun is a workaround to use together | ||
// jss-plugin-rule-value-function and jss-plugin-global | ||
const hasUpdateFun = typeof rule.updateFun == 'function' | ||
|
||
// It is a rules container like for e.g. ConditionalRule. | ||
if (rule.rules instanceof RuleList) { | ||
// Ignore if there is an updateFun | ||
if (!hasUpdateFun && rule.rules instanceof RuleList) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. breaks encapsulation between plugins and the core, core has no knowledge about style functions, so far we managed to run the plugin in a way that doesn't require this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the idea is that the plugin reacts to onUpdate hook and calls the function |
||
rule.rules.update(data, options) | ||
return | ||
} | ||
|
||
const styleRule: StyleRule = (rule: any) | ||
const {style} = styleRule | ||
|
||
plugins.onUpdate(data, rule, sheet, options) | ||
if (hasUpdateFun) rule.updateFun(data) | ||
else plugins.onUpdate(data, rule, sheet, options) | ||
|
||
// We rely on a new `style` ref in case it was mutated during onUpdate hook. | ||
if (options.process && style && style !== styleRule.style) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was how we hide the implementation detail of the interface that only this plugin knows how to handle