feat: replace JS card-link data-href with CSS overlay and add DOMPurify sanitizer
This commit is contained in:
@@ -969,3 +969,20 @@ img {
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
}
|
||||
|
||||
.card-link-host {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.card-link {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.card-link-host a:not(.card-link),
|
||||
.card-link-host button,
|
||||
.card-link-host form {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ export class DomUtils {
|
||||
this.initShareButtons();
|
||||
this.initTogglers();
|
||||
this.initStopPropagation();
|
||||
this.initCardLinks();
|
||||
}
|
||||
|
||||
initClipboardCopy() {
|
||||
@@ -54,14 +53,4 @@ export class DomUtils {
|
||||
el.addEventListener("click", (e) => e.stopPropagation());
|
||||
});
|
||||
}
|
||||
|
||||
initCardLinks() {
|
||||
document.querySelectorAll("[data-href]").forEach((el) => {
|
||||
el.addEventListener("click", (e) => {
|
||||
if (e.target.closest("[data-stop-propagation]")) return;
|
||||
const href = el.dataset.href;
|
||||
if (href) window.location.href = href;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,8 @@
|
||||
import { Http } from "./Http.js";
|
||||
|
||||
export class NotificationManager {
|
||||
constructor() {
|
||||
this.initCardNavigation();
|
||||
this.initDismiss();
|
||||
this.initHashScroll();
|
||||
}
|
||||
|
||||
initCardNavigation() {
|
||||
document.querySelectorAll(".notification-card[data-href]").forEach((card) => {
|
||||
card.addEventListener("click", (e) => {
|
||||
if (e.target.closest("a, button")) {
|
||||
return;
|
||||
}
|
||||
window.location.href = card.dataset.href;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
initDismiss() {
|
||||
document.querySelectorAll(".notification-dismiss").forEach((btn) => {
|
||||
btn.addEventListener("click", (e) => {
|
||||
e.preventDefault();
|
||||
const uid = btn.dataset.uid;
|
||||
if (!uid) {
|
||||
return;
|
||||
}
|
||||
Http.postForm(`/notifications/mark-read/${uid}`);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
initHashScroll() {
|
||||
const hash = window.location.hash;
|
||||
if (!hash.startsWith("#comment-")) {
|
||||
|
||||
+3
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user