diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 87af46a7fe..85f92ca64f 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -31,7 +31,7 @@ import { is_interactive_roles, is_hidden_from_screen_reader, is_semantic_role_element, - may_contain_input_child + contains_input_child } 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(' '); @@ -788,7 +788,7 @@ export default class Element extends Node { if (this.name === 'label') { 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); } } diff --git a/src/compiler/compile/nodes/InlineComponent.ts b/src/compiler/compile/nodes/InlineComponent.ts index 304da2604a..4978ff3b98 100644 --- a/src/compiler/compile/nodes/InlineComponent.ts +++ b/src/compiler/compile/nodes/InlineComponent.ts @@ -12,7 +12,7 @@ import { TemplateNode } from '../../interfaces'; import compiler_errors from '../compiler_errors'; import compiler_warnings from '../compiler_warnings'; 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 { type: 'InlineComponent'; @@ -173,7 +173,7 @@ export default class InlineComponent extends Node { validate() { 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 (!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); } } diff --git a/src/compiler/compile/utils/a11y.ts b/src/compiler/compile/utils/a11y.ts index a8524ad9f0..0dc78ad00c 100644 --- a/src/compiler/compile/utils/a11y.ts +++ b/src/compiler/compile/utils/a11y.ts @@ -174,7 +174,7 @@ const a11y_labelable = new Set([ 'textarea' ]); -export function may_contain_input_child( +export function contains_input_child( root: INode, rule_options: CompileOptions['a11y']['rules']['label-has-associated-control'] ): boolean {