release: WRNexusJS 0.2.47
This commit is contained in:
@@ -881,3 +881,68 @@ component Accordion {
|
||||
|
||||
expect(output).not.toContain('${(isOpen(index)) ? " open" : ""}');
|
||||
});
|
||||
test("server-rendered each locals work in reactive handlers", () => {
|
||||
const firstLocals = Buffer.from(
|
||||
JSON.stringify({
|
||||
item: {
|
||||
question: "First",
|
||||
},
|
||||
index: 0,
|
||||
}),
|
||||
"utf8",
|
||||
).toString("base64");
|
||||
|
||||
const secondLocals = Buffer.from(
|
||||
JSON.stringify({
|
||||
item: {
|
||||
question: "Second",
|
||||
},
|
||||
index: 1,
|
||||
}),
|
||||
"utf8",
|
||||
).toString("base64");
|
||||
|
||||
const dom = mountHtml(`
|
||||
<div
|
||||
data-scope="openIndex: -1"
|
||||
>
|
||||
<article
|
||||
data-wrn-loop-locals="${firstLocals}"
|
||||
>
|
||||
<button
|
||||
data-on-click="openIndex = index"
|
||||
>
|
||||
First
|
||||
</button>
|
||||
|
||||
<span
|
||||
data-wrn-class-0='["open","openIndex === index"]'
|
||||
></span>
|
||||
</article>
|
||||
|
||||
<article
|
||||
data-wrn-loop-locals="${secondLocals}"
|
||||
>
|
||||
<button
|
||||
data-on-click="openIndex = index"
|
||||
>
|
||||
Second
|
||||
</button>
|
||||
|
||||
<span
|
||||
data-wrn-class-0='["open","openIndex === index"]'
|
||||
></span>
|
||||
</article>
|
||||
</div>
|
||||
`);
|
||||
|
||||
const buttons: any = dom.querySelectorAll("button");
|
||||
|
||||
buttons[1].click();
|
||||
|
||||
const articles = dom.querySelectorAll("article");
|
||||
|
||||
expect(articles[0].querySelector("span")?.classList.contains("open")).toBe(false);
|
||||
|
||||
expect(articles[1].querySelector("span")?.classList.contains("open")).toBe(true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user