@@ -506,18 +506,6 @@ var codeInput = {
506506 this . needsHighlight = false ;
507507 }
508508
509- // Synchronise colors
510- if ( this . textareaElement ) {
511- let color ;
512- if ( this . templateObject . preElementStyled ) {
513- color = getComputedStyle ( this . preElement ) . color ;
514- } else {
515- color = getComputedStyle ( this . codeElement ) . color ;
516- }
517- this . style . setProperty ( "--code-input_highlight-text-color" , color ) ;
518- }
519- this . style . setProperty ( "--code-input_default-caret-color" , getComputedStyle ( this ) . color ) ;
520-
521509 window . requestAnimationFrame ( this . animateFrame . bind ( this ) ) ;
522510 }
523511
@@ -749,7 +737,6 @@ var codeInput = {
749737 this . codeElement = code ;
750738 pre . append ( code ) ;
751739 this . append ( pre ) ;
752-
753740 if ( this . templateObject . isCode ) {
754741 if ( lang != undefined && lang != "" ) {
755742 code . classList . add ( "language-" + lang . toLowerCase ( ) ) ;
@@ -788,7 +775,41 @@ var codeInput = {
788775 // The only element that could be resized is this code-input element.
789776 this . syncSize ( ) ;
790777 } ) ;
791- resizeObserver . observe ( this . textareaElement ) ;
778+ resizeObserver . observe ( this ) ;
779+
780+ // Synchronise colors
781+ if ( this . templateObject . preElementStyled ) {
782+ this . preElement . addEventListener ( "transitionend" , ( evt ) => {
783+ if ( evt . propertyName == "color" ) {
784+ // So previous variable value does not affect new value:
785+ // (required to deal with color being no longer specified in CSS)
786+ this . style . removeProperty ( "--code-input_highlight-text-color" ) ;
787+
788+ console . log ( "pre" , evt , getComputedStyle ( this . preElement ) . color ) ;
789+ this . style . setProperty ( "--code-input_highlight-text-color" , getComputedStyle ( this . preElement ) . color ) ;
790+ }
791+ } ) ;
792+ } else {
793+ this . codeElement . addEventListener ( "transitionend" , ( evt ) => {
794+ if ( evt . propertyName == "color" ) {
795+ // So previous variable value does not affect new value:
796+ // (required to deal with color being no longer specified in CSS)
797+ this . style . removeProperty ( "--code-input_highlight-text-color" ) ;
798+
799+ console . log ( "code" , evt , getComputedStyle ( this . codeElement ) . color ) ;
800+ this . style . setProperty ( "--code-input_highlight-text-color" , getComputedStyle ( this . codeElement ) . color ) ;
801+ }
802+ } ) ;
803+ }
804+ // Not on this element so CSS transition property which must be set for
805+ // listener to work does not conflict with library-user transition property
806+ this . dialogContainerElement . addEventListener ( "transitionend" , ( evt ) => {
807+ if ( evt . propertyName == "color" ) {
808+ console . log ( "ci" , evt , getComputedStyle ( this ) . color ) ;
809+
810+ this . style . setProperty ( "--code-input_default-caret-color" , getComputedStyle ( this ) . color ) ;
811+ }
812+ } ) ;
792813
793814 this . classList . add ( "code-input_loaded" ) ;
794815 }
0 commit comments