mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-20 21:49:32 +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 };
|
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) {
|
function finalize(root: HTMLElement) {
|
||||||
for (const element of root.querySelectorAll("*")) {
|
for (const element of root.querySelectorAll("*")) {
|
||||||
if (!(element instanceof HTMLElement) || isSVGElement(element)) continue;
|
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) {
|
if (element instanceof HTMLAnchorElement) {
|
||||||
element.href = element.href.startsWith("http")
|
element.href = element.href.startsWith("http")
|
||||||
|
|||||||
Reference in New Issue
Block a user