From 8d2b250fefe1c4e957482bce37e1bba65a772a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 23 Oct 2020 11:38:53 +0200 Subject: [PATCH] [FIX] slots: prevent infinite loop in some cases The reviewer for the commit on named slots inside named slots did not notice that there was an infinite loop. Because of his sloppiness, Owl could block in an infinite loop when a named t-slots was defined inside a subcomponent, but not as a direct child. --- src/component/directive.ts | 1 + tests/component/slots.test.ts | 33 +++++++++++++++++++++++++++++++++ tools/release.js | 2 +- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/component/directive.ts b/src/component/directive.ts index 72aae3c3..7d8e7fb7 100644 --- a/src/component/directive.ts +++ b/src/component/directive.ts @@ -436,6 +436,7 @@ QWeb.addDirective({ isInSubComponent = true; break; } + el = el.parentElement; } if (isInSubComponent) { continue; diff --git a/tests/component/slots.test.ts b/tests/component/slots.test.ts index ff1950b5..de6b0221 100644 --- a/tests/component/slots.test.ts +++ b/tests/component/slots.test.ts @@ -1052,4 +1052,37 @@ describe("t-slot directive", () => { "

Ablip

default2default1

Bblip

" ); }); + + test("named slot inside slot, part 3", async () => { + class Child extends Component { + static template = xml` +
+ + +
`; + } + class Parent extends Component { + static template = xml` +
+ + +

A

+
+ + + +

B

+
+
+
+
+
`; + static components = { Child }; + value = "blip"; + } + const parent = new Parent(); + await parent.mount(fixture); + + expect(fixture.innerHTML).toBe("

Ablip

Bblip

"); + }); }); diff --git a/tools/release.js b/tools/release.js index c1a69e75..7681fd61 100644 --- a/tools/release.js +++ b/tools/release.js @@ -87,7 +87,7 @@ async function startRelease() { // --------------------------------------------------------------------------- - log('Step 7/${STEPS}: Creating the release...'); + log(`Step 7/${STEPS}: Creating the release...`); const relaseResult = await execCommand(`gh release create v${next} dist/*.js ${draft} -F release-notes.md`); if (relaseResult !== 0) { log("github release failed. Aborting.");