diff --git a/src/folderOverview/FolderOverview.ts b/src/folderOverview/FolderOverview.ts index c11c18d..551287a 100644 --- a/src/folderOverview/FolderOverview.ts +++ b/src/folderOverview/FolderOverview.ts @@ -409,7 +409,7 @@ export class FolderOverview { } getElFromOverview(path: string): HTMLElement | null { - const el = this.listEl.querySelector(`[data-path="${path}"]`) as HTMLElement | null; + const el = this.listEl.querySelector(`[data-path="${CSS.escape(path)}"]`) as HTMLElement | null; return el; } @@ -464,4 +464,4 @@ class CustomMarkdownRenderChild extends MarkdownRenderChild { onunload() { this.folderOverview.disconnectListeners(); } -} \ No newline at end of file +} diff --git a/src/functions/styleFunctions.ts b/src/functions/styleFunctions.ts index 4cdaf87..b5526b5 100644 --- a/src/functions/styleFunctions.ts +++ b/src/functions/styleFunctions.ts @@ -125,7 +125,7 @@ export async function addCSSClassToTitleEL(path: string, cssClass: string, plugi return; } fileExplorerItem.addClass(cssClass); - const viewHeaderItems = document.querySelectorAll(`[data-path="${path}"]`); + const viewHeaderItems = document.querySelectorAll(`[data-path="${CSS.escape(path)}"]`); viewHeaderItems.forEach((item) => { item.addClass(cssClass); }); @@ -134,7 +134,7 @@ export async function addCSSClassToTitleEL(path: string, cssClass: string, plugi export function removeCSSClassFromEL(path: string | undefined, cssClass: string, plugin: FolderNotesPlugin) { if (!path) return; const fileExplorerItem = getEl(path, plugin); - const viewHeaderItems = document.querySelectorAll(`[data-path="${path}"]`); + const viewHeaderItems = document.querySelectorAll(`[data-path="${CSS.escape(path)}"]`); viewHeaderItems.forEach((item) => { item.removeClass(cssClass); }); @@ -151,4 +151,4 @@ export function getEl(path: string, plugin: FolderNotesPlugin): HTMLElement | nu if (!fileExplorerItem) { return null; } if (fileExplorerItem.selfEl) return fileExplorerItem.selfEl; return fileExplorerItem.titleEl; -} \ No newline at end of file +}