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

[fix] Apply class directive after half way transition #7765

Merged
merged 1 commit into from Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/compiler/compile/render_dom/wrappers/Element/index.ts
Expand Up @@ -1052,7 +1052,10 @@ export default class ElementWrapper extends Wrapper {
block.chunks.update.push(updater);
} else if ((dependencies && dependencies.size > 0) || this.class_dependencies.length) {
const all_dependencies = this.class_dependencies.concat(...dependencies);
const condition = block.renderer.dirty(all_dependencies);
let condition = block.renderer.dirty(all_dependencies);
if (block.has_outros) {
condition = x`!#current || ${condition}`;
}

// If all of the dependencies are non-dynamic (don't get updated) then there is no reason
// to add an updater for this.
Expand Down
30 changes: 30 additions & 0 deletions test/runtime/samples/class-shortcut-with-transition/_config.js
@@ -0,0 +1,30 @@
export default {
props: {
open: false,
border: true
},
html: '<p>foo</p>',

test({ assert, component, target, raf }) {
component.open = true;
raf.tick(100);
assert.htmlEqual(
target.innerHTML,
'<p>foo</p><p class="red svelte-1yszte8 border" style="">bar</p>'
);

component.open = false;
raf.tick(150);
assert.htmlEqual(
target.innerHTML,
'<p>foo</p><p class="red svelte-1yszte8 border" style="animation: __svelte_1333973250_0 100ms linear 0ms 1 both;">bar</p>'
);

component.open = true;
raf.tick(250);
assert.htmlEqual(
target.innerHTML,
'<p>foo</p><p class="red svelte-1yszte8 border" style="">bar</p>'
);
}
};
17 changes: 17 additions & 0 deletions test/runtime/samples/class-shortcut-with-transition/main.svelte
@@ -0,0 +1,17 @@
<script>
import { slide } from "svelte/transition";
export let open = false;
export let color = "red";
export let border = false;
</script>

<p>foo</p>
{#if open}
<p class={color} class:border transition:slide|local={{ duration: 100 }}>bar</p>
{/if}

<style>
.border {
border: 4px solid black;
}
</style>