From bb975e7b0c9a60477ed3daa5ea2b803505503141 Mon Sep 17 00:00:00 2001 From: James Bradbury Date: Thu, 30 Dec 2021 17:45:46 +0000 Subject: [PATCH] simplify conditional logic --- src/compiler/compile/nodes/Element.ts | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 4c267697f5..834d8aa1bd 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -370,23 +370,17 @@ export default class Element extends Node { } // no-redundant-roles - if (this.name === value) { - component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); - } else if (this.name === 'nav' && value === 'navigation') { - component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); - } else if (this.name === 'a' && value === 'link') { - component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); - } else if (this.name === 'fieldset' && value === 'group') { - component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); - } else if (this.name === 'ul' && value === 'list') { - component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); - } + if (this.name === value || + this.name === 'nav' && value === 'navigation' || + this.name === 'a' && value === 'link' || + this.name === 'fieldset' && value === 'group' || + this.name === 'ul' && value === 'list') { + component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); + } const is_parent_section_or_article = is_parent(this.parent, ['section', 'article']); if (!is_parent_section_or_article) { - if (this.name === 'header' && value === 'banner') { - component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); - } else if (this.name === 'footer' && value === 'contentinfo') { + if (this.name === 'header' && value === 'banner' || this.name === 'footer' && value === 'contentinfo') { component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); } }