From 74bd94f7bb9522b22b57a5353ca6070f67074127 Mon Sep 17 00:00:00 2001 From: gabrielzevedo Date: Tue, 11 Jun 2024 18:13:13 -0300 Subject: [PATCH] fix: verify if document exists --- src/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 0cb2f4f..119463f 100755 --- a/src/utils.ts +++ b/src/utils.ts @@ -102,7 +102,7 @@ import {css} from "lit-element/lit-element.js"; export default css\`${cssText.replace(/([$`\\])/g, '\\$1')}\`; ` -const styleModule = (cssText: string, nonce?: string) => nonce ? `\ +const styleModule = (cssText: string, nonce?: string) => typeof document !== 'undefined' ? nonce ? `\ const css = \`${cssText.replace(/([$`\\])/g, '\\$1')}\`; const style = document.createElement("style"); style.setAttribute("nonce", ${nonce}); @@ -115,7 +115,7 @@ document.head .appendChild(document.createElement("style")) .appendChild(document.createTextNode(css)); export {css}; -` +` : '' export function makeModule(contents: string, type: Type, nonce?: string):string { switch (type) {