Skip to content

Commit

Permalink
fix(icon): auto mask cant match data url
Browse files Browse the repository at this point in the history
  • Loading branch information
chizukicn committed Nov 28, 2023
1 parent 7c81d4b commit 95a0508
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/icon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const iconProps = defineHookProps({

export type HiIconProps = typeof iconProps;

const isSvg = (src: string) => src.endsWith(".svg") || src.startsWith("data:image/svg+xml");

export const useIcon = defineHookComponent({
props: iconProps,
setup(props, context) {
Expand All @@ -49,7 +51,7 @@ export const useIcon = defineHookComponent({
});

const dynamicStyle = computed<CSSProperties>(() => {
const mask = props.mask === "auto" ? props.src.endsWith(".svg") : props.mask;
const mask = props.mask === "auto" ? isSvg(props.src) : props.mask;
if (!mask) {
return {
"background-image": "var(--icon-url)",
Expand Down

0 comments on commit 95a0508

Please sign in to comment.