[FIX] blockdom: fix t-set-slot causing context capture with xml

This is a commit message.
This commit is contained in:
Samuel Degueldre
2024-01-10 10:20:14 +01:00
parent 70101e4c66
commit 3975a961ce
8 changed files with 115 additions and 94 deletions
+23 -1
View File
@@ -1,4 +1,4 @@
import { App, Component, mount, onMounted, useState, xml } from "../../src/index";
import { App, Component, mount, onMounted, onRendered, useState, xml } from "../../src/index";
import { children, makeTestFixture, nextAppError, nextTick, snapshotEverything } from "../helpers";
snapshotEverything();
@@ -62,6 +62,28 @@ describe("slots", () => {
expect(fixture.innerHTML).toBe("some other text");
});
test("t-set-slot doesn't cause context to be captured", async () => {
class Child extends Component {
static template = xml`<t t-slot="default"/>`;
}
class Parent extends Component {
static template = xml`<Child>
<t t-set-slot="default"><t t-esc="someVal"/></t>
</Child>`;
static components = { Child };
someVal = "some text";
setup() {
onRendered(() => {
this.someVal = "some other text";
});
}
}
await mount(Parent, fixture);
expect(fixture.textContent).toBe("some other text");
});
test("simple slot with slot scope", async () => {
let child: any;
class Child extends Component {