instanceof instead of nodeType
This commit is contained in:
parent
cd469f33db
commit
e89970d339
1 changed files with 5 additions and 7 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue