File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -43,11 +43,33 @@ window.addEventListener('WebComponentsReady', function () {
4343 return 'hx-icon' ;
4444 }
4545
46+ static get observedAttributes ( ) {
47+ return [ 'type' ] ;
48+ }
49+
4650 static get icons ( ) {
4751 return icons ;
4852 }
4953
54+ constructor ( type ) {
55+ super ( ) ;
56+
57+ if ( type ) {
58+ this . setAttribute ( 'type' , type ) ;
59+ }
60+ }
61+
5062 connectedCallback ( ) {
63+ this . _render ( ) ;
64+ }
65+
66+ attributeChangedCallback ( attr , oldValue , newValue ) {
67+ if ( attr === 'type' ) {
68+ this . _render ( ) ;
69+ }
70+ }
71+
72+ _render ( ) {
5173 const type = this . getAttribute ( 'type' ) ;
5274
5375 // erase previously injected markup
@@ -63,7 +85,7 @@ window.addEventListener('WebComponentsReady', function () {
6385 // inject SVG into Light DOM
6486 this . appendChild ( svg ) ;
6587 }
66- } //connectedCallback
88+ } //_render()
6789 } //HxIcon
6890
6991 customElements . define ( HxIcon . is , HxIcon ) ;
You can’t perform that action at this time.
0 commit comments