-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Copy link
Description
Describe the bug
We're using cn utility to set the tailwind classes, but in 5.20.3 this stopped working:
<script lang="ts">
function cn(className) {
return className;
}
const tag = "div";
</script>
<svelte:element this={tag}
class={cn("font-bold")}
>
</svelte:element>Compiles to:
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';
export default function App($$anchor) {
function cn(className) {
return className;
}
const tag = "div";
var fragment = $.comment();
var node = $.first_child(fragment);
$.element(node, () => tag, false, ($$element, $$anchor) => {
$.template_effect(() => $.set_class($$element, 0, $.clsx($0)));
});
$.append($$anchor, fragment);
}The cn("font-bold") code is is no longer in the compiled output.
In 5.20.2 the code worked and compiled to:
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';
export default function App($$anchor) {
function cn(className) {
return className;
}
const tag = "div";
var fragment = $.comment();
var node = $.first_child(fragment);
$.element(node, () => tag, false, ($$element, $$anchor) => {
let attributes;
$.template_effect(($0) => attributes = $.set_attributes($$element, attributes, { class: $0 }, undefined, $$element.namespaceURI === $.NAMESPACE_SVG, $$element.nodeName.includes('-')), [() => cn("font-bold")], $.derived_safe_equal);
});
$.append($$anchor, fragment);
}Reproduction
Logs
System Info
System:
OS: macOS 15.3.1
CPU: (12) arm64 Apple M3 Pro
Memory: 473.27 MB / 36.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.7.0 - /opt/homebrew/bin/node
Yarn: 1.22.22 - ~/Library/pnpm/yarn
npm: 10.9.2 - /opt/homebrew/bin/npm
pnpm: 10.5.0 - ~/Library/pnpm/pnpm
bun: 1.1.34 - ~/.bun/bin/bun
Browsers:
Chrome: 133.0.6943.127
Safari: 18.3
npmPackages:
svelte: 5.20.4 => 5.20.4Severity
blocking an upgrade
alexvdvalk
Metadata
Metadata
Assignees
Labels
No labels