Skip to content
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

fix(atomic): fix duplication of the same css properties in the same file #972

Merged
merged 1 commit into from May 21, 2022

Conversation

jpnelson
Copy link
Contributor

Motivation

This fixes a bug I discovered where the same property is getting overriden by other css in the same file. Test case provided for the scenario that's failing

Summary

Relatively simple fix – this just uses the CSS text itself as a key in the metadata to ensure that it's unique per rule + declaration, between declarations too.

Test plan

Fixed with a snapshot test

@@ -307,7 +307,7 @@ export default function getTemplateProcessor(
}
const atomicRules = atomize(cssText);
atomicRules.forEach((rule) => {
state.rules[rule.property] = {
state.rules[rule.cssText] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jpnelson great catch! I spotted this issue whilst working on the styled PR (I thought it wasn't affecting css, my bad) – and it seemed fixed when using rule.className as the key (as atomizeFn already creates a unique key for the rule).

is the reason you prefer cssText (eg. .atm_gi_yh40bf{margin:2px;}) over className (eg. atm_gi_yh40bf) because className can be null on certain cases (@keyframes only, right?)

@Anber
Copy link
Collaborator

Anber commented May 21, 2022

Hi @jpnelson!
I still don't understand, why CI doesn't run checks for your PRs :)

@Anber Anber merged commit f60039e into callstack:master May 21, 2022
@Anber
Copy link
Collaborator

Anber commented May 21, 2022

Btw, I'm in the process of big refactoring of shaker and during this refactoring I've replaced Lerna with Turborepo, and that's dramatically increased the speed of (pre-commit) checks, so when I finish it, you won't be needed to skip them anymore :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants