Skip to content

Commit 8633c2a

Browse files
committed
update Output.svelte
1 parent 9e1abd6 commit 8633c2a

File tree

1 file changed

+32
-40
lines changed

1 file changed

+32
-40
lines changed

packages/enhanced-img/test/Output.svelte

Lines changed: 32 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,15 @@
4848
{:else}
4949
<img src={src} alt="attribute shorthand test" />
5050
{/if}
51+
{:else if Object.keys(src.sources).length === 1}
52+
<img src={src.img.src} alt="attribute shorthand test" srcset={Object.values(src.sources)[0]} width={src.img.w} height={src.img.h} />
5153
{:else}
52-
{#if Object.keys(src.sources).length === 1}
53-
<img src={src.img.src} alt="attribute shorthand test" srcset={Object.values(src.sources)[0]} width={src.img.w} height={src.img.h} />
54-
{:else}
55-
<picture>
56-
{#each Object.entries(src.sources) as [format, srcset]}
57-
<source {srcset} type={'image/' + format} />
58-
{/each}
59-
<img src={src.img.src} alt="attribute shorthand test" width={src.img.w} height={src.img.h} />
60-
</picture>
61-
{/if}
54+
<picture>
55+
{#each Object.entries(src.sources) as [format, srcset]}
56+
<source {srcset} type={'image/' + format} />
57+
{/each}
58+
<img src={src.img.src} alt="attribute shorthand test" width={src.img.w} height={src.img.h} />
59+
</picture>
6260
{/if}
6361

6462
{#if typeof webp_image === 'string'}
@@ -68,17 +66,15 @@
6866
{:else}
6967
<img src={webp_image} alt="single format dynamic test" />
7068
{/if}
69+
{:else if Object.keys(webp_image.sources).length === 1}
70+
<img src={webp_image.img.src} alt="single format dynamic test" srcset={Object.values(webp_image.sources)[0]} width={webp_image.img.w} height={webp_image.img.h} />
7171
{:else}
72-
{#if Object.keys(webp_image.sources).length === 1}
73-
<img src={webp_image.img.src} alt="single format dynamic test" srcset={Object.values(webp_image.sources)[0]} width={webp_image.img.w} height={webp_image.img.h} />
74-
{:else}
75-
<picture>
76-
{#each Object.entries(webp_image.sources) as [format, srcset]}
77-
<source {srcset} type={'image/' + format} />
78-
{/each}
79-
<img src={webp_image.img.src} alt="single format dynamic test" width={webp_image.img.w} height={webp_image.img.h} />
80-
</picture>
81-
{/if}
72+
<picture>
73+
{#each Object.entries(webp_image.sources) as [format, srcset]}
74+
<source {srcset} type={'image/' + format} />
75+
{/each}
76+
<img src={webp_image.img.src} alt="single format dynamic test" width={webp_image.img.w} height={webp_image.img.h} />
77+
</picture>
8278
{/if}
8379

8480
{#each images as image}
@@ -89,17 +85,15 @@
8985
{:else}
9086
<img src={image} alt="opt-in test" />
9187
{/if}
88+
{:else if Object.keys(image.sources).length === 1}
89+
<img src={image.img.src} alt="opt-in test" srcset={Object.values(image.sources)[0]} width={image.img.w} height={image.img.h} />
9290
{:else}
93-
{#if Object.keys(image.sources).length === 1}
94-
<img src={image.img.src} alt="opt-in test" srcset={Object.values(image.sources)[0]} width={image.img.w} height={image.img.h} />
95-
{:else}
96-
<picture>
97-
{#each Object.entries(image.sources) as [format, srcset]}
98-
<source {srcset} type={'image/' + format} />
99-
{/each}
100-
<img src={image.img.src} alt="opt-in test" width={image.img.w} height={image.img.h} />
101-
</picture>
102-
{/if}
91+
<picture>
92+
{#each Object.entries(image.sources) as [format, srcset]}
93+
<source {srcset} type={'image/' + format} />
94+
{/each}
95+
<img src={image.img.src} alt="opt-in test" width={image.img.w} height={image.img.h} />
96+
</picture>
10397
{/if}
10498
{/each}
10599

@@ -111,17 +105,15 @@
111105
{:else}
112106
<img src={get_image(i)} alt="opt-in test" />
113107
{/if}
108+
{:else if Object.keys(get_image(i).sources).length === 1}
109+
<img src={get_image(i).img.src} alt="opt-in test" srcset={Object.values(get_image(i).sources)[0]} width={get_image(i).img.w} height={get_image(i).img.h} />
114110
{:else}
115-
{#if Object.keys(get_image(i).sources).length === 1}
116-
<img src={get_image(i).img.src} alt="opt-in test" srcset={Object.values(get_image(i).sources)[0]} width={get_image(i).img.w} height={get_image(i).img.h} />
117-
{:else}
118-
<picture>
119-
{#each Object.entries(get_image(i).sources) as [format, srcset]}
120-
<source {srcset} type={'image/' + format} />
121-
{/each}
122-
<img src={get_image(i).img.src} alt="opt-in test" width={get_image(i).img.w} height={get_image(i).img.h} />
123-
</picture>
124-
{/if}
111+
<picture>
112+
{#each Object.entries(get_image(i).sources) as [format, srcset]}
113+
<source {srcset} type={'image/' + format} />
114+
{/each}
115+
<img src={get_image(i).img.src} alt="opt-in test" width={get_image(i).img.w} height={get_image(i).img.h} />
116+
</picture>
125117
{/if}
126118
{/each}
127119

0 commit comments

Comments
 (0)