Change nodeIsInline logic to be more typesafe

This commit is contained in:
Henrik Giesel 2021-01-26 23:49:48 +01:00
parent feddf96f2a
commit 9b5d915983

View File

@ -176,19 +176,14 @@ const INLINE_TAGS = [
];
function nodeIsInline(node: Node): boolean {
return (
nodeIsText(node) ||
INLINE_TAGS.includes((node as Element).tagName)
);
return !nodeIsElement(node) || INLINE_TAGS.includes(node.tagName);
}
function inListItem(): boolean {
const anchor = window.getSelection().anchorNode;
let n = nodeIsElement(anchor) ? anchor : anchor.parentElement;
let inList = false;
let n = nodeIsElement(anchor) ? anchor : anchor.parentElement;
while (n) {
inList = inList || window.getComputedStyle(n).display == "list-item";
n = n.parentElement;