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 sortFiltersAlpha(e: Event) {
function getName(node: Node) { function getName(node: Node): string {
if (node.nodeType == Node.ELEMENT_NODE) { if (node instanceof Element) {
let elt = node as Element; return node.getElementsByTagName('input')[0].value;
return elt.getElementsByTagName('input')[0].value;
} else { } else {
return ''; return '';
} }
@ -160,9 +159,8 @@ function sortFiltersAlpha(e: Event) {
function sortFiltersUses(e: Event) { function sortFiltersUses(e: Event) {
function getUses(node: Node) { function getUses(node: Node) {
if (node.nodeType == Node.ELEMENT_NODE) { if (node instanceof Element) {
let elt = node as Element; const countStr = node.getElementsByTagName('label')[0].dataset.count;
let countStr = elt.getElementsByTagName('label')[0].dataset.count;
return countStr ? +countStr : 0; return countStr ? +countStr : 0;
} else { } else {
return 0; return 0;