@@ -561,13 +561,15 @@ var codeInput = {
561561
562562 /**
563563 * If the color attribute has been defined on the
564- * code-input element by external code, return true.
564+ * code-input element by external code, run the callback
565+ * provided.
565566 * Otherwise, make the aspects the color affects
566567 * (placeholder and caret colour) be the base colour
567- * of the highlighted text, for best contrast, and
568- * return false.
568+ * of the highlighted text, for best contrast.
569569 */
570- isColorOverridenSyncIfNot ( ) {
570+ syncIfColorNotOverridden ( callbackIfOverridden = function ( ) { } ) {
571+ if ( this . checkingColorOverridden ) return ;
572+ this . checkingColorOverridden = true ;
571573 const oldTransition = this . style . transition ;
572574 this . style . transition = "unset" ;
573575 window . requestAnimationFrame ( ( ) => {
@@ -578,20 +580,28 @@ var codeInput = {
578580 if ( getComputedStyle ( this ) . color == "rgb(255, 255, 255)" ) {
579581 // Definitely not overriden
580582 this . internalStyle . removeProperty ( "--code-input_no-override-color" ) ;
583+ console . log ( this , "Autoadapt; " + oldTransition ) ;
581584 this . style . transition = oldTransition ;
582585
583586 const highlightedTextColor = getComputedStyle ( this . getStyledHighlightingElement ( ) ) . color ;
584587
585588 this . internalStyle . setProperty ( "--code-input_highlight-text-color" , highlightedTextColor ) ;
586589 this . internalStyle . setProperty ( "--code-input_default-caret-color" , highlightedTextColor ) ;
587- return false ;
590+ this . checkingColorOverridden = false ;
591+ } else {
592+ this . style . transition = oldTransition ;
593+ this . checkingColorOverridden = false ;
594+ callbackIfOverridden ( ) ;
588595 }
596+ } else {
597+ this . style . transition = oldTransition ;
598+ this . checkingColorOverridden = false ;
599+ callbackIfOverridden ( ) ;
589600 }
590601 this . internalStyle . removeProperty ( "--code-input_no-override-color" ) ;
602+ console . log ( this , "No autoadapt; " + oldTransition ) ;
591603 this . style . transition = oldTransition ;
592604 } ) ;
593-
594- return true ;
595605 }
596606
597607 /**
@@ -603,11 +613,11 @@ var codeInput = {
603613 */
604614 syncColorCompletely ( ) {
605615 // color of code-input element
606- if ( this . isColorOverridenSyncIfNot ( ) ) {
616+ this . syncIfColorNotOverridden ( ( ) => {
607617 // color overriden
608618 this . internalStyle . removeProperty ( "--code-input_highlight-text-color" ) ;
609619 this . internalStyle . setProperty ( "--code-input_default-caret-color" , getComputedStyle ( this ) . color ) ;
610- }
620+ } ) ;
611621 }
612622
613623
@@ -847,7 +857,6 @@ var codeInput = {
847857 resizeObserver . observe ( this ) ;
848858
849859
850- // Add internal style as non-externally-overridable alternative to style attribute for e.g. syncing color
851860 this . classList . add ( "code-input_styles_" + codeInput . stylesheetI ) ;
852861 const stylesheet = document . createElement ( "style" ) ;
853862 stylesheet . innerHTML = "code-input.code-input_styles_" + codeInput . stylesheetI + " {}" ;
@@ -858,7 +867,7 @@ var codeInput = {
858867 // Synchronise colors
859868 const preColorChangeCallback = ( evt ) => {
860869 if ( evt . propertyName == "color" ) {
861- this . isColorOverridenSyncIfNot ( ) ;
870+ this . syncIfColorNotOverridden ( ) ;
862871 }
863872 } ;
864873 this . preElement . addEventListener ( "transitionend" , preColorChangeCallback ) ;
0 commit comments