From 2911f482c7a89b38564ac8af32a2189a32f6f27d Mon Sep 17 00:00:00 2001 From: tanhauhau Date: Tue, 12 Jul 2022 22:35:32 +0800 Subject: [PATCH] clean up test --- src/compiler/compile/nodes/Element.ts | 11 +++++------ .../input.svelte} | 0 .../a11y-label-has-associated-control-2/warnings.json | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) rename test/validator/samples/{a11y-label-has-associated-control/label.svelte => a11y-label-has-associated-control-2/input.svelte} (100%) create mode 100644 test/validator/samples/a11y-label-has-associated-control-2/warnings.json diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index e9a17af857..fb19d13f87 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -616,17 +616,16 @@ export default class Element extends Node { } if (this.name === 'label') { - const has_input_child = (children) => { - const has_input = children.some(i => (i instanceof Element && a11y_labelable.has(i.name))); - if (has_input) { + const has_input_child = (children: INode[]) => { + if (children.some(child => (child instanceof Element && (a11y_labelable.has(child.name) || child.name === 'slot')))) { return true; } - for (const c of children) { - if (!c.children || c.children.length === 0) { + for (const child of children) { + if (!('children' in child) || child.children.length === 0) { continue; } - if (has_input_child(c.children)) { + if (has_input_child(child.children)) { return true; } } diff --git a/test/validator/samples/a11y-label-has-associated-control/label.svelte b/test/validator/samples/a11y-label-has-associated-control-2/input.svelte similarity index 100% rename from test/validator/samples/a11y-label-has-associated-control/label.svelte rename to test/validator/samples/a11y-label-has-associated-control-2/input.svelte diff --git a/test/validator/samples/a11y-label-has-associated-control-2/warnings.json b/test/validator/samples/a11y-label-has-associated-control-2/warnings.json new file mode 100644 index 0000000000..fe51488c70 --- /dev/null +++ b/test/validator/samples/a11y-label-has-associated-control-2/warnings.json @@ -0,0 +1 @@ +[]