From f4aa3a2f0d0d9b98bb889ede5c27542393c85fd5 Mon Sep 17 00:00:00 2001 From: Adam LaCombe Date: Thu, 11 Jun 2020 23:13:41 +0800 Subject: [PATCH] 1.0.3 --- .gitignore | 7 ++++++- .npmignore | 2 ++ dist/index.d.ts | 1 - dist/index.js | 1 - dist/index.js.map | 1 - package.json | 2 +- 6 files changed, 9 insertions(+), 5 deletions(-) delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map diff --git a/.gitignore b/.gitignore index aecfe24..d4f5bba 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,9 @@ # Dependency directories node_modules/ -.rpt2_cache \ No newline at end of file +.rpt2_cache + +dist/ +.history/ + +.vscode/ diff --git a/.npmignore b/.npmignore index bbe4f03..83c5dd0 100644 --- a/.npmignore +++ b/.npmignore @@ -1,3 +1,5 @@ .rpt2_cache +.vscode +.history rollup.config.js src \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index 95d57e0..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function injectStyles(shadowRootElement: HTMLElement, insertBeforeSelector: string, styles: string): void; diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index d93e543..0000000 --- a/dist/index.js +++ /dev/null @@ -1 +0,0 @@ -function injectStyles(e,t,n){const o=e.shadowRoot;let r=!1;const c=Array.from(o.querySelectorAll("style"));c.forEach((e,l)=>{if(e.innerHTML===n&&(r=!0),c.length-1===l&&!1===r){const e=document.createElement("style");e.innerHTML=n,o.insertBefore(e,o.querySelector(t))}})}export{injectStyles}; \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 9d0f46d..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export function injectStyles(\n shadowRootElement: HTMLElement,\n insertBeforeSelector: string,\n styles: string\n) {\n const root = shadowRootElement.shadowRoot;\n let styleAlreadyAdded = false;\n const currentStyleTags = Array.from(root.querySelectorAll('style'));\n currentStyleTags.forEach((element: HTMLStyleElement, index) => {\n if (element.innerHTML === styles) {\n styleAlreadyAdded = true;\n }\n if (currentStyleTags.length - 1 === index && styleAlreadyAdded === false) {\n const newStyleTag = document.createElement('style');\n newStyleTag.innerHTML = styles;\n root.insertBefore(newStyleTag, root.querySelector(insertBeforeSelector));\n }\n });\n}\n"],"names":[],"mappings":"sBACE,iBAA8B,EAC9B,oBAA4B,EAC5B,MAAc;IAEd,MAAM,IAAI,GAAG,iBAAiB,CAAC,UAAU,CAAC;IAC1C,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAC9B,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACpE,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAyB,EAAE,KAAK;QACxD,IAAI,OAAO,CAAC,SAAS,KAAK,MAAM,EAAE;YAChC,iBAAiB,GAAG,IAAI,CAAC;SAC1B;QACD,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,KAAK,KAAK,IAAI,iBAAiB,KAAK,KAAK,EAAE;YACxE,MAAM,WAAW,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACpD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;YAC/B,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAC;SAC1E;KACF,CAAC,CAAC;CACJ;;;;"} \ No newline at end of file diff --git a/package.json b/package.json index 03b2bb7..402473e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shadow-dom-inject-styles", - "version": "1.0.2", + "version": "1.0.3", "description": "A helper function to easily modify shadow dom css.", "module": "./dist/index.js", "main": "./dist/index.js",