Merge pull request #21642 from Snuffleupagus/normalizeBlendMode-shorten

Reduce a tiny bit of duplication in the `normalizeBlendMode` helper
This commit is contained in:
Jonas Jenwald 2026-07-27 19:02:26 +02:00 committed by GitHub
commit a03ec7e8c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -140,52 +140,45 @@ function normalizeBlendMode(value, parsingArray = false) {
return "source-over";
}
if (!(value instanceof Name)) {
if (parsingArray) {
return null;
if (value instanceof Name) {
switch (value.name) {
case "Normal":
case "Compatible":
return "source-over";
case "Multiply":
return "multiply";
case "Screen":
return "screen";
case "Overlay":
return "overlay";
case "Darken":
return "darken";
case "Lighten":
return "lighten";
case "ColorDodge":
return "color-dodge";
case "ColorBurn":
return "color-burn";
case "HardLight":
return "hard-light";
case "SoftLight":
return "soft-light";
case "Difference":
return "difference";
case "Exclusion":
return "exclusion";
case "Hue":
return "hue";
case "Saturation":
return "saturation";
case "Color":
return "color";
case "Luminosity":
return "luminosity";
}
return "source-over";
warn(`Unsupported blend mode: ${value.name}`);
}
switch (value.name) {
case "Normal":
case "Compatible":
return "source-over";
case "Multiply":
return "multiply";
case "Screen":
return "screen";
case "Overlay":
return "overlay";
case "Darken":
return "darken";
case "Lighten":
return "lighten";
case "ColorDodge":
return "color-dodge";
case "ColorBurn":
return "color-burn";
case "HardLight":
return "hard-light";
case "SoftLight":
return "soft-light";
case "Difference":
return "difference";
case "Exclusion":
return "exclusion";
case "Hue":
return "hue";
case "Saturation":
return "saturation";
case "Color":
return "color";
case "Luminosity":
return "luminosity";
}
if (parsingArray) {
return null;
}
warn(`Unsupported blend mode: ${value.name}`);
return "source-over";
return parsingArray ? null : "source-over";
}
function addCachedImageOps(