-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Unbound namespace prefix: "xlink" #1730
Comments
The solution to this is probably to ignore unknown namespaces in this case. It appears there's a use-case for it, and if right now SVGO is just refusing to optimize the SVG at all, we could update it, so it just does what it can. The motivation behind the In other words, the goal is to intentionally create a malformed standalone SVG, but that will parse and render correctly with an HTML parser.
I'll give this more thought later, but the solution probably won't be to keep used namespaces. If you need them, users just shouldn't use this plugin. (It's disabled by default!) |
Why is the error occurring with module.exports = {
multipass: true,
plugins: ([
{
name: 'removeXMLNS',
active: false
},
{
name: 'reusePaths',
active: false
},
])
} |
Actually for HTML it's enough just “href” without “xlink:” prefix, which is now considered outdated. (But still probably needed for not updated software.) |
SVG 2.0 is ofiically still a draft and all common SVG 2.0-renderes work with SVG 1.1 spec does only allow As long as svgo does not declare to be a SVG2.0-only tool, which breaks SVG1.1, it should imho use |
Ahh, I misunderstood the issue. You're using the SVGO v2 config syntax in SVGO v3. Note that when the major version increments, that means there are breaking or interface changes, so it's best to read the changelog and README/documentation. The
GreLI is correct on the basis that you were enabling the See: https://svgo.dev/docs/plugins/remove-xmlns/
Good idea, this is a much better fix. I'll address this by finishing off TrySound's PR for creating a plugin to migrate from |
While the primary issue seems to be the SVGO v2 vs v3 config syntax, the issue you ran into here been resolved and will be released in SVGO v3.0.4.
|
I'm seeing the same error with this SVG using
Adding the const {data} = optimize(str, {
plugins: [
{name: "preset-default"},
{name: "removeXMLNS"},
{name: "removeDimensions"},
],
}); I think the whole |
@silverwind Hey! The error you're encountering is different from this issue. The bug reported in this issue was because the error was caused by SVGO, we broke the SVG ourselves. In the SVG you've posted, it's already malformed before SVGO can touch it. SVGO shouldn't touch malformed SVGs. We have no way of knowing what the user wants. It's better if they're given an error message that their SVG is malformed so they can fix it before going through SVGO, which is exactly what it's doing now.
I recommend you fix the SVG by either adding the XLink namespace, or removing references to XLink yourself, depending on whether they should be rendered or not. |
@SethFalco thanks. I've replaced that SVG with a different, valid one now. Though, it does render in all browsers that I've tested (Firefox, Chrome, Safari), so I think they are just more lenient towards this error than svgo. |
No actually! Browsers just ignore explicit namespaces and prefixes because it's not supported in the HTML spec. Browsers have to infer the namespace by usage, which is why it works. For example, Meanwhile, the SVG should fail to parse correctly by non HTML clients, like SVG editors and desktop applications.
|
Confirm fix with 3.2.0. |
Describe the bug
svgo does not create an output of https://camo.githubusercontent.com/48fff2a348143da7155275645da575b81276b9810d1e9f8b38547e34c9aaacb8/68747470733a2f2f7376672e6769746875622e696f2f7376676f2d6c6f676f2e737667 with
multipass: true
To Reproduce
svgo -i input.svg -o output.svg
with input.svg and svgo.config.js.txt
Expected behavior
Don't delete
xmlns:xlink="http://www.w3.org/1999/xlink"
in<svg
if some child-elements usexlink:href="
Screenshots
Desktop:
copyright
source: #1336 (comment)
author: unkown, maybe
<!-- ! https://github.com/svg/svgo --><!-- ! SVGO project logo by Yegor Bolshakov (http://xizzzy.ru/) -->
or André Castillolicense: assuming MIT License
The text was updated successfully, but these errors were encountered: