Untitled
unknown
plain_text
2 years ago
509 B
5
Indexable
// Helper function to check if the text content matches the target text
const isTextContent = (
content: string | undefined,
node: Element | undefined,
targetText: string
): boolean => {
const hasText = (element: Element) => element.textContent === targetText;
const nodeHasText = node && hasText(node);
const childrenDontHaveText = Array.from((node?.children ?? []) as Element[]).every(
(child) => !hasText(child)
);
return Boolean(nodeHasText && childrenDontHaveText);
};
Editor is loading...
Leave a Comment