add tslint config

This commit is contained in:
Adam LaCombe 2018-12-04 09:18:12 -05:00
parent 08338dce5f
commit bcd40dddaa
5 changed files with 17 additions and 4 deletions

2
dist/index.d.ts vendored
View File

@ -1 +1 @@
export declare function injectStyles(shadowRootElement: HTMLElement, insertBeforeSelector: string, styles: string): void;
export declare function injectStyles(shadowRootElement: HTMLElement, insertBeforeSelector: string, styles: string): void;

2
dist/index.js vendored
View File

@ -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};
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};

2
dist/index.js.map vendored
View File

@ -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;;;;"}
{"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;;;;"}

View File

@ -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));

13
tslint.json Normal file
View File

@ -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
}
}