diff --git a/dist/index.d.ts b/dist/index.d.ts index 0d95d4f..95d57e0 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1 +1 @@ -export declare function injectStyles(shadowRootElement: HTMLElement, insertBeforeSelector: string, styles: string): void; +export declare function injectStyles(shadowRootElement: HTMLElement, insertBeforeSelector: string, styles: string): void; diff --git a/dist/index.js b/dist/index.js index ec55cb6..d93e543 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -function injectStyles(e,t,r){let l=e.shadowRoot,n=!1,o=Array.from(l.querySelectorAll("style"));o.forEach((e,c)=>{if(e.innerHTML==r&&(n=!0),o.length-1==c&&0==n){let e=document.createElement("style");e.innerHTML=r,l.insertBefore(e,l.querySelector(t))}})}export{injectStyles}; \ No newline at end of file +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 index 55128d6..9d0f46d 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export function injectStyles(shadowRootElement: HTMLElement, insertBeforeSelector: string, styles: string) {\n\tlet root = shadowRootElement.shadowRoot;\n\tlet styleAlreadyAdded = false;\n\tlet currentStyleTags = Array.from(root.querySelectorAll('style'));\n\tcurrentStyleTags.forEach((element: HTMLStyleElement, index) => {\n\t\tif (element.innerHTML == styles) {\n\t\t\tstyleAlreadyAdded = true;\n\t\t}\n\t\tif ((currentStyleTags.length - 1) == index && styleAlreadyAdded == false) {\n\t\t\tlet newStyleTag = document.createElement('style');\n\t\t\tnewStyleTag.innerHTML = styles;\n\t\t\troot.insertBefore(newStyleTag, root.querySelector(insertBeforeSelector));\n\t\t}\n\t});\n}"],"names":[],"mappings":"sBAA6B,iBAA8B,EAAE,oBAA4B,EAAE,MAAc;IACxG,IAAI,IAAI,GAAgB,iBAAiB,CAAC,UAAU,CAAC;IACrD,IAAI,iBAAiB,GAAG,KAAK,CAAC;IAC9B,IAAI,gBAAgB,GAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IACnE,gBAAgB,CAAC,OAAO,CAAC,CAAC,OAAyB,EAAE,KAAK;QACzD,IAAI,OAAO,CAAC,SAAS,IAAI,MAAM,EAAE;YAChC,iBAAiB,GAAG,IAAI,CAAC;SACzB;QACD,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,KAAK,KAAK,IAAI,iBAAiB,IAAI,KAAK,EAAE;YACzE,IAAI,WAAW,GAAS,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACxD,WAAW,CAAC,SAAS,GAAG,MAAM,CAAC;YAC/B,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC,CAAC;SACzE;KACD,CAAC,CAAC;CACH;;;;"} \ No newline at end of file +{"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/src/index.ts b/src/index.ts index 2d7fb2e..f7bd969 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,7 +10,7 @@ export function injectStyles( if (element.innerHTML === styles) { styleAlreadyAdded = true; } - if (currentStyleTags.length - 1 === index && styleAlreadyAdded == false) { + if (currentStyleTags.length - 1 === index && styleAlreadyAdded === false) { const newStyleTag = document.createElement('style'); newStyleTag.innerHTML = styles; root.insertBefore(newStyleTag, root.querySelector(insertBeforeSelector)); diff --git a/tslint.json b/tslint.json new file mode 100644 index 0000000..d274ef0 --- /dev/null +++ b/tslint.json @@ -0,0 +1,13 @@ +{ + "extends": "tslint-ionic-rules", + "rules": { + "ban-comma-operator": false, + "no-empty": [true, "allow-empty-catch"], + "no-floating-promises": true, + "no-import-side-effect": false, + "no-var-keyword": false, + "no-var-requires": false, + "prefer-conditional-expression": false, + "linebreak-style": false + } +}