@@ -16,13 +16,13 @@ public sealed class HydroOnTagHelper : TagHelper
1616{
1717 private const string HandlersPrefix = "hydro-on:" ;
1818
19- private IDictionary < string , Expression < Action > > _handlers ;
19+ private IDictionary < string , Expression > _handlers ;
2020
2121 /// <summary />
2222 [ HtmlAttributeName ( DictionaryAttributePrefix = HandlersPrefix ) ]
23- public IDictionary < string , Expression < Action > > Handlers
23+ public IDictionary < string , Expression > Handlers
2424 {
25- get => _handlers ??= new Dictionary < string , Expression < Action > > ( StringComparer . OrdinalIgnoreCase ) ;
25+ get => _handlers ??= new Dictionary < string , Expression > ( StringComparer . OrdinalIgnoreCase ) ;
2626 set => _handlers = value ;
2727 }
2828
@@ -52,7 +52,12 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
5252
5353 foreach ( var eventItem in _handlers )
5454 {
55- var jsExpression = GetJsExpression ( eventItem . Value ) ;
55+ if ( eventItem . Value is not LambdaExpression actionExpression )
56+ {
57+ throw new InvalidOperationException ( $ "Wrong event handler statement in component for { modelType . Namespace } ") ;
58+ }
59+
60+ var jsExpression = GetJsExpression ( actionExpression ) ;
5661
5762 if ( jsExpression == null )
5863 {
@@ -70,7 +75,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
7075 }
7176 }
7277
73- private static string GetJsExpression ( Expression < Action > expression )
78+ private static string GetJsExpression ( LambdaExpression expression )
7479 {
7580 var clientAction = GetJsClientActionExpression ( expression ) ;
7681
@@ -82,7 +87,7 @@ private static string GetJsExpression(Expression<Action> expression)
8287 return GetJsInvokeExpression ( expression ) ;
8388 }
8489
85- private static string GetJsClientActionExpression ( Expression < Action > expression )
90+ private static string GetJsClientActionExpression ( LambdaExpression expression )
8691 {
8792 if ( expression is not { Body : MethodCallExpression methodCall }
8893 || methodCall . Method . DeclaringType != typeof ( HydroClientActions ) )
@@ -101,7 +106,7 @@ private static string GetJsClientActionExpression(Expression<Action> expression)
101106 }
102107 }
103108
104- private static string GetJsInvokeExpression ( Expression < Action > expression )
109+ private static string GetJsInvokeExpression ( LambdaExpression expression )
105110 {
106111 var eventData = expression . GetNameAndParameters ( ) ;
107112
0 commit comments