@@ -98,26 +98,28 @@ def _force_dict(value: t.Any, *, kind: str) -> dict:
9898 ) from None
9999
100100
101- def _substitute_attrs_dict (
102- value : object , * , kind : str
103- ) -> t .Iterable [tuple [str , str | None ]]:
104- """Substitute attributes based on the interpolated value being a dict."""
105- d = _force_dict (value , kind = kind )
106- for sub_k , sub_v in d .items ():
107- if sub_v is True :
108- yield f"{ kind } -{ sub_k } " , None
109- elif sub_v not in (False , None ):
110- yield f"{ kind } -{ sub_k } " , str (sub_v )
111-
112-
113101def _substitute_aria_attrs (value : object ) -> t .Iterable [tuple [str , str | None ]]:
114102 """Produce aria-* attributes based on the interpolated value for "aria"."""
115- return _substitute_attrs_dict (value , kind = "aria" )
103+ d = _force_dict (value , kind = "aria" )
104+ for sub_k , sub_v in d .items ():
105+ if sub_v is True :
106+ yield f"aria-{ sub_k } " , "true"
107+ elif sub_v is False :
108+ yield f"aria-{ sub_k } " , "false"
109+ elif sub_v is None :
110+ pass
111+ else :
112+ yield f"aria-{ sub_k } " , str (sub_v )
116113
117114
118115def _substitute_data_attrs (value : object ) -> t .Iterable [tuple [str , str | None ]]:
119116 """Produce data-* attributes based on the interpolated value for "data"."""
120- return _substitute_attrs_dict (value , kind = "data" )
117+ d = _force_dict (value , kind = "data" )
118+ for sub_k , sub_v in d .items ():
119+ if sub_v is True :
120+ yield f"data-{ sub_k } " , None
121+ elif sub_v not in (False , None ):
122+ yield f"data-{ sub_k } " , str (sub_v )
121123
122124
123125def _substitute_class_attr (value : object ) -> t .Iterable [tuple [str , str | None ]]:
0 commit comments