Closed marcaddeo closed 1 year ago
It's an intentional design choice for code
to be a prop. The reason is reactivity; if code
changes, it must be re-highlighted.
There is no built-in Svelte way to react to slot changes. You would need a mutation observer to re-highlight the child node text if it changes.
Is it possible to pass code using a slot instead of a prop?
For example, I'd like to be able to do
<Highlight language={typescript}> const a = "test"; </Highlight>
instead of having to put the code in a prop.The reason I'd like to see this is I'm using
<Highlight />
wrapped in a<code-block>
web component and it would feel more natural to pass it as a child/slot.