@@ -6,28 +6,27 @@ import { Opaque, Option, Simple } from '@glimmer/interfaces';
6
6
import { CachedReference , combine , map , Reference , Tag } from '@glimmer/reference' ;
7
7
import { ElementOperations , PrimitiveReference } from '@glimmer/runtime' ;
8
8
import { Core , Ops } from '@glimmer/wire-format' ;
9
- import { ROOT_REF } from '../component' ;
10
9
import { Component } from './curly-component-state-bucket' ;
11
- import { referenceFromParts } from './references' ;
10
+ import { referenceFromParts , RootReference } from './references' ;
12
11
import { htmlSafe , isHTMLSafe , SafeString } from './string' ;
13
12
14
- export function referenceForKey ( component : Component , key : string ) {
15
- return component [ ROOT_REF ] . get ( key ) ;
13
+ export function referenceForKey ( rootRef : RootReference < Component > , key : string ) {
14
+ return rootRef . get ( key ) ;
16
15
}
17
16
18
- function referenceForParts ( component : Component , parts : string [ ] ) : Reference {
17
+ function referenceForParts ( rootRef : RootReference < Component > , parts : string [ ] ) : Reference {
19
18
let isAttrs = parts [ 0 ] === 'attrs' ;
20
19
21
20
// TODO deprecate this
22
21
if ( isAttrs ) {
23
22
parts . shift ( ) ;
24
23
25
24
if ( parts . length === 1 ) {
26
- return referenceForKey ( component , parts [ 0 ] ) ;
25
+ return referenceForKey ( rootRef , parts [ 0 ] ) ;
27
26
}
28
27
}
29
28
30
- return referenceFromParts ( component [ ROOT_REF ] , parts ) ;
29
+ return referenceFromParts ( rootRef , parts ) ;
31
30
}
32
31
33
32
// TODO we should probably do this transform at build time
@@ -81,6 +80,7 @@ export const AttributeBinding = {
81
80
install (
82
81
_element : Simple . Element ,
83
82
component : Component ,
83
+ rootRef : RootReference < Component > ,
84
84
parsed : [ string , string , boolean ] ,
85
85
operations : ElementOperations
86
86
) {
@@ -99,8 +99,8 @@ export const AttributeBinding = {
99
99
100
100
let isPath = prop . indexOf ( '.' ) > - 1 ;
101
101
let reference = isPath
102
- ? referenceForParts ( component , prop . split ( '.' ) )
103
- : referenceForKey ( component , prop ) ;
102
+ ? referenceForParts ( rootRef , prop . split ( '.' ) )
103
+ : referenceForKey ( rootRef , prop ) ;
104
104
105
105
assert (
106
106
`Illegal attributeBinding: '${ prop } ' is not a valid attribute name.` ,
@@ -114,7 +114,7 @@ export const AttributeBinding = {
114
114
) {
115
115
reference = new StyleBindingReference (
116
116
reference ,
117
- referenceForKey ( component , 'isVisible' ) ,
117
+ referenceForKey ( rootRef , 'isVisible' ) ,
118
118
component
119
119
) ;
120
120
}
@@ -134,16 +134,14 @@ let StyleBindingReference:
134
134
if ( EMBER_COMPONENT_IS_VISIBLE ) {
135
135
StyleBindingReference = class extends CachedReference < string | SafeString > {
136
136
public tag : Tag ;
137
- private component : Component ;
138
137
constructor (
139
138
private inner : Reference < string > ,
140
139
private isVisible : Reference < Opaque > ,
141
- component : Component
140
+ private component : Component
142
141
) {
143
142
super ( ) ;
144
143
145
144
this . tag = combine ( [ inner . tag , isVisible . tag ] ) ;
146
- this . component = component ;
147
145
}
148
146
149
147
compute ( ) : string | SafeString {
@@ -179,20 +177,30 @@ if (EMBER_COMPONENT_IS_VISIBLE) {
179
177
export let IsVisibleBinding :
180
178
| undefined
181
179
| {
182
- install ( element : Simple . Element , component : Component , operations : ElementOperations ) : void ;
180
+ install (
181
+ element : Simple . Element ,
182
+ component : Component ,
183
+ rootRef : RootReference < Component > ,
184
+ operations : ElementOperations
185
+ ) : void ;
183
186
mapStyleValue ( isVisible : boolean , component : Component ) : SafeString | null ;
184
187
} ;
185
188
186
189
if ( EMBER_COMPONENT_IS_VISIBLE ) {
187
190
IsVisibleBinding = {
188
- install ( _element : Simple . Element , component : Component , operations : ElementOperations ) {
191
+ install (
192
+ _element : Simple . Element ,
193
+ component : Component ,
194
+ rootRef : RootReference < Component > ,
195
+ operations : ElementOperations
196
+ ) {
189
197
let componentMapStyleValue = ( isVisible : boolean ) => {
190
198
return this . mapStyleValue ( isVisible , component ) ;
191
199
} ;
192
200
193
201
operations . setAttribute (
194
202
'style' ,
195
- map ( referenceForKey ( component , 'isVisible' ) , componentMapStyleValue ) ,
203
+ map ( referenceForKey ( rootRef , 'isVisible' ) as any , componentMapStyleValue ) ,
196
204
false ,
197
205
null
198
206
) ;
@@ -219,7 +227,7 @@ if (EMBER_COMPONENT_IS_VISIBLE) {
219
227
export const ClassNameBinding = {
220
228
install (
221
229
_element : Simple . Element ,
222
- component : Component ,
230
+ rootRef : RootReference < Component > ,
223
231
microsyntax : string ,
224
232
operations : ElementOperations
225
233
) {
@@ -231,7 +239,7 @@ export const ClassNameBinding = {
231
239
} else {
232
240
let isPath = prop . indexOf ( '.' ) > - 1 ;
233
241
let parts = isPath ? prop . split ( '.' ) : [ ] ;
234
- let value = isPath ? referenceForParts ( component , parts ) : referenceForKey ( component , prop ) ;
242
+ let value = isPath ? referenceForParts ( rootRef , parts ) : referenceForKey ( rootRef , prop ) ;
235
243
let ref ;
236
244
237
245
if ( truthy === undefined ) {
0 commit comments