aboutsummaryrefslogtreecommitdiff
path: root/src/ClientUtils.ts
diff options
context:
space:
mode:
authorA.J. Shulman <Shulman.aj@gmail.com>2024-07-17 14:59:45 -0400
committerA.J. Shulman <Shulman.aj@gmail.com>2024-07-17 14:59:45 -0400
commitb7b3604f54ff5174b7f9a2f115362ea11d1a83ae (patch)
tree2378a214b6f624451228903808d06c9337142feb /src/ClientUtils.ts
parentdd379c9e4c4c214b2ed14e3fd9a5f966e4f03b48 (diff)
parent9da1206079b2f20274a720c4e62cf1d6e063e7ac (diff)
Merge branch 'master' into aj-system-message
Diffstat (limited to 'src/ClientUtils.ts')
-rw-r--r--src/ClientUtils.ts18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/ClientUtils.ts b/src/ClientUtils.ts
index d03ae1486..630d7edbc 100644
--- a/src/ClientUtils.ts
+++ b/src/ClientUtils.ts
@@ -86,6 +86,7 @@ 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;
@@ -449,30 +450,29 @@ export function smoothScrollHorizontal(duration: number, element: HTMLElement |
animateScroll();
}
-export function addStyleSheet(styleType: string = 'text/css') {
+export function addStyleSheet() {
const style = document.createElement('style');
- style.type = styleType;
const sheets = document.head.appendChild(style);
- return (sheets as any).sheet;
+ return sheets.sheet;
}
-export function addStyleSheetRule(sheet: any, selector: any, css: any, selectorPrefix = '.') {
+export function addStyleSheetRule(sheet: CSSStyleSheet | null, selector: string, css: string | {[key:string]: string}, 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: any, rule: number) {
- if (sheet.rules.length) {
+export function removeStyleSheetRule(sheet: CSSStyleSheet|null, rule: number) {
+ if (sheet?.rules.length) {
sheet.removeRule(rule);
return true;
}
return false;
}
-export function clearStyleSheetRules(sheet: any) {
- if (sheet.rules.length) {
+export function clearStyleSheetRules(sheet: CSSStyleSheet|null) {
+ if (sheet?.rules.length) {
numberRange(sheet.rules.length).map(() => sheet.removeRule(0));
return true;
}