55# Copyright (C) 2006-2022 NV Access Limited, Peter Vágner
66
77from typing import (
8- Iterable ,
8+ Generator ,
99 Optional ,
1010)
1111
@@ -34,7 +34,7 @@ def summary(self) -> str:
3434 return self ._target .summarizeInProcess ()
3535
3636 @property
37- def role (self ) -> controlTypes .Role :
37+ def role (self ) -> Optional [ controlTypes .Role ] :
3838 # details-roles is currently only defined in Chromium
3939 # this may diverge in Firefox in the future.
4040 from .chromium import supportedAriaDetailsRoles
@@ -46,7 +46,10 @@ def role(self) -> controlTypes.Role:
4646 log .debug (f"detailsRole: { repr (detailsRole )} " )
4747 if detailsRole in supportedAriaDetailsRoles .values ():
4848 return detailsRole
49- raise ValueError (f"Unsupported aria details role: { detailsRole } " )
49+
50+ if config .conf ["debugLog" ]["annotations" ]:
51+ log .warning (f"Unsupported aria details role: { detailsRole } " )
52+ return None
5053
5154 @property
5255 def targetObject (self ) -> IAccessible :
@@ -68,25 +71,24 @@ def __bool__(self) -> bool:
6871 )
6972
7073 @property
71- def targets (self ) -> Iterable [MozAnnotationTarget ]:
74+ def targets (self ) -> Generator [MozAnnotationTarget , None , None ]:
7275 detailsRelations = self ._originObj .detailsRelations
7376 for rel in detailsRelations :
7477 yield MozAnnotationTarget (rel )
7578
7679 @property
77- def roles (self ) -> Iterable [ controlTypes .Role ]:
80+ def roles (self ) -> Generator [ Optional [ controlTypes .Role ], None , None ]:
7881 # Unlike base Ia2Web implementation, the details-roles
7982 # IA2 attribute is not exposed in Firefox.
8083 # Although slower, we have to fetch the details relations instead.
8184 for target in self .targets :
82- # just take the first target for now.
8385 try :
8486 yield target .role
8587 except ValueError :
8688 log .error ("Error getting role." , exc_info = True )
8789
8890 @property
89- def summaries (self ) -> Iterable [str ]:
91+ def summaries (self ) -> Generator [str , None , None ]:
9092 for target in self .targets :
9193 yield target .summary
9294
0 commit comments