From e78a219718e4a52e9d86240d3e3c9ed632bc262c Mon Sep 17 00:00:00 2001 From: "James C. Davis" Date: Tue, 26 Jan 2021 17:16:07 -0500 Subject: [PATCH] add test for angle-bracket-like name invoked with curlies --- .../test/compiler/compile-options-test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/packages/@glimmer/integration-tests/test/compiler/compile-options-test.ts b/packages/@glimmer/integration-tests/test/compiler/compile-options-test.ts index 560b36ea47..b8096882a0 100644 --- a/packages/@glimmer/integration-tests/test/compiler/compile-options-test.ts +++ b/packages/@glimmer/integration-tests/test/compiler/compile-options-test.ts @@ -95,6 +95,29 @@ module('[glimmer-compiler] precompile', ({ test }) => { assert.equal(componentName, 'my-component', 'original component name was used'); }); + test('customizeComponentName is not invoked on angle-bracket-like name invoked with curlies', function (assert) { + let wire = JSON.parse( + precompile('{{#MyComponent}}hello{{/MyComponent}}', { + customizeComponentName(input: string) { + return input.toUpperCase(); + }, + }) + ); + + let block: WireFormat.SerializedTemplateBlock = JSON.parse(wire.block); + + let [[, componentNameExpr]] = block[0] as [WireFormat.Statements.Block]; + + glimmerAssert( + Array.isArray(componentNameExpr) && + componentNameExpr[0] === SexpOpcodes.GetFreeAsComponentHead, + `component name is a free variable lookup` + ); + + let componentName = block[3][componentNameExpr[1]]; + assert.equal(componentName, 'MyComponent', 'original component name was used'); + }); + test('lowercased names are not resolved or customized in resolution mode', (assert) => { let wire = JSON.parse( precompile('', {