diff --git a/package.json b/package.json index 958540d..c47d17a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.1.8", + "version": "0.1.9", "name": "react-phone-hooks", "description": "React hooks and utility functions for parsing and validating phone numbers.", "keywords": [ diff --git a/src/styles.ts b/src/styles.ts index 1921545..08f67e0 100644 --- a/src/styles.ts +++ b/src/styles.ts @@ -11,14 +11,17 @@ export const jsonToCss = (stylesheet: object) => { export const injectStyles = (cssText: string) => { /** Inject the given `cssText` in the document head */ - const style = document.createElement("style"); - style.setAttribute("type", "text/css"); + try { + const style = document.createElement("style"); + style.setAttribute("type", "text/css"); - if ((style as any).styleSheet) { - (style as any).styleSheet.cssText = cssText; - } else { - style.appendChild(document.createTextNode(cssText)); - } + if ((style as any).styleSheet) { + (style as any).styleSheet.cssText = cssText; + } else { + style.appendChild(document.createTextNode(cssText)); + } - document.head.appendChild(style); + document.head.appendChild(style); + } catch (err) { + } }