Skip to content

Commit

Permalink
fix: start rewriting event attributes again
Browse files Browse the repository at this point in the history
  • Loading branch information
Percslol committed Nov 10, 2024
1 parent d79811d commit 21a112b
Showing 1 changed file with 112 additions and 0 deletions.
112 changes: 112 additions & 0 deletions src/shared/rewriters/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ function traverseParsedHtml(
}
}
}
for (const [attr, value] of Object.entries(node.attribs)) {
if (eventAttributes.includes(attr)) {
node.attribs[`data-scramjet-${attr}`] = attr;
node.attribs[attr] = rewriteJs(
value as string,
`(inline ${attr} on element)`,
meta
);
}
}
}

if (node.name === "style" && node.children[0] !== undefined)
Expand Down Expand Up @@ -299,3 +309,105 @@ function bytesToBase64(bytes: Uint8Array) {

return btoa(binString);
}
const eventAttributes = [
"onbeforexrselect",
"onabort",
"onbeforeinput",
"onbeforematch",
"onbeforetoggle",
"onblur",
"oncancel",
"oncanplay",
"oncanplaythrough",
"onchange",
"onclick",
"onclose",
"oncontentvisibilityautostatechange",
"oncontextlost",
"oncontextmenu",
"oncontextrestored",
"oncuechange",
"ondblclick",
"ondrag",
"ondragend",
"ondragenter",
"ondragleave",
"ondragover",
"ondragstart",
"ondrop",
"ondurationchange",
"onemptied",
"onended",
"onerror",
"onfocus",
"onformdata",
"oninput",
"oninvalid",
"onkeydown",
"onkeypress",
"onkeyup",
"onload",
"onloadeddata",
"onloadedmetadata",
"onloadstart",
"onmousedown",
"onmouseenter",
"onmouseleave",
"onmousemove",
"onmouseout",
"onmouseover",
"onmouseup",
"onmousewheel",
"onpause",
"onplay",
"onplaying",
"onprogress",
"onratechange",
"onreset",
"onresize",
"onscroll",
"onsecuritypolicyviolation",
"onseeked",
"onseeking",
"onselect",
"onslotchange",
"onstalled",
"onsubmit",
"onsuspend",
"ontimeupdate",
"ontoggle",
"onvolumechange",
"onwaiting",
"onwebkitanimationend",
"onwebkitanimationiteration",
"onwebkitanimationstart",
"onwebkittransitionend",
"onwheel",
"onauxclick",
"ongotpointercapture",
"onlostpointercapture",
"onpointerdown",
"onpointermove",
"onpointerrawupdate",
"onpointerup",
"onpointercancel",
"onpointerover",
"onpointerout",
"onpointerenter",
"onpointerleave",
"onselectstart",
"onselectionchange",
"onanimationend",
"onanimationiteration",
"onanimationstart",
"ontransitionrun",
"ontransitionstart",
"ontransitionend",
"ontransitioncancel",
"oncopy",
"oncut",
"onpaste",
"onscrollend",
"onscrollsnapchange",
"onscrollsnapchanging",
];

0 comments on commit 21a112b

Please sign in to comment.