Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add instanceof Node to document node
  • Loading branch information
sw1tch3roo committed Aug 6, 2025
commit fc67a960c2b6c5e44fa6049ad108fd86561bd97a
9 changes: 3 additions & 6 deletions lib/utils/isInDocument.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 4 additions & 6 deletions lib/utils/isInDocument.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Node } from 'postcss';

import { isDocument } from './typeGuards.mjs';

/**
* @param {import('postcss').Node} node
* @param {Node} node
* @returns {boolean}
*/
export default function isInDocument(node) {
Expand All @@ -11,11 +13,7 @@ export default function isInDocument(node) {
if (isDocument(current)) return true;

// Check for unofficial 'document' property from parsers like postcss-html
if (
'document' in current &&
current.document &&
isDocument(/** @type {import('postcss').Document} */ (current.document))
)
if ('document' in current && current.document instanceof Node && isDocument(current.document))
return true;

if (!current.parent) break;
Expand Down
Loading