@@ -11,6 +11,7 @@ import type {
1111import type { TemplateOnlyComponent } from '@glimmer/runtime' ;
1212import type { EmberishCurlyComponent } from '@glimmer-workspace/integration-tests' ;
1313import { expect } from '@glimmer/debug-util' ;
14+ import { DEBUG } from '@glimmer/env' ;
1415import { modifierCapabilities , setComponentTemplate , setModifierManager } from '@glimmer/manager' ;
1516import { EMPTY_ARGS , templateOnlyComponent , TemplateOnlyComponentManager } from '@glimmer/runtime' ;
1617import { assign } from '@glimmer/util' ;
@@ -110,6 +111,88 @@ class DebugRenderTreeTest extends RenderTest {
110111 ] ) ;
111112 }
112113
114+ @test 'strict-mode components without debug symbols preserve names from scope' ( ) {
115+ const HelloWorld = defComponent ( '{{@arg}}' ) ;
116+ const Root = defComponent ( `<HelloWorld @arg="first"/>` , {
117+ scope : { HelloWorld } ,
118+ emit : { moduleName : 'root.hbs' , debugSymbols : false } ,
119+ } ) ;
120+
121+ this . renderComponent ( Root ) ;
122+
123+ this . assertRenderTree ( [
124+ {
125+ type : 'component' ,
126+ name : '{ROOT}' ,
127+ args : { positional : [ ] , named : { } } ,
128+ instance : null ,
129+ template : 'root.hbs' ,
130+ bounds : this . elementBounds ( this . delegate . getInitialElement ( ) ) ,
131+ children : [
132+ {
133+ type : 'component' ,
134+ name : 'HelloWorld' ,
135+ args : { positional : [ ] , named : { arg : 'first' } } ,
136+ instance : null ,
137+ template : '(unknown template module)' ,
138+ bounds : this . nodeBounds ( this . delegate . getInitialElement ( ) . firstChild ) ,
139+ children : [ ] ,
140+ } ,
141+ ] ,
142+ } ,
143+ ] ) ;
144+ }
145+
146+ @test ( { skip : ! DEBUG } ) 'dynamic component via <this.dynamicComponent>' ( ) {
147+ const HelloWorld = defComponent ( '{{@arg}}' ) ;
148+
149+ class Root extends GlimmerishComponent {
150+ HelloWorld = HelloWorld ;
151+ }
152+
153+ const RootDef = defComponent ( `<this.HelloWorld @arg="first"/>` , {
154+ component : Root ,
155+ emit : { moduleName : 'root.hbs' } ,
156+ } ) ;
157+
158+ this . renderComponent ( RootDef ) ;
159+
160+ const rootChildren = this . delegate . getCapturedRenderTree ( ) [ 0 ] ?. children ?? [ ] ;
161+ const componentNode = rootChildren . find (
162+ ( n : CapturedRenderNode ) => n . type === 'component' && n . name !== '{ROOT}'
163+ ) ;
164+
165+ this . assert . ok ( componentNode , 'found a component child node' ) ;
166+
167+ this . assert . strictEqual (
168+ componentNode ?. name ,
169+ 'this.HelloWorld' ,
170+ `dynamic <this.X> component name (got "${ componentNode ?. name } ")`
171+ ) ;
172+ }
173+
174+ @test ( { skip : ! DEBUG } ) 'dynamic component via <@argComponent>' ( ) {
175+ const HelloWorld = defComponent ( '{{@arg}}' ) ;
176+ const Root = defComponent ( `<@Greeting @arg="first"/>` , {
177+ emit : { moduleName : 'root.hbs' } ,
178+ } ) ;
179+
180+ this . renderComponent ( Root , { Greeting : HelloWorld } ) ;
181+
182+ const rootChildren = this . delegate . getCapturedRenderTree ( ) [ 0 ] ?. children ?? [ ] ;
183+ const componentNode = rootChildren . find (
184+ ( n : CapturedRenderNode ) => n . type === 'component' && n . name !== '{ROOT}'
185+ ) ;
186+
187+ this . assert . ok ( componentNode , 'found a component child node' ) ;
188+
189+ this . assert . strictEqual (
190+ componentNode ?. name ,
191+ '@Greeting' ,
192+ `dynamic <@X> component name (got "${ componentNode ?. name } ")`
193+ ) ;
194+ }
195+
113196 @test 'strict-mode modifiers' ( ) {
114197 const state = trackedObj ( { showSecond : false } ) ;
115198
0 commit comments