monolith/
js.rs

1const JS_DOM_EVENT_ATTRS: &[&str] = &[
2    // From WHATWG HTML spec 8.1.5.2 "Event handlers on elements, Document objects, and Window objects":
3    //   https://html.spec.whatwg.org/#event-handlers-on-elements,-document-objects,-and-window-objects
4    //   https://html.spec.whatwg.org/#attributes-3 (table "List of event handler content attributes")
5
6    // Global event handlers
7    "onabort",
8    "onauxclick",
9    "onblur",
10    "oncancel",
11    "oncanplay",
12    "oncanplaythrough",
13    "onchange",
14    "onclick",
15    "onclose",
16    "oncontextmenu",
17    "oncuechange",
18    "ondblclick",
19    "ondrag",
20    "ondragend",
21    "ondragenter",
22    "ondragexit",
23    "ondragleave",
24    "ondragover",
25    "ondragstart",
26    "ondrop",
27    "ondurationchange",
28    "onemptied",
29    "onended",
30    "onerror",
31    "onfocus",
32    "onformdata",
33    "oninput",
34    "oninvalid",
35    "onkeydown",
36    "onkeypress",
37    "onkeyup",
38    "onload",
39    "onloadeddata",
40    "onloadedmetadata",
41    "onloadstart",
42    "onmousedown",
43    "onmouseenter",
44    "onmouseleave",
45    "onmousemove",
46    "onmouseout",
47    "onmouseover",
48    "onmouseup",
49    "onwheel",
50    "onpause",
51    "onplay",
52    "onplaying",
53    "onprogress",
54    "onratechange",
55    "onreset",
56    "onresize",
57    "onscroll",
58    "onsecuritypolicyviolation",
59    "onseeked",
60    "onseeking",
61    "onselect",
62    "onslotchange",
63    "onstalled",
64    "onsubmit",
65    "onsuspend",
66    "ontimeupdate",
67    "ontoggle",
68    "onvolumechange",
69    "onwaiting",
70    "onwebkitanimationend",
71    "onwebkitanimationiteration",
72    "onwebkitanimationstart",
73    "onwebkittransitionend",
74    // Event handlers for <body/> and <frameset/> elements
75    "onafterprint",
76    "onbeforeprint",
77    "onbeforeunload",
78    "onhashchange",
79    "onlanguagechange",
80    "onmessage",
81    "onmessageerror",
82    "onoffline",
83    "ononline",
84    "onpagehide",
85    "onpageshow",
86    "onpopstate",
87    "onrejectionhandled",
88    "onstorage",
89    "onunhandledrejection",
90    "onunload",
91    // Event handlers for <html/> element
92    "oncut",
93    "oncopy",
94    "onpaste",
95];
96
97// Returns true if DOM attribute name matches a native JavaScript event handler
98pub fn attr_is_event_handler(attr_name: &str) -> bool {
99    JS_DOM_EVENT_ATTRS
100        .iter()
101        .any(|a| attr_name.eq_ignore_ascii_case(a))
102}