language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Svelte 5 events lack syntax highlight

Open ilblog opened this issue 5 months ago • 2 comments

Description

While legacy mode events, like on:click={} of on:scroll={} etc... is nicely highlighted (combination of red and green), using Svelte 5 events, displays events in green colour, which is the same, as any other attribute. Thus it degrades a readability of the code.

Image Image

Proposed solution

Make events onclick, onsomething... coloured in different colour

Alternatives

No response

Additional Information, eg. Screenshots

No response

ilblog avatar Nov 06 '25 07:11 ilblog

For components, this would only be possible at the type level. For elements, checking whether the attribute starts with on is relatively safe. However, it would be quite weird if it only works in elements. If we were to use semantic highlight —the type-level highlight —you still need to use a supported theme and need the theme highlight method/function in a different colour.

*And note to self, removing the quote in the generated object property could achieve it, but it also highlights the normal property to yet another different colour, which might not be ideal. Another potential reason against this is that TypeScript also doesn't highlight jsx attribute that is a function.

jasonlyu123 avatar Nov 06 '25 14:11 jasonlyu123

From an alternative perspective: I find not splitting attribute names into two halves or mixing colors among attribute names far more readable.

Readbility is a weird and oftentimes extremely subjective thing.

cofl avatar Nov 06 '25 15:11 cofl