Skip to content

Commit

Permalink
fix: adding new classes in rootClassName before removing (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimirluk88 authored Mar 12, 2024
1 parent 4dbfdf9 commit e29cde1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/components/theme/dom-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ export function updateBodyClassName({
bodyEl.classList.add(rootClassName);
}

if (className) {
const parsedCustomRootClassNames = className.split(' ');
parsedCustomRootClassNames.forEach((cls) => {
if (cls && !bodyEl.classList.contains(cls)) {
bodyEl.classList.add(cls);
}
});
}

if (prevClassName) {
const parsedPrevCustomRootClassNames = prevClassName.split(' ');
parsedPrevCustomRootClassNames.forEach((cls) => {
Expand All @@ -41,6 +32,15 @@ export function updateBodyClassName({
});
}

if (className) {
const parsedCustomRootClassNames = className.split(' ');
parsedCustomRootClassNames.forEach((cls) => {
if (cls && !bodyEl.classList.contains(cls)) {
bodyEl.classList.add(cls);
}
});
}

[...bodyEl.classList].forEach((cls) => {
if (cls.startsWith(modsClassName(b({theme: true})))) {
bodyEl.classList.remove(cls);
Expand Down

0 comments on commit e29cde1

Please sign in to comment.