Skip to content

Commit 26bc45c

Browse files
authored
Update 01_console.js
Upstream some changes from nodejs/node#49205 Signed-off-by: Jordan Harband <ljharb@gmail.com>
1 parent 29026fa commit 26bc45c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

ext/console/01_console.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -2742,34 +2742,34 @@ const HSL_PATTERN = new SafeRegExp(
27422742
);
27432743

27442744
function parseCssColor(colorString) {
2745-
if (MapPrototypeHas(colorKeywords, colorString)) {
2746-
colorString = MapPrototypeGet(colorKeywords, colorString);
2745+
if (colorKeywords.has(colorString)) {
2746+
colorString = colorKeywords.get(colorString);
27472747
}
27482748
// deno-fmt-ignore
27492749
const hashMatch = StringPrototypeMatch(colorString, HASH_PATTERN);
27502750
if (hashMatch != null) {
27512751
return [
2752-
Number(`0x${hashMatch[1]}`),
2753-
Number(`0x${hashMatch[2]}`),
2754-
Number(`0x${hashMatch[3]}`),
2752+
NumberParseInt(hashMatch[1], 16),
2753+
NumberParseInt(hashMatch[2], 16),
2754+
NumberParseInt(hashMatch[3], 16),
27552755
];
27562756
}
27572757
// deno-fmt-ignore
27582758
const smallHashMatch = StringPrototypeMatch(colorString, SMALL_HASH_PATTERN);
27592759
if (smallHashMatch != null) {
27602760
return [
2761-
Number(`0x${smallHashMatch[1]}${smallHashMatch[1]}`),
2762-
Number(`0x${smallHashMatch[2]}${smallHashMatch[2]}`),
2763-
Number(`0x${smallHashMatch[3]}${smallHashMatch[3]}`),
2761+
NumberParseInt(`${smallHashMatch[1]}${smallHashMatch[1]}`, 16),
2762+
NumberParseInt(`${smallHashMatch[2]}${smallHashMatch[2]}`, 16),
2763+
NumberParseInt(`${smallHashMatch[3]}${smallHashMatch[3]}`, 16),
27642764
];
27652765
}
27662766
// deno-fmt-ignore
27672767
const rgbMatch = StringPrototypeMatch(colorString, RGB_PATTERN);
27682768
if (rgbMatch != null) {
27692769
return [
2770-
MathRound(MathMax(0, MathMin(255, Number(rgbMatch[1])))),
2771-
MathRound(MathMax(0, MathMin(255, Number(rgbMatch[2])))),
2772-
MathRound(MathMax(0, MathMin(255, Number(rgbMatch[3])))),
2770+
MathRound(MathMax(0, MathMin(255, rgbMatch[1]))),
2771+
MathRound(MathMax(0, MathMin(255, rgbMatch[2]))),
2772+
MathRound(MathMax(0, MathMin(255, rgbMatch[3]))),
27732773
];
27742774
}
27752775
// deno-fmt-ignore
@@ -2780,8 +2780,8 @@ function parseCssColor(colorString) {
27802780
if (h < 0) {
27812781
h += 360;
27822782
}
2783-
const s = MathMax(0, MathMin(100, Number(hslMatch[2]))) / 100;
2784-
const l = MathMax(0, MathMin(100, Number(hslMatch[3]))) / 100;
2783+
const s = MathMax(0, MathMin(100, hslMatch[2])) / 100;
2784+
const l = MathMax(0, MathMin(100, hslMatch[3])) / 100;
27852785
const c = (1 - MathAbs(2 * l - 1)) * s;
27862786
const x = c * (1 - MathAbs((h / 60) % 2 - 1));
27872787
const m = l - c / 2;

0 commit comments

Comments
 (0)