diff options
| author | Akshay Nair <phenax5@gmail.com> | 2023-08-11 19:25:17 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2023-08-11 19:25:17 +0530 |
| commit | 6aec6197fbd916c2930813b46b07e726803993f0 (patch) | |
| tree | 2166acaa80cc3ae358b4abb4e20d51546f2438af /src/index.ts | |
| parent | 952256ae8bf5514a246db8f33bef207f5747b138 (diff) | |
| download | css-everything-6aec6197fbd916c2930813b46b07e726803993f0.tar.gz css-everything-6aec6197fbd916c2930813b46b07e726803993f0.zip | |
refactor: minor refactor
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/index.ts b/src/index.ts index 9e9443c..2d6e9b8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -39,25 +39,26 @@ const getEvalActions = ($element: Element): EvalActions => ({ document.getElementById(id)?.classList.remove(cls), delay: (delay) => new Promise((res) => setTimeout(res, delay)), jsEval: async (js) => (0, eval)(js), - loadCssx: async (id, url) => new Promise((resolve, reject) => { - const $link = Object.assign(document.createElement('link'), { - href: url, - rel: 'stylesheet', - }) - $link.onload = () => { - const $el = document.getElementById(id); - // NOTE: Maybe create and append to body if no root? - if ($el) { - manageElement($el) - resolve(id) - } else { - console.error(`[CSSX] Unable to find root for ${id}`) - reject(`[CSSX] Unable to find root for ${id}`) + loadCssx: async (id, url) => + new Promise((resolve, reject) => { + const $link = Object.assign(document.createElement('link'), { + href: url, + rel: 'stylesheet', + }) + $link.onload = () => { + const $el = document.getElementById(id) + // NOTE: Maybe create and append to body if no root? + if ($el) { + manageElement($el) + resolve(id) + } else { + console.error(`[CSSX] Unable to find root for ${id}`) + reject(`[CSSX] Unable to find root for ${id}`) + } } - } - document.body.appendChild($link); - }), - getVariable: async varName => getPropertyValue($element, varName), + document.body.appendChild($link) + }), + getVariable: async (varName) => getPropertyValue($element, varName), updateVariable: async (targetId, varName, value) => { const $el = document.getElementById(targetId) if ($el) { |
