export const getPreviousElementSibling = (
element: Element,
): O.Option<Element> => O.fromNullable(element.previousElementSibling);
... several more of these DOM functions that return an Option...
const getOpCode = (textArea: HTMLElement) => {
return pipe(
textArea.closest("tr"),
O.fromNullable,
O.chain(getPreviousElementSibling),
O.chain(getNthChild("td", 4)),
O.chain(getElementAttribute("title")),
O.getOrElse(() => ""), // <-- if any Option is none, return ""
);
};
export const getPreviousElementSibling = (
element: Element,
): O.Option<Element> => O.fromNullable(element.previousElementSibling);
... several more of these DOM functions that return an Option...
const getOpCode = (textArea: HTMLElement) => {
return pipe(
textArea.closest("tr"),
O.fromNullable,
O.chain(getPreviousElementSibling),
O.chain(getNthChild("td", 4)),
O.chain(getElementAttribute("title")),
O.getOrElse(() => ""), // <-- if any Option is none, return ""
);
};