From 978c9240fa3982caeeab6c7a37693da144df60fe Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Fri, 22 Oct 2021 00:26:58 -0400 Subject: [PATCH] Followup for loose-mode lexical scope #1351 was incomplete, and the test suite didn't make that clear because it doesn't exercise real template precompilation. This time I've manually tested end-to-end in a real app (alongside ember canary). --- packages/@glimmer/compiler/lib/compiler.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/@glimmer/compiler/lib/compiler.ts b/packages/@glimmer/compiler/lib/compiler.ts index 8afa7795c5..f3f99e6bc0 100644 --- a/packages/@glimmer/compiler/lib/compiler.ts +++ b/packages/@glimmer/compiler/lib/compiler.ts @@ -124,19 +124,17 @@ export function precompile( isStrictMode: options.strictMode ?? false, }; - if (!options.strictMode) { + if (usedLocals.length === 0) { delete templateJSONObject.scope; } // JSON is javascript let stringified = JSON.stringify(templateJSONObject); - if (options.strictMode && usedLocals.length > 0) { + if (usedLocals.length > 0) { let scopeFn = `()=>[${usedLocals.join(',')}]`; stringified = stringified.replace(`"${SCOPE_PLACEHOLDER}"`, scopeFn); - } else { - stringified = stringified.replace(`"${SCOPE_PLACEHOLDER}"`, 'null'); } return stringified;