diff --git a/src/qweb/compiler.ts b/src/qweb/compiler.ts index 7b080daa..e9f438b4 100644 --- a/src/qweb/compiler.ts +++ b/src/qweb/compiler.ts @@ -1029,7 +1029,6 @@ export class QWebCompiler { const subCtx: Context = createContext(ctx); this.compileAST(ast.slots[slotName], subCtx); if (this.hasRef) { - slot.signature = "ctx => node => {"; slot.code.unshift(` const refs = ctx.__owl__.refs`); slotStr.push(`'${slotName}': ${name}(${ctxStr})`); } else { diff --git a/tests/components/__snapshots__/refs.test.ts.snap b/tests/components/__snapshots__/refs.test.ts.snap index e2caae75..9b9678be 100644 --- a/tests/components/__snapshots__/refs.test.ts.snap +++ b/tests/components/__snapshots__/refs.test.ts.snap @@ -41,7 +41,7 @@ exports[`refs refs are properly bound in slots 2`] = ` let block1 = createBlock(\`
\`); let block2 = createBlock(\`\`); - const slot3 = ctx => node => { + const slot3 = ctx => (node, key) => { const refs = ctx.__owl__.refs let d2 = [ctx, 'doSomething']; let d3 = (el) => refs[\`myButton\`] = el; diff --git a/tests/components/__snapshots__/slots.test.ts.snap b/tests/components/__snapshots__/slots.test.ts.snap index 1d1ca6de..d3424146 100644 --- a/tests/components/__snapshots__/slots.test.ts.snap +++ b/tests/components/__snapshots__/slots.test.ts.snap @@ -43,6 +43,42 @@ exports[`slots can define and call slots 2`] = ` }" `; +exports[`slots can render node with t-ref and Component in same slot 1`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber } = helpers; + + return function template(ctx, node, key = \\"\\") { + return callSlot(ctx, node, key, 'default'); + } +}" +`; + +exports[`slots can render node with t-ref and Component in same slot 2`] = ` +"function anonymous(bdom, helpers +) { + let { text, createBlock, list, multi, html, toggler, component } = bdom; + let { withDefault, getTemplate, prepareList, withKey, zero, call, callSlot, capture, isBoundary, shallowEqual, setContextValue, toNumber } = helpers; + let assign = Object.assign; + + let block2 = createBlock(\`
\`); + + const slot2 = ctx => (node, key) => { + const refs = ctx.__owl__.refs + let d1 = (el) => refs[\`div\`] = el; + let b2 = block2([d1]); + let b3 = component(\`Child\`, {}, key + \`__3\`, node, ctx); + return multi([b2, b3]); + } + + return function template(ctx, node, key = \\"\\") { + const refs = ctx.__owl__.refs; + return assign(component(\`Child\`, {}, key + \`__1\`, node, ctx), {slots: {'default': slot2(ctx)}}); + } +}" +`; + exports[`slots can render only empty slot 1`] = ` "function anonymous(bdom, helpers ) { diff --git a/tests/components/slots.test.ts b/tests/components/slots.test.ts index 9fbea862..65c5b0ab 100644 --- a/tests/components/slots.test.ts +++ b/tests/components/slots.test.ts @@ -1347,4 +1347,22 @@ describe("slots", () => { expect(error).toBeNull(); expect(fixture.innerHTML).toEqual(""); }); + + test("can render node with t-ref and Component in same slot", async () => { + class Child extends Component { + static template = xml``; + } + + class Parent extends Component { + static template = xml`
`; + static components = { Child }; + } + let error = null; + try { + await mount(Parent, fixture); + } catch (e) { + error = e; + } + expect(error).toBeNull(); + }); });