Skip to content

Commit

Permalink
fix: prevent crash on jsdom
Browse files Browse the repository at this point in the history
- cssom package does not implement StyleSheet.media
  • Loading branch information
AriPerkkio committed Oct 31, 2022
1 parent 213ad5c commit 98a0c7e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/core/utils/preload-cssom.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,13 @@ function getStylesheetsFromDocumentFragment(rootNode, convertDataToStylesheet) {
* @returns {Array<Object>}
*/
function getStylesheetsFromDocument(rootNode) {
return Array.from(rootNode.styleSheets).filter(sheet =>
filterMediaIsPrint(sheet.media.mediaText)
);
return Array.from(rootNode.styleSheets).filter(sheet => {
if (!sheet.media) {
return false;
}

return filterMediaIsPrint(sheet.media.mediaText);
});
}

/**
Expand Down

0 comments on commit 98a0c7e

Please sign in to comment.