-
Notifications
You must be signed in to change notification settings - Fork 68
Accessibility labels for form fields and fieldsets #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
d25c8d5
ec3939d
99cb6ec
ceb4e3f
c9e079e
9d282fb
6541512
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,7 +72,7 @@ generators['terms-checkbox'] = function (config) { | |
| required: config.required | ||
| }), | ||
| ' ', | ||
| label | ||
| m('span', label) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we wrap the label in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if i don't, it puts on the same line as the already very long agree to terms text. |
||
| ]) | ||
| } | ||
|
|
||
|
|
@@ -155,19 +155,25 @@ generators.procaptcha = function (config) { | |
| * @returns {string} | ||
| */ | ||
| function generate (config) { | ||
| const labelAtts = {} | ||
| const label = config.label.length > 0 && config.showLabel ? m('label', labelAtts, config.label) : '' | ||
| const field = typeof (generators[config.type]) === 'function' ? generators[config.type](config) : generators.default(config) | ||
| const htmlTemplate = config.wrap ? m('p', [label, field]) : [label, field] | ||
|
|
||
| // render in vdom | ||
| const isNested = !['checkbox', 'radio'].includes(config.type) | ||
| const field = (generators[config.type] || generators.default)(config) | ||
| const hasLabel = config.label.length > 0 && config.showLabel | ||
|
|
||
| const content = config.type === 'terms-checkbox' | ||
| ? field | ||
| : isNested | ||
| ? (hasLabel | ||
| ? m('label', [config.label, field]) | ||
|
||
| : field) | ||
| : m('fieldset', [hasLabel | ||
| ? m('legend', config.label) | ||
| : '', field]) | ||
|
|
||
| const htmlTemplate = (config.wrap && isNested) ? m('p', content) : content | ||
| const vdom = document.createElement('div') | ||
| m.render(vdom, htmlTemplate) | ||
|
|
||
| // prettify html | ||
| const html = htmlutil.prettyPrint(vdom.innerHTML) | ||
|
|
||
| return html + '\n' | ||
| return htmlutil.prettyPrint(vdom.innerHTML) + '\n' | ||
| } | ||
|
|
||
| module.exports = generate | ||
Uh oh!
There was an error while loading. Please reload this page.