cssinjs / aphrodite-jss

Aphrodite-like API on top of JSS.
MIT License
92 stars 17 forks source link

Update to jss ^8.1.0 #19

Closed pyrrho closed 6 years ago

pyrrho commented 6 years ago

Like it says on the tin. Note; this PR does not increment the aphrodite-jss version, though it includes a change that will break interoperability with jss 7.1.7

A change in jss 8.0.0 broke interoperability with aphrodite-jss 1.1.1, specifically in how selector names are generated. In JSS 7.1.7, the RegularRule class would only invoke generateClassName only if className had not already been set on the rule, and would always use the .className to set the selector;

if (options.className) this.className = options.className
else if (generateClassName) this.className = generateClassName(this, sheet)
this.selectorText = options.selector || `.${this.className}`

In jss 8.0.0 RegularRule was renamed to StyleRule, className was dropped from its logic, and the selector name is always generated by invoking generateClassName;

this.selectorText = selector || `.${generateClassName(this, sheet)}`

This caused a mismatch between the aphrodite-jss-generated class name returned by css, and the selector generated by jss. Explicitly setting the Rule's selector in aphrodite-jss before adding it to the jss StyleSheet is one way to work around this issue.

... I probably didn't need to go into this much detail for this PR, but... Hooray for old habits?

kof commented 6 years ago

lgtm, thanks

kof commented 6 years ago

published