Skip to content

Commit

Permalink
fix: dynamic style unmounting
Browse files Browse the repository at this point in the history
  • Loading branch information
kripod committed Mar 30, 2020
1 parent f5ff7ac commit ff203cd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/glaze/src/useStyling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ export function useStyling(): (themedStyle: ThemedStyle) => string {
} else {
// Detach unused dynamic style from the DOM
// TODO: Use `ChildNode.remove()` when dropping IE 11 support
/* eslint-disable @typescript-eslint/no-non-null-assertion */
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const element = document.getElementById(className)!;
element.parentNode!.removeChild(element);
/* eslint-enable @typescript-eslint/no-non-null-assertion */
document.head.removeChild(element);

instancesByClassName.delete(className);
}
Expand Down Expand Up @@ -83,11 +82,12 @@ export function useStyling(): (themedStyle: ThemedStyle) => string {
);
}

className += `${appendedClassName} `;
className += ` ${appendedClassName}`;
}
});
}

return className;
// Remove prepended whitespace
return className.slice(1);
};
}

0 comments on commit ff203cd

Please sign in to comment.