From 53b89192c28eac9da8d2b5e248775ded689a8d54 Mon Sep 17 00:00:00 2001 From: James Bradbury Date: Thu, 30 Dec 2021 12:31:48 +0000 Subject: [PATCH] nest article/section checks into an if statement --- src/compiler/compile/nodes/Element.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 0d5dbe7c3e..f9e6f7d8bb 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -394,19 +394,14 @@ export default class Element extends Node { } 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)); } - if (parent.type === 'Element') { - break; + + else if (this.name === 'footer' && value === 'contentinfo') { + component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); } - parent = parent.parent; - } - - if (this.name === 'header' && value === 'banner' && !is_parent_section_or_article) { - component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); - } - - if (this.name === 'footer' && value === 'contentinfo' && !is_parent_section_or_article) { - component.warn(attribute, compiler_warnings.a11y_no_redundant_roles(value)); } }