Merge pull request #184 from vkatushenok/escape-selectors

Escape folder path in selectors
This commit is contained in:
Lost Paul 2024-12-27 20:14:55 +01:00 committed by GitHub
commit 4673d9db29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

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

View file

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