instanceof instead of nodeType

This commit is contained in:
rhiannon morris 2024-07-07 21:41:25 +02:00
parent cd469f33db
commit e89970d339

View file

@ -146,10 +146,9 @@ function sortFilters(cmp: (a: Node, b: Node) => number) {
}
function sortFiltersAlpha(e: Event) {
function getName(node: Node) {
if (node.nodeType == Node.ELEMENT_NODE) {
let elt = node as Element;
return elt.getElementsByTagName('input')[0].value;
function getName(node: Node): string {
if (node instanceof Element) {
return node.getElementsByTagName('input')[0].value;
} else {
return '';
}
@ -160,9 +159,8 @@ function sortFiltersAlpha(e: Event) {
function sortFiltersUses(e: Event) {
function getUses(node: Node) {
if (node.nodeType == Node.ELEMENT_NODE) {
let elt = node as Element;
let countStr = elt.getElementsByTagName('label')[0].dataset.count;
if (node instanceof Element) {
const countStr = node.getElementsByTagName('label')[0].dataset.count;
return countStr ? +countStr : 0;
} else {
return 0;