fix: none image (#2627)

This commit is contained in:
Niklas von Hertzen 2021-08-05 09:30:22 +08:00 committed by GitHub
parent df223c3ff2
commit 6651fc6789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -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> = {

View File

@ -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>