diff --git a/src/core/action.ts b/src/core/action.ts index e009399b..5828dafd 100644 --- a/src/core/action.ts +++ b/src/core/action.ts @@ -28,7 +28,7 @@ export class Action { this.eventName = descriptor.eventName || getDefaultEventNameForElement(element) || error("missing event name") this.eventOptions = descriptor.eventOptions || {} this.identifier = descriptor.identifier || error("missing identifier") - this.methodName = descriptor.methodName || error("missing method name") + this.methodName = descriptor.methodName || "_" this.keyFilter = descriptor.keyFilter || "" this.schema = schema } diff --git a/src/core/action_descriptor.ts b/src/core/action_descriptor.ts index 35a4a211..ca694e18 100644 --- a/src/core/action_descriptor.ts +++ b/src/core/action_descriptor.ts @@ -42,7 +42,7 @@ export interface ActionDescriptor { } // capture nos.: 1 1 2 2 3 3 4 4 5 5 6 6 7 7 -const descriptorPattern = /^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/ +const descriptorPattern = /^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)?(?:#([^:]+?))?(?::(.+))?$/ export function parseActionDescriptorString(descriptorString: string): Partial { const source = descriptorString.trim() diff --git a/src/tests/controllers/log_controller.ts b/src/tests/controllers/log_controller.ts index 2468b22c..38cc7546 100644 --- a/src/tests/controllers/log_controller.ts +++ b/src/tests/controllers/log_controller.ts @@ -30,6 +30,10 @@ export class LogController extends Controller { this.disconnectCount++ } + _(event: ActionEvent) { + this.recordAction("default", event) + } + log(event: ActionEvent) { this.recordAction("log", event) } diff --git a/src/tests/modules/core/action_tests.ts b/src/tests/modules/core/action_tests.ts index 4e3c7718..91ad4e0b 100644 --- a/src/tests/modules/core/action_tests.ts +++ b/src/tests/modules/core/action_tests.ts @@ -5,6 +5,7 @@ export default class ActionTests extends LogControllerTestCase { fixtureHTML = `
+
@@ -21,6 +22,11 @@ export default class ActionTests extends LogControllerTestCase { this.assertActions({ name: "log", eventType: "click" }) } + async "test default method"() { + await this.triggerEvent("#default", "click") + this.assertActions({ name: "default", eventType: "click" }) + } + async "test bubbling events"() { await this.triggerEvent("span", "click") this.assertActions({ eventType: "click", currentTarget: this.findElement("button") })