mirror of https://github.com/sveltejs/svelte
parent
6eb720a1b7
commit
b0e03c7b96
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: prevent responsive image retention in Chromium
|
||||
@ -0,0 +1,19 @@
|
||||
import { append, comment, from_html } from 'svelte/internal/client';
|
||||
|
||||
const parent_template = from_html('<div><!></div>');
|
||||
const picture_template = from_html(
|
||||
'<picture><source srcset="small.webp 400w, large.webp 800w" sizes="100vw" type="image/webp"> <img src="small.jpg" srcset="small.jpg 400w, large.jpg 800w" sizes="100vw" alt=""></picture>'
|
||||
);
|
||||
|
||||
export default function Picture(anchor) {
|
||||
const parent = parent_template();
|
||||
const fragment = comment();
|
||||
const fragment_anchor = fragment.lastChild;
|
||||
const picture = picture_template();
|
||||
const img = picture.querySelector('img');
|
||||
|
||||
img.dataset.pageDocument = String(img.ownerDocument === document);
|
||||
append(fragment_anchor, picture);
|
||||
parent.firstChild.before(fragment);
|
||||
append(anchor, parent);
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['client'],
|
||||
|
||||
test({ assert, target }) {
|
||||
assert.equal(target.querySelector('img')?.dataset.pageDocument, 'true');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
import Picture from './Picture.js';
|
||||
|
||||
let show = $state(true);
|
||||
</script>
|
||||
|
||||
{#if show}
|
||||
<div>
|
||||
{#if true}<Picture />{/if}
|
||||
</div>
|
||||
{/if}
|
||||
Loading…
Reference in new issue