Skip to content

Commit

Permalink
clean up test
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhauhau committed Jul 12, 2022
1 parent 30150b1 commit ee1e0fa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/compiler/compile/nodes/Element.ts
Expand Up @@ -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;
}
}
Expand Down
@@ -0,0 +1,12 @@
<script>
import LabelComponent from './label.svelte'
</script>

<label>A</label>
<label for="id">B</label>

<label>C <input type="text" /></label>
<label>D <button>D</button></label>
<label>E <span></span></label>
<label>F {#if true}<input type="text" />{/if}</label>
<LabelComponent>G <input type="text" /></LabelComponent>
@@ -0,0 +1 @@
[]

This file was deleted.

0 comments on commit ee1e0fa

Please sign in to comment.