Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@iamllama
Copy link
Contributor

createClassComponent was made available in svelte 5 as a way to ease migration, and is intended to be replaced by mount. This pr proposes to do just that

What's odd is that i had to bump esbuild-svelte to 0.9.x. It introduced support for .svelte.{ts,js} files in 0.9.0, which is needed(?) for $state use outside of svelte files

However, there are already 2 existing .svelte.ts files, tooltip-utils.svelte.ts and add-or-update-note.svelte.ts, which seemed to work fine before. My best guess is that the svelte compiler was able to pick up on their use of $state by svelte(kit) files, but not mathjax-element.ts's since it's only trivially referenced in svelte files (mathjaxConfig)

Testing didn't reveal regressions with mathjax, the stats tooltips or the mobile mask editor's save tooltip

@dae
Copy link
Member

dae commented Apr 13, 2025

The move away from the old legacy code is very welcome! I did spot an issue though: the cmd+m m shortcut to add a new MathJax eqn in the add screen seems to be broken

@iamllama
Copy link
Contributor Author

iamllama commented Apr 13, 2025

Sorry for not catching that 😅 Pushed a fix that correctly opens up the overlay editor when using the mathjax toolbar buttons now, surprised this discrepancy between createClassComponent and mount wasn't documented (or perhaps i overlooked it)

EDIT: i did overlook it

Note that mount and hydrate are not synchronous, so things like onMount won’t have been called by the time the function returns and the pending block of promises will not have been rendered yet (because #await waits a microtask to wait for a potentially immediately-resolved promise). If you need that guarantee, call flushSync (import from 'svelte') after calling mount/hydrate.

@dae
Copy link
Member

dae commented Apr 13, 2025

Not a problem! Really appreciate you moving us in the right direction here. :-)

@dae dae merged commit 9d167fe into ankitects:main Apr 13, 2025
1 check passed
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.

2 participants