Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: css url() support # prefix url #949

Merged
merged 2 commits into from
Mar 14, 2024
Merged

fix: css url() support # prefix url #949

merged 2 commits into from
Mar 14, 2024

Conversation

sorrycc
Copy link
Member

@sorrycc sorrycc commented Mar 14, 2024

背景:

antd 组件里有用到,针对 svg 的样式中有 fill: url(#gradientXXX) 的用法,目的是取 svg 的一部分作为 fill 的内容。我们之前的实现忽略了 # 的处理,会去做 resolve,然后报错。

分析:

尝试彻底解这个问题,对 js 和 css 的场景做了下分析。

1、css 下通过 @import '#a' 用在属性值里用 url(#a) 都会原样保留下来。

@import '#a';
svg {
  fill: url(#a);
}

2、js 里用了 #a 会报错。

import '#a';

所以要只针对 css 处理 #,而 js 保留现状。

@sorrycc sorrycc merged commit 4e7efb5 into master Mar 14, 2024
8 checks passed
@delete-merged-branch delete-merged-branch bot deleted the sorrycc-5cih branch March 14, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant