release: WRNexusJS 0.2.35
This commit is contained in:
@@ -610,3 +610,39 @@ function extractBehavior(output: string): {
|
||||
|
||||
return JSON.parse(Buffer.from(match![1], "base64").toString("utf8"));
|
||||
}
|
||||
test("component interpolated class attributes remain reactive", () => {
|
||||
const output = generate(
|
||||
parse(`
|
||||
component CookieToggle {
|
||||
state personalizationCookies = false
|
||||
|
||||
view {
|
||||
<span
|
||||
class="base {personalizationCookies ? 'enabled' : 'disabled'}"
|
||||
>
|
||||
Cookie
|
||||
</span>
|
||||
}
|
||||
}
|
||||
`),
|
||||
);
|
||||
|
||||
const match = output.match(/data-wrn-bind-class="([^"]+)"/);
|
||||
|
||||
expect(match).not.toBeNull();
|
||||
|
||||
const encodedBinding = match?.[1] ?? "";
|
||||
|
||||
const decodedBinding = encodedBinding
|
||||
.replaceAll(""", '"')
|
||||
.replaceAll("'", "'")
|
||||
.replaceAll("&", "&")
|
||||
.replaceAll("<", "<")
|
||||
.replaceAll(">", ">");
|
||||
|
||||
const binding = JSON.parse(decodedBinding) as [string, string];
|
||||
|
||||
expect(binding[0]).toBe("class");
|
||||
|
||||
expect(binding[1]).toBe("base {personalizationCookies ? 'enabled' : 'disabled'}");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user