* fix: ensure TopicDetail locks the body when open * chore: ensure 'overflow-hidden' is always available via safelist * revert: prettier changes
20 lines
502 B
TypeScript
20 lines
502 B
TypeScript
export function replaceChildren(parentNode: Element, newChild: Element) {
|
|
if (parentNode.replaceChildren) {
|
|
return parentNode.replaceChildren(newChild);
|
|
}
|
|
|
|
parentNode.innerHTML = '';
|
|
parentNode.append(newChild);
|
|
}
|
|
|
|
export function lockBodyScroll(shouldLock: boolean) {
|
|
const isClient = document && 'body' in document;
|
|
if (!isClient) return;
|
|
|
|
if (shouldLock) {
|
|
document.body.classList.add('overflow-hidden');
|
|
} else {
|
|
document.body.classList.remove('overflow-hidden');
|
|
}
|
|
}
|