@@ -43,9 +43,17 @@ def _check_node(self, node: Any) -> None:
4343 self ._check_node (item )
4444
4545 def _check_event_bindings (self , node : Dict [str , Any ]) -> None :
46- """检查单个节点的事件绑定"""
46+ """检查单个节点的事件绑定(含 props 内的事件绑定) """
4747 component = node .get ('componentName' , 'unknown' )
4848
49+ # 两处都需要校验,避免漏检 props 内的事件。
50+ self ._check_event_holder (node , component )
51+ props = node .get ('props' )
52+ if isinstance (props , dict ):
53+ self ._check_event_holder (props , component )
54+
55+ def _check_event_holder (self , holder : Dict [str , Any ], component : str ) -> None :
56+ """检查某个属性容器(节点本身或其 props)内的事件绑定"""
4957 # 检查所有可能的事件属性
5058 event_keys = [
5159 'onClick' , 'onChange' , 'onKeyup' , 'onKeyDown' , 'onKeyPress' ,
@@ -55,13 +63,13 @@ def _check_event_bindings(self, node: Dict[str, Any]) -> None:
5563 ]
5664
5765 for key in event_keys :
58- if key in node :
59- value = node [key ]
66+ if key in holder :
67+ value = holder [key ]
6068 if isinstance (value , dict ):
6169 self ._check_event_value (component , key , value )
6270
6371 # 也检查以'on'开头的属性
64- for key , value in node .items ():
72+ for key , value in holder .items ():
6573 if key .startswith ('on' ) and key not in event_keys :
6674 if isinstance (value , dict ):
6775 self ._check_event_value (component , key , value )
0 commit comments