fix: disallow `bind` and `transitions`

pull/18058/head
paoloricciuti 5 months ago
parent df42e4babd
commit 9167c8df4d

@ -7,6 +7,10 @@ import * as e from '../../../errors.js';
* @param {Context} context
*/
export function AnimateDirective(node, context) {
if (context.state.analysis.custom_renderer) {
e.incompatible_with_custom_renderer(node, '`animate:`');
}
context.next({ ...context.state, expression: node.metadata.expression });
if (node.metadata.expression.has_await) {

@ -27,6 +27,9 @@ export function BindDirective(node, context) {
parent?.type === 'SvelteDocument' ||
parent?.type === 'SvelteBody'
) {
if (context.state.analysis.custom_renderer) {
e.incompatible_with_custom_renderer(node, '`bind:`');
}
if (node.name in binding_properties) {
const property = binding_properties[node.name];
if (property.valid_elements && !property.valid_elements.includes(parent.name)) {

@ -9,6 +9,11 @@ import { mark_subtree_dynamic } from './shared/fragment.js';
* @param {Context} context
*/
export function TransitionDirective(node, context) {
if (context.state.analysis.custom_renderer) {
const directive = node.intro && node.outro ? '`transition:`' : node.intro ? '`in:`' : '`out:`';
e.incompatible_with_custom_renderer(node, directive);
}
mark_subtree_dynamic(context.path);
context.next({ ...context.state, expression: node.metadata.expression });

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
compile_error: '`animate:` is not compatible with `customRenderer`'
});

@ -0,0 +1,9 @@
<script>
import { flip } from 'svelte/animate';
let items = [1, 2, 3];
</script>
{#each items as item (item)}
<div animate:flip>{item}</div>
{/each}

@ -0,0 +1,5 @@
<script>
let value = $state('hello');
</script>
{value}

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
html: 'hello'
});

@ -0,0 +1,7 @@
<script>
import Child from './Child.svelte';
let value = $state('hello');
</script>
<Child bind:value />

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
compile_error: '`bind:` is not compatible with `customRenderer`'
});

@ -0,0 +1,5 @@
<script>
let value = $state('');
</script>
<input bind:value />

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
compile_error: '`in:` is not compatible with `customRenderer`'
});

@ -0,0 +1,5 @@
<script>
import { fade } from 'svelte/transition';
</script>
<div in:fade>content</div>

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
compile_error: '`out:` is not compatible with `customRenderer`'
});

@ -0,0 +1,5 @@
<script>
import { fade } from 'svelte/transition';
</script>
<div out:fade>content</div>

@ -0,0 +1,5 @@
import { test } from '../../test';
export default test({
compile_error: '`transition:` is not compatible with `customRenderer`'
});

@ -0,0 +1,5 @@
<script>
import { fade } from 'svelte/transition';
</script>
<div transition:fade>content</div>
Loading…
Cancel
Save