Skip to content

Commit fc67a96

Browse files
committed
add instanceof Node to document node
1 parent ce24f1c commit fc67a96

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

lib/utils/isInDocument.cjs

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/utils/isInDocument.mjs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { Node } from 'postcss';
2+
13
import { isDocument } from './typeGuards.mjs';
24

35
/**
4-
* @param {import('postcss').Node} node
6+
* @param {Node} node
57
* @returns {boolean}
68
*/
79
export default function isInDocument(node) {
@@ -11,11 +13,7 @@ export default function isInDocument(node) {
1113
if (isDocument(current)) return true;
1214

1315
// Check for unofficial 'document' property from parsers like postcss-html
14-
if (
15-
'document' in current &&
16-
current.document &&
17-
isDocument(/** @type {import('postcss').Document} */ (current.document))
18-
)
16+
if ('document' in current && current.document instanceof Node && isDocument(current.document))
1917
return true;
2018

2119
if (!current.parent) break;

0 commit comments

Comments
 (0)