diff --git a/lib/core_dom/event_handler.dart b/lib/core_dom/event_handler.dart index b47fb59b7..629daecec 100644 --- a/lib/core_dom/event_handler.dart +++ b/lib/core_dom/event_handler.dart @@ -78,26 +78,16 @@ class EventHandler { } /** - * Converts event name into attribute. Event named 'someCustomEvent' needs to - * be transformed into on-some-custom-event. + * Converts event name into attribute name. */ - static String eventNameToAttrName(String eventName) { - var part = eventName.replaceAllMapped(new RegExp("([A-Z])"), (Match match) { - return '-${match.group(0).toLowerCase()}'; - }); - return 'on-${part}'; - } + static String eventNameToAttrName(String eventName) => 'on-$eventName'; /** - * Converts attribute into event name. Attribute 'on-some-custom-event' - * corresponds to event named 'someCustomEvent'. + * Converts attribute name into event name. */ static String attrNameToEventName(String attrName) { - var part = attrName.startsWith("on-") ? attrName.substring(3) : attrName; - part = part.replaceAllMapped(new RegExp(r'\-(\w)'), (Match match) { - return match.group(0).toUpperCase(); - }); - return part.replaceAll("-", ""); + assert(attrName.startsWith('on-')); + return attrName.substring(3); } } diff --git a/test/core_dom/event_handler_spec.dart b/test/core_dom/event_handler_spec.dart index 036e19986..0c8e63b4e 100644 --- a/test/core_dom/event_handler_spec.dart +++ b/test/core_dom/event_handler_spec.dart @@ -50,7 +50,7 @@ main() { var e = compile(_, '''
'''); - _.triggerEvent(e, 'myNewEvent'); + _.triggerEvent(e, 'my-new-event'); expect(_.rootScope.context['invoked']).toEqual(true); });