Skip to content

Commit 186f8f1

Browse files
fix(migrate): use Node in JSDOM
1 parent 04d20e7 commit 186f8f1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

migrate/text-from-element.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { JSDOM } from "jsdom"
2+
13
interface GetTextOptions {
24
treatBlockAsNewline?: boolean;
35
collapseSpaces?: boolean;
@@ -13,16 +15,15 @@ const BLOCK_ELEMENTS = [
1315
'hr', 'br'
1416
];
1517

18+
const Node = new JSDOM('').window.Node;
1619
function isBlockElement(node: Node): boolean {
1720
if (node.nodeType !== Node.ELEMENT_NODE) return false;
1821
const element = node as HTMLElement;
1922

20-
2123
if (BLOCK_ELEMENTS.includes(element.tagName.toLowerCase())) {
2224
return true;
2325
}
2426

25-
2627
const style = window.getComputedStyle(element);
2728
return style.display === 'block' ||
2829
style.display === 'flex' ||

0 commit comments

Comments
 (0)