diff --git a/src/core/action.ts b/src/core/action.ts
index 3350ea84..a0209176 100644
--- a/src/core/action.ts
+++ b/src/core/action.ts
@@ -96,6 +96,14 @@ const defaultEventNames: { [tagName: string]: (element: Element) => string } = {
textarea: () => "input",
}
+export function registerDefaultEventName(tagName: string, eventName: string | ((element: Element) => string)) {
+ if (typeof eventName === 'string') {
+ defaultEventNames[tagName] = () => eventName
+ } else {
+ defaultEventNames[tagName] = eventName
+ }
+}
+
export function getDefaultEventNameForElement(element: Element): string | undefined {
const tagName = element.tagName.toLowerCase()
if (tagName in defaultEventNames) {
diff --git a/src/core/index.ts b/src/core/index.ts
index 7fa3ec6b..82d48223 100644
--- a/src/core/index.ts
+++ b/src/core/index.ts
@@ -1,3 +1,4 @@
+export { registerDefaultEventName } from "./action"
export { ActionEvent } from "./action_event"
export { Application } from "./application"
export { Context } from "./context"
diff --git a/src/tests/modules/core/action_tests.ts b/src/tests/modules/core/action_tests.ts
index 4e3c7718..919173aa 100644
--- a/src/tests/modules/core/action_tests.ts
+++ b/src/tests/modules/core/action_tests.ts
@@ -1,5 +1,9 @@
+import { registerDefaultEventName } from "../../../core"
import { LogControllerTestCase } from "../../cases/log_controller_test_case"
+// must be done before the fixture element is constructed
+registerDefaultEventName('some-element', 'click')
+
export default class ActionTests extends LogControllerTestCase {
identifier = "c"
fixtureHTML = `
@@ -14,6 +18,7 @@ export default class ActionTests extends LogControllerTestCase {
+ Hm
`
async "test default event"() {
@@ -21,6 +26,11 @@ export default class ActionTests extends LogControllerTestCase {
this.assertActions({ name: "log", eventType: "click" })
}
+ async "test default event on custom element"() {
+ await this.triggerEvent("some-element", "click")
+ this.assertActions({ name: "log", eventType: "click" })
+ }
+
async "test bubbling events"() {
await this.triggerEvent("span", "click")
this.assertActions({ eventType: "click", currentTarget: this.findElement("button") })