Skip to content

fix: warn on undeclared shorthand event handlers on svelte:window/document/body#18480

Open
chatman-media wants to merge 1 commit into
sveltejs:mainfrom
chatman-media:fix-global-event-reference-special-elements
Open

fix: warn on undeclared shorthand event handlers on svelte:window/document/body#18480
chatman-media wants to merge 1 commit into
sveltejs:mainfrom
chatman-media:fix-global-event-reference-special-elements

Conversation

@chatman-media

Copy link
Copy Markdown

On a regular element, writing a shorthand event handler whose name isn't declared (e.g. {onresize}) gives you the attribute_global_event_reference warning, since it quietly falls back to the global handler. But <svelte:window>, <svelte:document> and <svelte:body> never ran that check, so the same typo there slipped by silently — closes #18275.

I pulled the shorthand-identifier check into a small helper in special-element.js and call it from the three special-element visitors for their event attributes. Spread/non-event attributes still error exactly as before. Added a validator sample covering all three (a declared handler stays quiet, undeclared ones warn).

@changeset-bot

changeset-bot Bot commented Jun 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0ba0e76

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shorthand properties for touch don't throw if they don't exist inside svelte:window

1 participant