mirror of
https://gitee.com/shuto-github/Shadow-DOM-inject-styles.git
synced 2024-10-06 04:02:06 +08:00
1.0.3
This commit is contained in:
parent
a4cf9d9c33
commit
f4aa3a2f0d
7
.gitignore
vendored
7
.gitignore
vendored
@ -4,4 +4,9 @@
|
|||||||
# Dependency directories
|
# Dependency directories
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
.rpt2_cache
|
.rpt2_cache
|
||||||
|
|
||||||
|
dist/
|
||||||
|
.history/
|
||||||
|
|
||||||
|
.vscode/
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
.rpt2_cache
|
.rpt2_cache
|
||||||
|
.vscode
|
||||||
|
.history
|
||||||
rollup.config.js
|
rollup.config.js
|
||||||
src
|
src
|
1
dist/index.d.ts
vendored
1
dist/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export declare function injectStyles(shadowRootElement: HTMLElement, insertBeforeSelector: string, styles: string): void;
|
|
1
dist/index.js
vendored
1
dist/index.js
vendored
@ -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};
|
|
1
dist/index.js.map
vendored
1
dist/index.js.map
vendored
@ -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;;;;"}
|
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "shadow-dom-inject-styles",
|
"name": "shadow-dom-inject-styles",
|
||||||
"version": "1.0.2",
|
"version": "1.0.3",
|
||||||
"description": "A helper function to easily modify shadow dom css.",
|
"description": "A helper function to easily modify shadow dom css.",
|
||||||
"module": "./dist/index.js",
|
"module": "./dist/index.js",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user