Skip to content

Commit 28f869a

Browse files
committed
Prevent no-override-color becoming visible when transition set
1 parent b76ea47 commit 28f869a

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

code-input.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ code-input {
2424
to keep low precedence and thus overridability
2525
The variable names may change and are for internal use. */
2626
/* --code-input_highlight-text-color: Set by JS to be base text color of pre code element */
27-
--code-input_no-override-color: revert; /* Set by JS for very short time to get whether color has been overriden */
28-
color: var(--code-input_no-override-color, revert);
29-
/* --code-input_default-caret-color: Set by JS to be same as color property */
30-
caret-color: var(--code-input_default-caret-color, black); /* Set by JS to be equal to color property - currentColor won't work because it's lazily evaluated so gives transparent for the textarea */
27+
/* --code-input_no-override-color: Set by JS for very short time to get whether color has been overriden */
28+
color: var(--code-input_no-override-color, black);
29+
/* --code-input_default-caret-color: Set by JS to be same as color property - currentColor won't work because it's lazily evaluated so gives transparent for the textarea */
30+
caret-color: var(--code-input_default-caret-color, black);
3131
background-color: white;
3232

3333
/* Normal inline styles */

code-input.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -558,24 +558,26 @@ var codeInput = {
558558
isColorOverridenSyncIfNot() {
559559
const oldTransition = this.style.transition;
560560
this.style.transition = "unset";
561-
this.style.setProperty("--code-input_no-override-color", "rgb(0, 0, 0)");
562-
if(getComputedStyle(this).color == "rgb(0, 0, 0)") {
563-
// May not be overriden
564-
this.style.setProperty("--code-input_no-override-color", "rgb(255, 255, 255)");
565-
if(getComputedStyle(this).color == "rgb(255, 255, 255)") {
566-
// Definitely not overriden
567-
this.style.removeProperty("--code-input_no-override-color");
568-
this.style.transition = oldTransition;
569-
570-
const highlightedTextColor = getComputedStyle(this.getStyledHighlightingElement()).color;
571-
572-
this.style.setProperty("--code-input_highlight-text-color", highlightedTextColor);
573-
this.style.setProperty("--code-input_default-caret-color", highlightedTextColor);
574-
return false;
561+
window.requestAnimationFrame(() => {
562+
this.style.setProperty("--code-input_no-override-color", "rgb(0, 0, 0)");
563+
if(getComputedStyle(this).color == "rgb(0, 0, 0)") {
564+
// May not be overriden
565+
this.style.setProperty("--code-input_no-override-color", "rgb(255, 255, 255)");
566+
if(getComputedStyle(this).color == "rgb(255, 255, 255)") {
567+
// Definitely not overriden
568+
this.style.removeProperty("--code-input_no-override-color");
569+
this.style.transition = oldTransition;
570+
571+
const highlightedTextColor = getComputedStyle(this.getStyledHighlightingElement()).color;
572+
573+
this.style.setProperty("--code-input_highlight-text-color", highlightedTextColor);
574+
this.style.setProperty("--code-input_default-caret-color", highlightedTextColor);
575+
return false;
576+
}
575577
}
576-
}
577-
this.style.removeProperty("--code-input_no-override-color");
578-
this.style.transition = oldTransition;
578+
this.style.removeProperty("--code-input_no-override-color");
579+
this.style.transition = oldTransition;
580+
});
579581

580582
return true;
581583
}

0 commit comments

Comments
 (0)