a11y: do not use <label> for readonly single checkbox (#71089) #399

Merged
fpeters merged 1 commits from wip/71089-a11y-readonly-single-checkbox into main 2023-06-23 08:10:18 +02:00
1 changed files with 3 additions and 2 deletions

View File

@ -767,10 +767,11 @@ class CheckboxWidget(QuixoteCheckboxWidget):
data_attrs = ' '.join('%s="%s"' % x for x in attrs.items() if x[0].startswith('data-'))
# more elaborate markup so standalone checkboxes can be applied a
# custom style.
label_tag = 'span' if 'readonly' in self.attrs else 'label'
return (
htmltext('<label %s>%s<span>' % (data_attrs, checkbox))
htmltext('<%s %s>%s<span>' % (label_tag, data_attrs, checkbox))
+ str(inline_title)
+ htmltext('</span></label>')
+ htmltext('</span></%s>' % label_tag)
)
return checkbox