[FIX] compiler: handle t-set as functions

This commit is contained in:
Géry Debongnie
2021-12-22 15:06:28 +01:00
committed by Mathieu Duckerts-Antoine
parent f014b1a33e
commit 5b1132f01a
9 changed files with 416 additions and 40 deletions
+10 -3
View File
@@ -78,7 +78,14 @@ export function snapshotTemplate(template: string) {
expect(fn.toString()).toMatchSnapshot();
}
export function renderToBdom(template: string, context: any = {}, node: any = {}): BDom {
export function renderToBdom(template: string, context: any = {}, node?: any): BDom {
if (!node) {
if (!context.__owl__) {
context.__owl__ = { component: context };
} else {
context.__owl__.component = context;
}
}
const fn = compile(template);
if (shouldSnapshot && !snapshottedTemplates.has(template)) {
snapshottedTemplates.add(template);
@@ -87,9 +94,9 @@ export function renderToBdom(template: string, context: any = {}, node: any = {}
return fn(blockDom, UTILS)(context, node);
}
export function renderToString(template: string, context: any = {}): string {
export function renderToString(template: string, context: any = {}, node?: any): string {
const fixture = makeTestFixture();
const bdom = renderToBdom(template, context);
const bdom = renderToBdom(template, context, node);
mount(bdom, fixture);
return fixture.innerHTML;
}