Skip to content

Commit

Permalink
tweak test
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Mar 14, 2024
1 parent 502ce5d commit e648afe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
7 changes: 3 additions & 4 deletions packages/enhanced-img/test/Input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import manual_image1 from './no.png';
import manual_image2 from './no.svg';
const src = manual_image1;
const images = [manual_image1, manual_image2];
let foo: string = 'bar';
Expand Down Expand Up @@ -31,6 +32,8 @@

<enhanced:img src="/src/foo.png" alt="absolute path test" />

<enhanced:img {src} alt="attribute shorthand test" />

<enhanced:img src="./foo.svg" alt="svg test" />

{#each images as image}
Expand All @@ -42,7 +45,3 @@
<source srcset="./foo.avif 500v ./bar.avif 100v" />
<source srcset="./foo.avif, ./bar.avif 1v" />
</picture>

{#each images as src}
<enhanced:img {src} alt="opt-in test" />
{/each}
25 changes: 12 additions & 13 deletions packages/enhanced-img/test/Output.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import manual_image2 from './no.svg';
const src = manual_image1;
const images = [manual_image1, manual_image2];
let foo: string = 'bar';
Expand All @@ -30,6 +31,17 @@

<picture><source srcset={"/1 1440w, /2 960w"} type="image/avif" /><source srcset={"/3 1440w, /4 960w"} type="image/webp" /><source srcset={"5 1440w, /6 960w"} type="image/png" /><img src="/7" alt="absolute path test" width=1440 height=1440 /></picture>

{#if typeof src === 'string'}
<img src={src.img.src} alt="attribute shorthand test" width={src.img.w} height={src.img.h} />
{:else}
<picture>
{#each Object.entries(src.sources) as [format, srcset]}
<source {srcset} type={'image/' + format} />
{/each}
<img src={src.img.src} alt="attribute shorthand test" width={src.img.w} height={src.img.h} />
</picture>
{/if}

<img src={___ASSET___0} alt="svg test" />

{#each images as image}
Expand All @@ -50,16 +62,3 @@
<source srcset="./foo.avif 500v ./bar.avif 100v" />
<source srcset="./foo.avif, ./bar.avif 1v" />
</picture>

{#each images as src}
{#if typeof src === 'string'}
<img src={src.img.src} alt="opt-in test" width={src.img.w} height={src.img.h} />
{:else}
<picture>
{#each Object.entries(src.sources) as [format, srcset]}
<source {srcset} type={'image/' + format} />
{/each}
<img src={src.img.src} alt="opt-in test" width={src.img.w} height={src.img.h} />
</picture>
{/if}
{/each}

0 comments on commit e648afe

Please sign in to comment.