From 3d9e5a0f7ad586aba75cb28e2117a4ea567e204f Mon Sep 17 00:00:00 2001 From: EduSantosBrito Date: Fri, 25 Aug 2023 13:47:54 +0200 Subject: [PATCH 1/2] fix: ignore stylesheets fetching when is a inline style --- lib/core/utils/preload-cssom.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/core/utils/preload-cssom.js b/lib/core/utils/preload-cssom.js index c919d023c4..198ec75ac9 100644 --- a/lib/core/utils/preload-cssom.js +++ b/lib/core/utils/preload-cssom.js @@ -173,7 +173,10 @@ function getStylesheetsFromDocumentFragment(rootNode, convertDataToStylesheet) { isLink, root: rootNode }); - out.push(stylesheet.sheet); + // If the shadowRoot has inline style (e.g. Lit component), it will return null at stylesheet.sheet and will trigger "Couldn't load preload assets" error. + if(stylesheet.sheet) { + out.push(stylesheet.sheet); + } return out; }, []) ); From 2b6be25a9b8a497f378bef1b362cecd71393a82a Mon Sep 17 00:00:00 2001 From: Eduardo Santos de Brito Date: Tue, 5 Sep 2023 16:26:04 +0200 Subject: [PATCH 2/2] chore: update comment for jsdom issue Co-authored-by: Steven Lambert <2433219+straker@users.noreply.github.com> --- lib/core/utils/preload-cssom.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/core/utils/preload-cssom.js b/lib/core/utils/preload-cssom.js index 198ec75ac9..7f5fab5db6 100644 --- a/lib/core/utils/preload-cssom.js +++ b/lib/core/utils/preload-cssom.js @@ -173,7 +173,8 @@ function getStylesheetsFromDocumentFragment(rootNode, convertDataToStylesheet) { isLink, root: rootNode }); - // If the shadowRoot has inline style (e.g. Lit component), it will return null at stylesheet.sheet and will trigger "Couldn't load preload assets" error. + // prevent error in jsdom with style elements not having a `sheet` property + // @see https://github.com/jsdom/jsdom/issues/3179 if(stylesheet.sheet) { out.push(stylesheet.sheet); }