mirror of https://github.com/sveltejs/svelte
fix: warn on undeclared shorthand event handlers on svelte:window/document/body (#18480)
Same as we already did on regular elements. Fixes #18275 --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/18680/merge
parent
44bd73f3e5
commit
09a67efcfc
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: warn on undeclared shorthand event handlers on `<svelte:window>`, `<svelte:document>` and `<svelte:body>`
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({});
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
let onkeydown;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:window {onkeydown} {onresize} />
|
||||||
|
<svelte:document {onvisibilitychange} />
|
||||||
|
<svelte:body {onfocus} />
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "attribute_global_event_reference",
|
||||||
|
"message": "You are referencing `globalThis.onresize`. Did you forget to declare a variable with that name?",
|
||||||
|
"start": {
|
||||||
|
"column": 27,
|
||||||
|
"line": 5
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"column": 37,
|
||||||
|
"line": 5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "attribute_global_event_reference",
|
||||||
|
"message": "You are referencing `globalThis.onvisibilitychange`. Did you forget to declare a variable with that name?",
|
||||||
|
"start": {
|
||||||
|
"column": 17,
|
||||||
|
"line": 6
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"column": 37,
|
||||||
|
"line": 6
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "attribute_global_event_reference",
|
||||||
|
"message": "You are referencing `globalThis.onfocus`. Did you forget to declare a variable with that name?",
|
||||||
|
"start": {
|
||||||
|
"column": 13,
|
||||||
|
"line": 7
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"column": 22,
|
||||||
|
"line": 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
Loading…
Reference in new issue