You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Though most of the automated atomization will reproduce identical results, there are some known edge cases. These should be documented as "gotchas" on the website. And ideally, resolved by some code updates when someone clever finds a better solution to handle them.
Dealing with CSS Specificity
Sometimes styles that normally would apply based on specificity no longer do after the atomization reduces redundant code that would have come later and thus overridden the previous style. For Example:
In the above example, assume that all of these classes have many other properties (except the last one). Notice that they all happen to affect padding, and that the order of them in the CSS file will effect their specificity.
However, when atomized, the redundant classes that come later, are removed. So specificity is impacted. Here's how that looks from the HTML's perspective.
<divclass="success btn-sm"></div>
Here, the success and btn-sm both apply padding to the element, however .btn-sm is defined in the CSS later, so the element should get 10px of padding. However, when atomized the classes become this:
<divclass="rp__2 rp__0"></div>
And because the redundant atomized classes are removed, the actual padding to be applied is 20px, since rp__2 is defined later in the CSS file.
Workaround
To resolve this, create atomic styles that use !important to ensure they are applied over their alternatives.
<divclass="success btn-sm p-md"></div>
becomes
<divclass="rp__2 rp__0 rp__3"></div>
And the correct padding is applied in both cases.
Matching nested selectors
If there are two unrelated nested selectors that have the same level of nesting and the same property/value inside them it is possible for them to cross-effect each other.
Though most of the automated atomization will reproduce identical results, there are some known edge cases. These should be documented as "gotchas" on the website. And ideally, resolved by some code updates when someone clever finds a better solution to handle them.
Dealing with CSS Specificity
Sometimes styles that normally would apply based on specificity no longer do after the atomization reduces redundant code that would have come later and thus overridden the previous style. For Example:
In the above example, assume that all of these classes have many other properties (except the last one). Notice that they all happen to affect padding, and that the order of them in the CSS file will effect their specificity.
However, when atomized, the redundant classes that come later, are removed. So specificity is impacted. Here's how that looks from the HTML's perspective.
Here, the
success
andbtn-sm
both applypadding
to the element, however.btn-sm
is defined in the CSS later, so the element should get10px
of padding. However, when atomized the classes become this:And because the redundant atomized classes are removed, the actual padding to be applied is
20px
, sincerp__2
is defined later in the CSS file.Workaround
To resolve this, create atomic styles that use
!important
to ensure they are applied over their alternatives.becomes
And the correct padding is applied in both cases.
Matching nested selectors
If there are two unrelated nested selectors that have the same level of nesting and the same property/value inside them it is possible for them to cross-effect each other.
Example:
This CSS input:
Would produce this atomzied output:
When this HTML gets atomized, it works as intended, the inner div's both receive a padding of 1px.
This scenario would also receive a 1px padding on the inner div, even though based on the original code, it should not.
Workaround
There is no workaround for this, it is recommended to avoid using nesting when using automated atomization.
The text was updated successfully, but these errors were encountered: