Skip to content

Commit

Permalink
fix: none image (niklasvh#2627)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasvh authored Aug 5, 2021
1 parent df223c3 commit 6651fc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/css/types/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ export const image: ITypeDescriptor<ICSSImage> = {
return imageFunction(context, value.values);
}

throw new Error(`Unsupported image type`);
throw new Error(`Unsupported image type ${value.type}`);
}
};

export function isSupportedImage(value: CSSValue): boolean {
return value.type !== TokenType.FUNCTION || !!SUPPORTED_IMAGE_FUNCTIONS[value.name];
return (
!(value.type === TokenType.IDENT_TOKEN && value.value === 'none') &&
(value.type !== TokenType.FUNCTION || !!SUPPORTED_IMAGE_FUNCTIONS[value.name])
);
}

const SUPPORTED_IMAGE_FUNCTIONS: Record<string, (context: Context, args: CSSValue[]) => ICSSImage> = {
Expand Down
1 change: 1 addition & 0 deletions tests/reftests/background/linear-gradient2.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<div style="background: linear-gradient(60deg, hsla(120,80%,50%,0.8) 0%, transparent 50%, rgba(255,100,100,0.5) 100%);"></div>
<div style="background: linear-gradient(to right, red 20%, orange 20% 40%, yellow 40% 60%, green 60% 80%, blue 80%);"></div>
<div style="background: linear-gradient(-45deg, #FF0000 40%, #00FF00 50%);"></div>
<div style="background:linear-gradient(217deg, rgba(255, 0, 0, 0.8) 10%, rgba(255, 0, 0, 0) 70.71%), linear-gradient(127deg, rgba(0, 255, 0, 0.8) 20%, rgba(0, 255, 0, 0) 70.71%), linear-gradient(336deg, rgba(0, 0, 255, 0.8) 40%, rgba(0, 0, 255, 0) 70.71%), rgb(255, 255, 255);"></div>
<div class="linearGradient"></div>
</body>
</html>

0 comments on commit 6651fc6

Please sign in to comment.