pull/7774/head
Simon H 4 years ago committed by tanhauhau
parent bd03c70516
commit 8201d761d2

@ -31,7 +31,7 @@ import {
is_interactive_roles, is_interactive_roles,
is_hidden_from_screen_reader, is_hidden_from_screen_reader,
is_semantic_role_element, is_semantic_role_element,
may_contain_input_child contains_input_child
} from '../utils/a11y'; } from '../utils/a11y';
const aria_attributes = 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby description details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split(' '); const aria_attributes = 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby description details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split(' ');
@ -788,7 +788,7 @@ export default class Element extends Node {
if (this.name === 'label') { if (this.name === 'label') {
const rule_options = component.compile_options.a11y?.rules?.['label-has-associated-control']; const rule_options = component.compile_options.a11y?.rules?.['label-has-associated-control'];
if (!attribute_map.has('for') && !may_contain_input_child(this, rule_options)) { if (!attribute_map.has('for') && !contains_input_child(this, rule_options)) {
component.warn(this, compiler_warnings.a11y_label_has_associated_control); component.warn(this, compiler_warnings.a11y_label_has_associated_control);
} }
} }

@ -12,7 +12,7 @@ import { TemplateNode } from '../../interfaces';
import compiler_errors from '../compiler_errors'; import compiler_errors from '../compiler_errors';
import compiler_warnings from '../compiler_warnings'; import compiler_warnings from '../compiler_warnings';
import { regex_only_whitespaces } from '../../utils/patterns'; import { regex_only_whitespaces } from '../../utils/patterns';
import { may_contain_input_child } from '../utils/a11y'; import { contains_input_child } from '../utils/a11y';
export default class InlineComponent extends Node { export default class InlineComponent extends Node {
type: 'InlineComponent'; type: 'InlineComponent';
@ -173,7 +173,7 @@ export default class InlineComponent extends Node {
validate() { validate() {
const label_has_associated_control_rule_options = this.component.compile_options.a11y?.rules?.['label-has-associated-control']; const label_has_associated_control_rule_options = this.component.compile_options.a11y?.rules?.['label-has-associated-control'];
if (label_has_associated_control_rule_options?.labelComponents?.includes(this.name)) { if (label_has_associated_control_rule_options?.labelComponents?.includes(this.name)) {
if (!may_contain_input_child(this, label_has_associated_control_rule_options)) { if (!contains_input_child(this, label_has_associated_control_rule_options)) {
this.component.warn(this, compiler_warnings.a11y_label_has_associated_control); this.component.warn(this, compiler_warnings.a11y_label_has_associated_control);
} }
} }

@ -174,7 +174,7 @@ const a11y_labelable = new Set([
'textarea' 'textarea'
]); ]);
export function may_contain_input_child( export function contains_input_child(
root: INode, root: INode,
rule_options: CompileOptions['a11y']['rules']['label-has-associated-control'] rule_options: CompileOptions['a11y']['rules']['label-has-associated-control']
): boolean { ): boolean {

Loading…
Cancel
Save