diff --git a/src/core/Stats.tsx b/src/core/Stats.tsx index b842ced5a..302284ce2 100644 --- a/src/core/Stats.tsx +++ b/src/core/Stats.tsx @@ -17,10 +17,12 @@ export function Stats({ showPanel = 0, className, parent }: Props): null { const node = (parent && parent.current) || document.body stats.showPanel(showPanel) node?.appendChild(stats.dom) - if (className) stats.dom.classList.add(...className.split(' ').filter((cls) => cls)) + const classNames = (className ?? '').split(' ').filter((cls) => cls) + if (classNames.length) stats.dom.classList.add(...classNames) const begin = addEffect(() => stats.begin()) const end = addAfterEffect(() => stats.end()) return () => { + if (classNames.length) stats.dom.classList.remove(...classNames) node?.removeChild(stats.dom) begin() end() diff --git a/src/core/StatsGl.tsx b/src/core/StatsGl.tsx index 2d6d7dc7e..0c99b2f00 100644 --- a/src/core/StatsGl.tsx +++ b/src/core/StatsGl.tsx @@ -23,9 +23,11 @@ export function StatsGl({ className, parent, ...props }: Props) { if (stats) { const node = (parent && parent.current) || document.body node?.appendChild(stats.dom) - if (className) stats.container.classList.add(...className.split(' ').filter((cls) => cls)) + const classNames = (className ?? '').split(' ').filter((cls) => cls) + if (classNames.length) stats.dom.classList.add(...classNames) const end = addAfterEffect(() => stats.update()) return () => { + if (classNames.length) stats.dom.classList.remove(...classNames) node?.removeChild(stats.dom) end() }