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

data-uri won't accept fragment identifiers in URLs #1959

Closed
regiskuckaertz opened this issue Apr 8, 2014 · 3 comments · Fixed by #2136
Closed

data-uri won't accept fragment identifiers in URLs #1959

regiskuckaertz opened this issue Apr 8, 2014 · 3 comments · Fixed by #2136

Comments

@regiskuckaertz
Copy link

Hello, so this issue appears not to have been reported before. I'm using grunt-contrib-less v0.10 which uses LESS v1.6 behind the scene. This issue won't happen in the browser since data-uri won't try to resolve the file path in that case, thus I'm unable to reproduce it in less2css.org, sorry.

I'm using SVG filters for a project and, rather than embedding the SVG definitions in the HTML, I'd rather inline it in the CSS. Like so:

.element {
  filter: url('data:image/svg+xml,%3Csvg%20...#blur');
}

I tried using data-uri, like so:

.element {
  filter: data-uri('image/svg+xml', 'filters.svg#blur');
}

but the pre-processor stops with a "File not found" error. The solution I suppose would be to:

1 detect if there's a fragment identifier in filePathNode
2 save it for later and truncate the value accordingly
3 process as usual
4 append the fragment ID to the generated URI

I will try to find time to update the code by myself but I'm quite in a hurry right now, at least I wanted to report the issue.

@lukeapage
Copy link
Member

Thanks, whats the fragment used for? (just because I haven't come across it myself)

@regiskuckaertz
Copy link
Author

It is needed everywhere CSS and SVG join forces: masks, clipping paths, filters, ... For instance:

<svg>
 <defs>
  <clipPath id="circle">
    <circle r="50" cx="50" cy="50"></circle>
  </clipPath>
 </defs>
<svg>

Then in CSS:

.avatar {
  clip-path: url("mask.svg#circle");
}

(HTML5 Rocks has "everything covered")

@lukeapage
Copy link
Member

Ok, we should fix it then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants