1
- import { Factory , getOwner } from '@ember/-internals/owner' ;
1
+ import { Factory , getOwner , Owner , setOwner } from '@ember/-internals/owner' ;
2
2
import { enumerableSymbol , guidFor , symbol } from '@ember/-internals/utils' ;
3
3
import { addChildView , setElementView , setViewElement } from '@ember/-internals/views' ;
4
4
import { assert , debugFreeze } from '@ember/debug' ;
@@ -131,7 +131,7 @@ type ComponentFactory = Factory<
131
131
132
132
export default class CurlyComponentManager
133
133
implements
134
- WithCreateInstance < ComponentStateBucket , Environment > ,
134
+ WithCreateInstance < ComponentStateBucket > ,
135
135
WithDynamicLayout < ComponentStateBucket , RuntimeResolver > ,
136
136
WithDynamicTagName < ComponentStateBucket > {
137
137
protected templateFor ( component : Component ) : CompilableProgram | null {
@@ -250,9 +250,10 @@ export default class CurlyComponentManager
250
250
* etc.
251
251
*/
252
252
create (
253
- environment : Environment ,
253
+ owner : Owner ,
254
254
ComponentClass : ComponentFactory ,
255
255
args : VMArguments ,
256
+ { isInteractive } : Environment ,
256
257
dynamicScope : DynamicScope ,
257
258
callerSelfRef : Reference ,
258
259
hasBlock : boolean
@@ -285,6 +286,8 @@ export default class CurlyComponentManager
285
286
// `_target`, so bubbled actions are routed to the right place.
286
287
props . _target = valueForRef ( callerSelfRef ) ;
287
288
289
+ setOwner ( props , owner ) ;
290
+
288
291
// caller:
289
292
// <FaIcon @name="bug" />
290
293
//
@@ -314,26 +317,26 @@ export default class CurlyComponentManager
314
317
315
318
// We usually do this in the `didCreateElement`, but that hook doesn't fire for tagless components
316
319
if ( ! hasWrappedElement ) {
317
- if ( environment . isInteractive ) {
320
+ if ( isInteractive ) {
318
321
component . trigger ( 'willRender' ) ;
319
322
}
320
323
321
324
component . _transitionTo ( 'hasElement' ) ;
322
325
323
- if ( environment . isInteractive ) {
326
+ if ( isInteractive ) {
324
327
component . trigger ( 'willInsertElement' ) ;
325
328
}
326
329
}
327
330
328
331
// Track additional lifecycle metadata about this component in a state bucket.
329
332
// Essentially we're saving off all the state we'll need in the future.
330
333
let bucket = new ComponentStateBucket (
331
- environment ,
332
334
component ,
333
335
capturedArgs ,
334
336
argsTag ,
335
337
finalizer ,
336
- hasWrappedElement
338
+ hasWrappedElement ,
339
+ isInteractive
337
340
) ;
338
341
339
342
if ( args . named . has ( 'class' ) ) {
@@ -344,7 +347,7 @@ export default class CurlyComponentManager
344
347
processComponentInitializationAssertions ( component , props ) ;
345
348
}
346
349
347
- if ( environment . isInteractive && hasWrappedElement ) {
350
+ if ( isInteractive && hasWrappedElement ) {
348
351
component . trigger ( 'willRender' ) ;
349
352
}
350
353
@@ -368,7 +371,7 @@ export default class CurlyComponentManager
368
371
}
369
372
370
373
didCreateElement (
371
- { component, classRef, environment , rootRef } : ComponentStateBucket ,
374
+ { component, classRef, isInteractive , rootRef } : ComponentStateBucket ,
372
375
element : SimpleElement ,
373
376
operations : ElementOperations
374
377
) : void {
@@ -411,7 +414,7 @@ export default class CurlyComponentManager
411
414
412
415
component . _transitionTo ( 'hasElement' ) ;
413
416
414
- if ( environment . isInteractive ) {
417
+ if ( isInteractive ) {
415
418
beginUntrackFrame ( ) ;
416
419
component . trigger ( 'willInsertElement' ) ;
417
420
endUntrackFrame ( ) ;
@@ -423,16 +426,16 @@ export default class CurlyComponentManager
423
426
bucket . finalize ( ) ;
424
427
}
425
428
426
- didCreate ( { component, environment } : ComponentStateBucket ) : void {
427
- if ( environment . isInteractive ) {
429
+ didCreate ( { component, isInteractive } : ComponentStateBucket ) : void {
430
+ if ( isInteractive ) {
428
431
component . _transitionTo ( 'inDOM' ) ;
429
432
component . trigger ( 'didInsertElement' ) ;
430
433
component . trigger ( 'didRender' ) ;
431
434
}
432
435
}
433
436
434
437
update ( bucket : ComponentStateBucket ) : void {
435
- let { component, args, argsTag, argsRevision, environment } = bucket ;
438
+ let { component, args, argsTag, argsRevision, isInteractive } = bucket ;
436
439
437
440
bucket . finalizer = _instrumentStart ( 'render.component' , rerenderInstrumentDetails , component ) ;
438
441
@@ -453,7 +456,7 @@ export default class CurlyComponentManager
453
456
component . trigger ( 'didReceiveAttrs' ) ;
454
457
}
455
458
456
- if ( environment . isInteractive ) {
459
+ if ( isInteractive ) {
457
460
component . trigger ( 'willUpdate' ) ;
458
461
component . trigger ( 'willRender' ) ;
459
462
}
@@ -468,8 +471,8 @@ export default class CurlyComponentManager
468
471
bucket . finalize ( ) ;
469
472
}
470
473
471
- didUpdate ( { component, environment } : ComponentStateBucket ) : void {
472
- if ( environment . isInteractive ) {
474
+ didUpdate ( { component, isInteractive } : ComponentStateBucket ) : void {
475
+ if ( isInteractive ) {
473
476
component . trigger ( 'didUpdate' ) ;
474
477
component . trigger ( 'didRender' ) ;
475
478
}
@@ -553,6 +556,7 @@ export const CURLY_CAPABILITIES: InternalComponentCapabilities = {
553
556
createInstance : true ,
554
557
wrapped : true ,
555
558
willDestroy : true ,
559
+ hasSubOwner : false ,
556
560
} ;
557
561
558
562
export const CURLY_COMPONENT_MANAGER = new CurlyComponentManager ( ) ;
0 commit comments