File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,7 @@ class QuiCodeBlock extends LitElement {
6262
6363 connectedCallback ( ) {
6464 super . connectedCallback ( ) ;
65+ this . _updateSlotContent ( ) ;
6566 if ( this . src ) {
6667 // if mode is not provided, figure is out
6768 if ( ! this . mode ) {
@@ -83,7 +84,12 @@ class QuiCodeBlock extends LitElement {
8384 } else {
8485 this . _basicTheme = basicDark ;
8586 }
86-
87+ const slot = this . shadowRoot . querySelector ( 'slot' ) ;
88+ if ( slot ) {
89+ slot . addEventListener ( 'slotchange' , ( ) => {
90+ this . _updateSlotContent ( ) ;
91+ } ) ;
92+ }
8793 }
8894
8995 disconnectedCallback ( ) {
@@ -94,13 +100,17 @@ class QuiCodeBlock extends LitElement {
94100 }
95101
96102 firstUpdated ( ) {
97-
103+ this . _updateSlotContent ( ) ;
104+ }
105+
106+ _updateSlotContent ( ) {
98107 // See if the content is provided in a slot
99108 const slotValue = this . shadowRoot . getElementById ( 'slotContent' ) ;
100109 if ( slotValue ) {
101110 const v = slotValue . assignedNodes ( ) [ 1 ] ;
102111 if ( v && v . textContent ) {
103112 this . content = this . _removeEmptyLines ( v . textContent ) ;
113+ this . _updateContent ( ) ;
104114 }
105115 }
106116
You can’t perform that action at this time.
0 commit comments