diff options
author | eleanor-park <eleanor_park@brown.edu> | 2024-07-26 01:23:06 -0400 |
---|---|---|
committer | eleanor-park <eleanor_park@brown.edu> | 2024-07-26 01:23:06 -0400 |
commit | 647b66c965f5896d784de0f321d31cc712937e1c (patch) | |
tree | 51521faf3dc5d1ebcf867d78e7938bbef8135e86 /src/ClientUtils.ts | |
parent | decbefe23a1da35c838222bafe8a2c029c6ea794 (diff) |
Revert "Merge branch 'master' into eleanor-gptdraw"
This reverts commit decbefe23a1da35c838222bafe8a2c029c6ea794, reversing
changes made to 8ca26551622d36b7856f5c1865498fa9e5d888b5.
Diffstat (limited to 'src/ClientUtils.ts')
-rw-r--r-- | src/ClientUtils.ts | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/ClientUtils.ts b/src/ClientUtils.ts index 630d7edbc..d03ae1486 100644 --- a/src/ClientUtils.ts +++ b/src/ClientUtils.ts @@ -86,7 +86,6 @@ export function returnEmptyDoclist() { return [] as any[]; } -// eslint-disable-next-line @typescript-eslint/no-namespace export namespace ClientUtils { export const CLICK_TIME = 300; export const DRAG_THRESHOLD = 4; @@ -450,29 +449,30 @@ export function smoothScrollHorizontal(duration: number, element: HTMLElement | animateScroll(); } -export function addStyleSheet() { +export function addStyleSheet(styleType: string = 'text/css') { const style = document.createElement('style'); + style.type = styleType; const sheets = document.head.appendChild(style); - return sheets.sheet; + return (sheets as any).sheet; } -export function addStyleSheetRule(sheet: CSSStyleSheet | null, selector: string, css: string | {[key:string]: string}, selectorPrefix = '.') { +export function addStyleSheetRule(sheet: any, selector: any, css: any, selectorPrefix = '.') { const propText = typeof css === 'string' ? css : Object.keys(css) .map(p => p + ':' + (p === 'content' ? "'" + css[p] + "'" : css[p])) .join(';'); - return sheet?.insertRule(selectorPrefix + selector + '{' + propText + '}', sheet.cssRules.length); + return sheet.insertRule(selectorPrefix + selector + '{' + propText + '}', sheet.cssRules.length); } -export function removeStyleSheetRule(sheet: CSSStyleSheet|null, rule: number) { - if (sheet?.rules.length) { +export function removeStyleSheetRule(sheet: any, rule: number) { + if (sheet.rules.length) { sheet.removeRule(rule); return true; } return false; } -export function clearStyleSheetRules(sheet: CSSStyleSheet|null) { - if (sheet?.rules.length) { +export function clearStyleSheetRules(sheet: any) { + if (sheet.rules.length) { numberRange(sheet.rules.length).map(() => sheet.removeRule(0)); return true; } |