Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Explicitly disallow `var` declarations extending the reactive statement scope ([#6800](https://github.com/sveltejs/svelte/pull/6800))
* Allow `#each` to iterate over iterables like `Set`, `Map` etc ([#7425](https://github.com/sveltejs/svelte/issues/7425))
* Warn about `:` in attributes and props to prevent ambiguity with Svelte directives ([#6823](https://github.com/sveltejs/svelte/issues/6823))
* Improve error message when trying to use `animate:` directives on inline components ([#8641](https://github.com/sveltejs/svelte/issues/8641))

## 3.59.1

Expand Down
4 changes: 4 additions & 0 deletions src/compiler/compile/compiler_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ export default {
code: 'invalid-action',
message: 'Actions can only be applied to DOM elements, not components'
},
invalid_animation: {
code: 'invalid-animation',
message: 'Animations can only be applied to DOM elements, not components'
},
invalid_class: {
code: 'invalid-class',
message: 'Classes can only be applied to DOM elements, not components'
Expand Down
6 changes: 5 additions & 1 deletion src/compiler/compile/nodes/InlineComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export default class InlineComponent extends Node {
? new Expression(component, this, scope, info.expression)
: null;
info.attributes.forEach(
/** @param {any} node */ (node) => {
/** @param {import('../../interfaces.js').BaseDirective | import('../../interfaces.js').Attribute | import('../../interfaces.js').SpreadAttribute} node */ (
node
) => {
/* eslint-disable no-fallthrough */
switch (node.type) {
case 'Action':
Expand Down Expand Up @@ -88,6 +90,8 @@ export default class InlineComponent extends Node {
return component.error(node, compiler_errors.invalid_transition);
case 'StyleDirective':
return component.error(node, compiler_errors.invalid_component_style_directive);
case 'Animation':
return component.error(node, compiler_errors.invalid_animation);
default:
throw new Error(`Not implemented: ${node.type}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/interfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export type DirectiveType =
| 'Ref'
| 'Transition';

interface BaseDirective extends BaseNode {
export interface BaseDirective extends BaseNode {
type: DirectiveType;
name: string;
}
Expand Down
14 changes: 14 additions & 0 deletions test/validator/samples/animation-on-component/errors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"code": "invalid-animation",
"message": "Animations can only be applied to DOM elements, not components",
"start": {
"line": 7,
"column": 8
},
"end": {
"line": 7,
"column": 19
}
}
]
7 changes: 7 additions & 0 deletions test/validator/samples/animation-on-component/input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script>
import Widget from './Widget.svelte';

function foo() {}
</script>

<Widget animate:foo />