@@ -11,6 +11,8 @@ import { UUIIconRegistry } from './UUIIconRegistry';
11
11
export class UUIIconRegistryElement extends LitElement {
12
12
/**
13
13
* Provide a Dictionary/Record/Object where key is the icon name and the value is the SVGs to define in the icon registry.
14
+ * @type {Record<string, string> }
15
+ * @default {}
14
16
*/
15
17
@property ( { attribute : false } )
16
18
private _icons : Record < string , string > = { } ;
@@ -20,38 +22,28 @@ export class UUIIconRegistryElement extends LitElement {
20
22
set icons ( icons ) {
21
23
this . _icons = icons ;
22
24
if ( this . _registry ) {
23
- this . defineIconsInRegistry ( ) ;
25
+ Object . entries ( this . _icons ) . forEach ( ( [ key , value ] ) =>
26
+ this . _registry . defineIcon ( key , value )
27
+ ) ;
24
28
}
25
29
}
26
30
27
- private defineIconsInRegistry ( ) {
28
- Object . entries ( this . _icons ) . forEach ( ( [ key , value ] ) =>
29
- this . _registry . defineIcon ( key , value )
30
- ) ;
31
- }
32
-
33
31
private _registry : UUIIconRegistry = new UUIIconRegistry ( ) ;
34
32
35
33
public get registry ( ) : UUIIconRegistry {
36
34
return this . _registry ;
37
35
}
38
36
public set registry ( newRegistry : UUIIconRegistry ) {
39
- if ( this . shadowRoot ) {
40
- if ( this . registry ) {
41
- this . registry . detach ( this ) ;
42
- }
43
- newRegistry . attach ( this ) ;
37
+ if ( this . registry ) {
38
+ this . registry . detach ( this ) ;
44
39
}
40
+ newRegistry . attach ( this ) ;
45
41
this . _registry = newRegistry ;
46
42
}
47
43
48
- connectedCallback ( ) : void {
49
- super . connectedCallback ( ) ;
50
- this . registry . attach ( this ) ;
51
- }
52
- disconnectedCallback ( ) : void {
53
- super . disconnectedCallback ( ) ;
54
- this . registry . detach ( this ) ;
44
+ constructor ( ) {
45
+ super ( ) ;
46
+ this . _registry . attach ( this ) ;
55
47
}
56
48
57
49
render ( ) {
0 commit comments