Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A11y: <figcaption> must be an immediate child of <figure> #2582

Closed
meydjer opened this issue Apr 26, 2019 · 2 comments · Fixed by #2607
Closed

A11y: <figcaption> must be an immediate child of <figure> #2582

meydjer opened this issue Apr 26, 2019 · 2 comments · Fixed by #2607
Labels

Comments

@meydjer
Copy link

meydjer commented Apr 26, 2019

<script>
	let caption = 'Lorem ipsum';
</script>

<figure>
	<img src="https://placekitten.com/200/300" alt="kitty" />
	{#if caption}
		<figcaption>{caption}</figcaption>
	{/if}
</figure>

This outputs the following warning: A11y: <figcaption> must be an immediate child of <figure>

REPL: https://svelte.dev/repl?version=3.1.0&gist=81856872f651e9f460d8f7497dedceb5

@EmilTholin
Copy link
Member

I wonder what blocks should be discarded when checking the figure/figcaption relationship.

Possibly {#if}, {:else if}, {:else}, and {#await}, {:then}, {:catch}?

<script>
  let caption = 'foo';
  let captionPromise = Promise.resolve('foo');
</script>

<figure>
  <img src="https://placekitten.com/200/300" alt="kitty" />
  {#if caption === 'foo'}
    <figcaption>{caption}</figcaption>
  {:else if caption === 'bar'}
    <figcaption>{caption}</figcaption>
  {:else}
    <figcaption>{caption}</figcaption>
  {/if}
</figure>

<figure>
  <img src="https://placekitten.com/200/300" alt="kitty" />
  {#await captionPromise}
    <figcaption>Loading</figcaption>
  {:then c}
    <figcaption>{c}</figcaption>
  {:catch e}
    <figcaption>{e}</figcaption>
  {/await}
</figure>

@Conduitry Conduitry added the bug label Apr 28, 2019
@Conduitry
Copy link
Member

I think we should probably just be looking for the nearest ancestor of the Element node type, and making sure that it's a <figure>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants