@@ -33,20 +33,25 @@ class InElementSupportProvider {
33
33
const NewElementBuilder = this . NewElementBuilder ;
34
34
const remoteStack = [ ] ;
35
35
36
+ function createRef ( value ) {
37
+ if ( self . reference . createUnboundRef ) {
38
+ return self . reference . createUnboundRef ( value ) ;
39
+ } else {
40
+ return new self . reference . ConstReference ( value ) ;
41
+ }
42
+ }
43
+
36
44
const didAppendNode = NewElementBuilder . prototype . didAppendNode ;
37
45
NewElementBuilder . prototype . didAppendNode = function ( ...args ) {
38
- const debugRenderTree =
39
- this . env ?. debugRenderTree || this . env ?. extra ?. debugRenderTree ;
46
+ const debugRenderTree = self . debugRenderTree ;
40
47
const parent = debugRenderTree . stack . current ;
41
48
args [ 0 ] . __emberInspectorParentNode = debugRenderTree . nodeFor ( parent ) ;
42
49
return didAppendNode . call ( this , ...args ) ;
43
50
} ;
44
51
45
52
const pushElement = NewElementBuilder . prototype . pushElement ;
46
53
NewElementBuilder . prototype . pushElement = function ( ...args ) {
47
- const debugRenderTree =
48
- this . env ?. debugRenderTree || this . env ?. extra ?. debugRenderTree ;
49
- // for first push element, .env is not yet set...
54
+ const debugRenderTree = self . debugRenderTree ;
50
55
if ( debugRenderTree ) {
51
56
const parent = debugRenderTree . stack . current ;
52
57
args [ 0 ] . __emberInspectorParentNode = debugRenderTree . nodeFor ( parent ) ;
@@ -55,54 +60,51 @@ class InElementSupportProvider {
55
60
} ;
56
61
57
62
const pushRemoteElement = NewElementBuilder . prototype . pushRemoteElement ;
58
- NewElementBuilder . prototype . pushRemoteElement = function ( ...args ) {
59
- const element = args [ 0 ] ;
60
- remoteStack . push ( { } ) ;
61
- let capturedArgs , ref ;
62
- if ( self . reference . createUnboundRef ) {
63
- ref = self . reference . createUnboundRef ?. ( element ) ;
64
- capturedArgs = {
65
- positional : [ ] ,
66
- named : {
67
- destination : ref ,
68
- } ,
69
- } ;
70
- } else {
71
- ref = new self . reference . ConstReference ( ( ) => element ) ;
72
- capturedArgs = {
73
- value ( ) {
74
- return {
75
- positional : [ ] ,
76
- named : {
77
- destination : ref ,
78
- } ,
79
- } ;
80
- } ,
81
- } ;
63
+ NewElementBuilder . prototype . pushRemoteElement = function (
64
+ element ,
65
+ guid ,
66
+ insertBefore
67
+ ) {
68
+ remoteStack . push ( { element } ) ;
69
+ const ref = createRef ( element ) ;
70
+ const capturedArgs = {
71
+ positional : [ ref ] ,
72
+ named : { } ,
73
+ } ;
74
+ if ( insertBefore ) {
75
+ capturedArgs . named . insertBefore = insertBefore ;
82
76
}
83
- const debugRenderTree =
84
- this . env ?. debugRenderTree || this . env ?. extra ?. debugRenderTree ;
77
+ const inElementArgs = self . reference . createUnboundRef
78
+ ? capturedArgs
79
+ : {
80
+ value ( ) {
81
+ return capturedArgs ;
82
+ } ,
83
+ } ;
84
+ const debugRenderTree = self . debugRenderTree ;
85
85
debugRenderTree ?. create ( remoteStack . at ( - 1 ) , {
86
- type : 'remote-element ' ,
86
+ type : 'keyword ' ,
87
87
name : 'in-element' ,
88
- args : capturedArgs ,
88
+ args : inElementArgs ,
89
89
instance : {
90
90
args : {
91
- destination : element ,
91
+ named : {
92
+ insertBefore,
93
+ } ,
94
+ positional : [ element ] ,
92
95
} ,
93
96
constructor : {
94
97
name : 'InElement' ,
95
98
} ,
96
99
} ,
97
100
} ) ;
98
- return pushRemoteElement . call ( this , ... args ) ;
101
+ return pushRemoteElement . call ( this , element , guid , insertBefore ) ;
99
102
} ;
100
103
101
104
const popRemoteElement = NewElementBuilder . prototype . popRemoteElement ;
102
105
NewElementBuilder . prototype . popRemoteElement = function ( ...args ) {
103
106
const element = this . element ;
104
- const debugRenderTree =
105
- this . env ?. debugRenderTree || this . env ?. extra ?. debugRenderTree ;
107
+ const debugRenderTree = self . debugRenderTree ;
106
108
debugRenderTree ?. didRender ( remoteStack . at ( - 1 ) , {
107
109
parentElement : ( ) => element . parentElement ,
108
110
firstNode : ( ) => element ,
@@ -409,7 +411,7 @@ export default class RenderTree {
409
411
410
412
if ( serialized === undefined ) {
411
413
this . nodes [ node . id ] = node ;
412
- if ( node . type === 'remote-element ' ) {
414
+ if ( node . type === 'keyword ' ) {
413
415
node . type = 'component' ;
414
416
this . inElementSupport ?. nodeMap . set ( node , node . id ) ;
415
417
this . inElementSupport ?. remoteRoots . push ( node ) ;
0 commit comments