mirror of https://github.com/sveltejs/svelte
parent
a60fffc456
commit
eb0845e365
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: await dependencies of style directives
|
||||
@ -0,0 +1,30 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
mode: ['async-server', 'client', 'hydrate'],
|
||||
ssrHtml: `
|
||||
<div style="color: red;"></div>
|
||||
<div style="width: 100px;"></div>
|
||||
<button>width</button>
|
||||
<div style="color: red;"></div>
|
||||
<div style="width: 100px;"></div>
|
||||
<button>width</button>
|
||||
`,
|
||||
|
||||
async test({ assert, target }) {
|
||||
await tick();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<div style="color: red;"></div>
|
||||
<div style="width: 100px;"></div>
|
||||
<button>width</button>
|
||||
<div style="color: red;"></div>
|
||||
<div style="width: 100px;"></div>
|
||||
<button>width</button>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,25 @@
|
||||
<script>
|
||||
await Promise.resolve();
|
||||
|
||||
// static
|
||||
let color = $state('red');
|
||||
|
||||
// dynamic
|
||||
let width = $state('100px');
|
||||
</script>
|
||||
|
||||
<!-- force them into their own template effects -->
|
||||
|
||||
<!-- normal -->
|
||||
{#if color}
|
||||
<div style:color={color}></div>
|
||||
<div style:width={width}></div>
|
||||
<button onclick={() => width = '1px'}>width</button>
|
||||
{/if}
|
||||
|
||||
<!-- shorthand -->
|
||||
{#if color}
|
||||
<div style:color></div>
|
||||
<div style:width></div>
|
||||
<button onclick={() => width = '1px'}>width</button>
|
||||
{/if}
|
||||
Loading…
Reference in new issue