diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index d915f14..5aad4c7 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -26,9 +26,9 @@ jobs:
node-version: "18"
- name: Setup pnpm
- uses: pnpm/action-setup@v2.2.4
+ uses: pnpm/action-setup@v4
with:
- version: 7
+ version: latest
- name: Install dependencies
run: pnpm install
diff --git a/src/modules/pageIcons/pageIcons.ts b/src/modules/pageIcons/pageIcons.ts
index 2bd51c5..f757df8 100644
--- a/src/modules/pageIcons/pageIcons.ts
+++ b/src/modules/pageIcons/pageIcons.ts
@@ -1,7 +1,7 @@
import fastdom from 'fastdom'
import { body, doc, globals, propsObject, root } from '../globals';
-import { settingsTextToPropsObj, isNeedLowContrastFix, isEmoji, injectPluginCSS, ejectPluginCSS } from '../utils';
+import { settingsTextToPropsObj, isNeedLowContrastFix, isEmoji, injectPluginCSS, ejectPluginCSS, htmlToElement } from '../utils';
import { getPropsByPageName } from './queries';
import pageIconsStyles from './pageIcons.css?inline';
@@ -129,11 +129,13 @@ const setIconToLinkItem = async (linkItem: HTMLElement, pageProps: propsObject,
return;
}
if (pageIcon && pageIcon !== 'none') {
-
const oldPageIcon = linkItem.querySelector('.awLi-icon');
oldPageIcon && oldPageIcon.remove();
hideTitle(linkItem, pageProps);
- linkItem.insertAdjacentHTML('afterbegin', `${pageIcon}`);
+
+ const iconNode = htmlToElement(`${pageIcon}`);
+ const lastNode = linkItem.childNodes[linkItem.childNodes.length - 1];
+ linkItem.insertBefore(iconNode, lastNode);
}
}
diff --git a/src/modules/utils.ts b/src/modules/utils.ts
index acd44db..9f1a5d0 100644
--- a/src/modules/utils.ts
+++ b/src/modules/utils.ts
@@ -103,3 +103,13 @@ export const ejectPluginCSS = (iframeId: string, label: string) => {
}
pluginIframe.contentDocument?.getElementById(label)?.remove();
}
+
+/**
+ * source: https://stackoverflow.com/a/35385518/7662783
+ */
+export function htmlToElement(html: string): ChildNode {
+ const template = document.createElement('template');
+ html = html.trim(); // Never return a text node of whitespace as the result
+ template.innerHTML = html;
+ return template.content.firstChild as ChildNode;
+}