In EventNameList.h, we list some events solely so that `setAttribute("onblah", "...")` isn't rejected:
https://searchfox.org/mozilla-central/rev/3c7b40d1d74c26a82486f38b5828c3f3a43e05da/dom/events/EventNameList.h#529-542
```cpp
#ifndef MESSAGE_TO_EVENT
// These are only here so that IsEventAttributeName() will return the right
// thing for these events. We could probably remove them if we used
// Element::GetEventNameForAttr on the input to IsEventAttributeName before
// looking it up in the hashtable...
EVENT(webkitanimationend, eUnidentifiedEvent, EventNameType_All,
eAnimationEventClass)
EVENT(webkitanimationiteration, eUnidentifiedEvent, EventNameType_All,
eAnimationEventClass)
EVENT(webkitanimationstart, eUnidentifiedEvent, EventNameType_All,
eAnimationEventClass)
EVENT(webkittransitionend, eUnidentifiedEvent, EventNameType_All,
eTransitionEventClass)
#endif
```
https://searchfox.org/mozilla-central/rev/3c7b40d1d74c26a82486f38b5828c3f3a43e05da/dom/html/nsGenericHTMLElement.cpp#720-724
```cpp
if (IsEventAttributeName(aName) && aValue) {
MOZ_ASSERT(aValue->Type() == nsAttrValue::eString,
"Expected string value for script body");
SetEventHandler(GetEventNameForAttr(aName), aValue->GetStringValue());
} else if (aNotify && aName == nsGkAtoms::spellcheck) {
```
This bug is for making the change suggested in the comment: First, check if the attribute name starts with "on". If it does, call `GetEventNameForAttr` to map it to an event name. Then, call `IsEventAttributeName`, which at that point it should be renamed to `IsEventTypeAtom`.
This pattern is used in a bunch of different places.
Bug 1845422 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
In EventNameList.h, we list some events solely so that `setAttribute("onblah", "...")` isn't rejected:
https://searchfox.org/mozilla-central/rev/3c7b40d1d74c26a82486f38b5828c3f3a43e05da/dom/events/EventNameList.h#529-542
```cpp
#ifndef MESSAGE_TO_EVENT
// These are only here so that IsEventAttributeName() will return the right
// thing for these events. We could probably remove them if we used
// Element::GetEventNameForAttr on the input to IsEventAttributeName before
// looking it up in the hashtable...
EVENT(webkitanimationend, eUnidentifiedEvent, EventNameType_All,
eAnimationEventClass)
EVENT(webkitanimationiteration, eUnidentifiedEvent, EventNameType_All,
eAnimationEventClass)
EVENT(webkitanimationstart, eUnidentifiedEvent, EventNameType_All,
eAnimationEventClass)
EVENT(webkittransitionend, eUnidentifiedEvent, EventNameType_All,
eTransitionEventClass)
#endif
```
https://searchfox.org/mozilla-central/rev/3c7b40d1d74c26a82486f38b5828c3f3a43e05da/dom/html/nsGenericHTMLElement.cpp#714-724
```cpp
void nsGenericHTMLElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
const nsAttrValue* aValue,
const nsAttrValue* aOldValue,
nsIPrincipal* aMaybeScriptedPrincipal,
bool aNotify) {
if (aNamespaceID == kNameSpaceID_None) {
if (IsEventAttributeName(aName) && aValue) {
MOZ_ASSERT(aValue->Type() == nsAttrValue::eString,
"Expected string value for script body");
SetEventHandler(GetEventNameForAttr(aName), aValue->GetStringValue());
} else if (aNotify && aName == nsGkAtoms::spellcheck) {
```
This bug is for making the change suggested in the comment: First, check if the attribute name starts with "on". If it does, call `GetEventNameForAttr` to map it to an event name. Then, call `IsEventAttributeName`, which at that point it should be renamed to `IsEventTypeAtom`.
This pattern is used in a bunch of different places.
In EventNameList.h, we list some events solely so that `<div onblah"="...">` passes the "attribute is event handler" check: https://searchfox.org/mozilla-central/rev/3c7b40d1d74c26a82486f38b5828c3f3a43e05da/dom/events/EventNameList.h#529-542 ```cpp #ifndef MESSAGE_TO_EVENT // These are only here so that IsEventAttributeName() will return the right // thing for these events. We could probably remove them if we used // Element::GetEventNameForAttr on the input to IsEventAttributeName before // looking it up in the hashtable... EVENT(webkitanimationend, eUnidentifiedEvent, EventNameType_All, eAnimationEventClass) EVENT(webkitanimationiteration, eUnidentifiedEvent, EventNameType_All, eAnimationEventClass) EVENT(webkitanimationstart, eUnidentifiedEvent, EventNameType_All, eAnimationEventClass) EVENT(webkittransitionend, eUnidentifiedEvent, EventNameType_All, eTransitionEventClass) #endif ``` https://searchfox.org/mozilla-central/rev/3c7b40d1d74c26a82486f38b5828c3f3a43e05da/dom/html/nsGenericHTMLElement.cpp#714-724 ```cpp void nsGenericHTMLElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { if (IsEventAttributeName(aName) && aValue) { MOZ_ASSERT(aValue->Type() == nsAttrValue::eString, "Expected string value for script body"); SetEventHandler(GetEventNameForAttr(aName), aValue->GetStringValue()); } else if (aNotify && aName == nsGkAtoms::spellcheck) { ``` This bug is for making the change suggested in the comment: First, check if the attribute name starts with "on". If it does, call `GetEventNameForAttr` to map it to an event name. Then, call `IsEventAttributeName`, which at that point it should be renamed to `IsEventTypeAtom`. This pattern is used in a bunch of different places.
In EventNameList.h, we list some events solely so that `<div onblah="...">` passes the "attribute is event handler" check: https://searchfox.org/mozilla-central/rev/3c7b40d1d74c26a82486f38b5828c3f3a43e05da/dom/events/EventNameList.h#529-542 ```cpp #ifndef MESSAGE_TO_EVENT // These are only here so that IsEventAttributeName() will return the right // thing for these events. We could probably remove them if we used // Element::GetEventNameForAttr on the input to IsEventAttributeName before // looking it up in the hashtable... EVENT(webkitanimationend, eUnidentifiedEvent, EventNameType_All, eAnimationEventClass) EVENT(webkitanimationiteration, eUnidentifiedEvent, EventNameType_All, eAnimationEventClass) EVENT(webkitanimationstart, eUnidentifiedEvent, EventNameType_All, eAnimationEventClass) EVENT(webkittransitionend, eUnidentifiedEvent, EventNameType_All, eTransitionEventClass) #endif ``` https://searchfox.org/mozilla-central/rev/3c7b40d1d74c26a82486f38b5828c3f3a43e05da/dom/html/nsGenericHTMLElement.cpp#714-724 ```cpp void nsGenericHTMLElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { if (IsEventAttributeName(aName) && aValue) { MOZ_ASSERT(aValue->Type() == nsAttrValue::eString, "Expected string value for script body"); SetEventHandler(GetEventNameForAttr(aName), aValue->GetStringValue()); } else if (aNotify && aName == nsGkAtoms::spellcheck) { ``` This bug is for making the change suggested in the comment: First, check if the attribute name starts with "on". If it does, call `GetEventNameForAttr` to map it to an event name. Then, call `IsEventAttributeName`, which at that point it should be renamed to `IsEventTypeAtom`. This pattern is used in a bunch of different places.