mirror of https://github.com/sveltejs/svelte
breaking: warn/error on old syntax in runes mode (#11203)
* breaking: warn/error on old syntax in runes mode - warn on slots and event handlers in runes mode - error on `<slot>` + `{@render ...}` tag usage in same component closes #9416 * render tag + slot could occur in legacy mode as well, error there, toopull/11209/head
parent
4ef64541dd
commit
d51075c154
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"svelte": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
breaking: warn on slots and event handlers in runes mode, error on `<slot>` + `{@render ...}` tag usage in same component
|
@ -0,0 +1,10 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
error: {
|
||||||
|
code: 'conflicting-slot-usage',
|
||||||
|
message:
|
||||||
|
'Cannot use <slot> syntax and {@render ...} tags in the same component. Migrate towards {@render ...} tags completely.',
|
||||||
|
position: [71, 84]
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
let { children } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{@render children()}
|
||||||
|
<slot></slot>
|
@ -0,0 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
let { foo } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<!-- ok -->
|
||||||
|
<button onclick={foo}>click me</button>
|
||||||
|
<Button onclick={foo}>click me</Button>
|
||||||
|
<Button on:click={foo}>click me</Button>
|
||||||
|
|
||||||
|
<!-- warn -->
|
||||||
|
<slot></slot>
|
||||||
|
<slot name="foo"></slot>
|
||||||
|
<button on:click={foo}>click me</button>
|
@ -0,0 +1,38 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "deprecated-slot-element",
|
||||||
|
"end": {
|
||||||
|
"column": 13,
|
||||||
|
"line": 11
|
||||||
|
},
|
||||||
|
"message": "Using <slot> to render parent content is deprecated. Use {@render ...} tags instead.",
|
||||||
|
"start": {
|
||||||
|
"column": 0,
|
||||||
|
"line": 11
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "deprecated-slot-element",
|
||||||
|
"end": {
|
||||||
|
"column": 24,
|
||||||
|
"line": 12
|
||||||
|
},
|
||||||
|
"message": "Using <slot> to render parent content is deprecated. Use {@render ...} tags instead.",
|
||||||
|
"start": {
|
||||||
|
"column": 0,
|
||||||
|
"line": 12
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "deprecated-event-handler",
|
||||||
|
"end": {
|
||||||
|
"column": 22,
|
||||||
|
"line": 13
|
||||||
|
},
|
||||||
|
"message": "Using on:click to listen to the click event is is deprecated. Use the event attribute onclick instead.",
|
||||||
|
"start": {
|
||||||
|
"column": 8,
|
||||||
|
"line": 13
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in new issue