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

This commit is contained in:
Frédéric Péters 2023-06-17 08:19:39 +02:00
parent b08b007386
commit bc81a6e3aa
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