mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
clipper: remove valid attributes check
Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
@@ -176,39 +176,9 @@ function makeSvgDataUri(node: HTMLElement, width: number, height: number) {
|
||||
|
||||
export { toJpeg, toBlob, toCanvas, toPixelData, toPng, toSvg, getInlinedNode };
|
||||
|
||||
const VALID_ATTRIBUTES = [
|
||||
"src",
|
||||
"href",
|
||||
"title",
|
||||
"style",
|
||||
"srcset",
|
||||
"sizes",
|
||||
"width",
|
||||
"height",
|
||||
"target",
|
||||
"rel",
|
||||
"class",
|
||||
"id",
|
||||
"disabled",
|
||||
"type",
|
||||
"data-",
|
||||
"aria-"
|
||||
];
|
||||
|
||||
function finalize(root: HTMLElement) {
|
||||
for (const element of root.querySelectorAll("*")) {
|
||||
if (!(element instanceof HTMLElement) || isSVGElement(element)) continue;
|
||||
for (const attribute of Array.from(element.attributes)) {
|
||||
if (attribute.name === "class" && element.className.includes("pseudo--"))
|
||||
continue;
|
||||
|
||||
const isValidAttribute = VALID_ATTRIBUTES.some((attr) =>
|
||||
attribute.name.startsWith(attr)
|
||||
);
|
||||
if (!isValidAttribute) {
|
||||
element.removeAttribute(attribute.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (element instanceof HTMLAnchorElement) {
|
||||
element.href = element.href.startsWith("http")
|
||||
|
||||
Reference in New Issue
Block a user