mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[FIX] compiler: fix issue with identifiers with same name
Before this commit, there were 2 different ways of generating variable identifiers. And it was possible to have a situation with two different variable in a template with the same identifier, which caused a crash. This commit ensures that we go through a unique helper method, so this cannot occur anymore. Also, the code is slightly simpler.
This commit is contained in:
committed by
Sam Degueldre
parent
7137130c38
commit
d09771b04b
@@ -197,6 +197,36 @@ describe("t-on", () => {
|
||||
expect(fixture.innerHTML).toBe("<div><span></span><button>2</button><p></p></div>");
|
||||
});
|
||||
|
||||
test("t-on on component next to t-on on div", async () => {
|
||||
class Child extends Component {
|
||||
static template = xml`<button t-esc="props.value"/>`;
|
||||
}
|
||||
|
||||
class Parent extends Component {
|
||||
static template = xml`
|
||||
<div>
|
||||
<Child t-on-click="increment" value="state.value"/>
|
||||
<p t-on-click="decrement">dec</p>
|
||||
</div>`;
|
||||
static components = { Child };
|
||||
state = useState({ value: 1 });
|
||||
increment() {
|
||||
this.state.value++;
|
||||
}
|
||||
decrement() {
|
||||
this.state.value--;
|
||||
}
|
||||
}
|
||||
await mount(Parent, fixture);
|
||||
expect(fixture.innerHTML).toBe("<div><button>1</button><p>dec</p></div>");
|
||||
fixture.querySelector("button")!.click();
|
||||
await nextTick();
|
||||
expect(fixture.innerHTML).toBe("<div><button>2</button><p>dec</p></div>");
|
||||
fixture.querySelector("p")!.click();
|
||||
await nextTick();
|
||||
expect(fixture.innerHTML).toBe("<div><button>1</button><p>dec</p></div>");
|
||||
});
|
||||
|
||||
test("t-on on t-slots", async () => {
|
||||
class Child extends Component {
|
||||
static template = xml`
|
||||
|
||||
Reference in New Issue
Block a user