Explorar o código

add typed wrapper around document.getElementById

checktheroads %!s(int64=4) %!d(string=hai) anos
pai
achega
d2b915f6c2
Modificáronse 1 ficheiros con 4 adicións e 0 borrados
  1. 4 0
      netbox/project-static/src/util.ts

+ 4 - 0
netbox/project-static/src/util.ts

@@ -148,6 +148,10 @@ export function* getElements(
   }
   }
 }
 }
 
 
+export function getElement<E extends HTMLElement>(id: string): Nullable<E> {
+  return document.getElementById(id) as Nullable<E>;
+}
+
 /**
 /**
  * scrollTo() wrapper that calculates a Y offset relative to `element`, but also factors in an
  * scrollTo() wrapper that calculates a Y offset relative to `element`, but also factors in an
  * offset relative to div#content-title. This ensures we scroll to the element, but leave enough
  * offset relative to div#content-title. This ensures we scroll to the element, but leave enough