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

not able to use addAttributes plugin #583

Closed
gjjones opened this issue Aug 26, 2016 · 11 comments
Closed

not able to use addAttributes plugin #583

gjjones opened this issue Aug 26, 2016 · 11 comments

Comments

@gjjones
Copy link
Contributor

gjjones commented Aug 26, 2016

The addAttributesToSVGElement plugin will not function without first being defined in the .svgo.yml defaults file.

This should just need to be added to the default plugins config to be allowed for use.

@stephan-v
Copy link

Any update on this? It does not work and I have no idea where to find the .svgo.yml file.

@gjjones
Copy link
Contributor Author

gjjones commented Oct 17, 2016

What svgo version are you using? The plugin is available as of 7.0.1. There is a file named .svgo.yml in the base directory of your svgo installation. Near the bottom of that file is a line that reads - addAttributesToSVGElement. I'd be curious to know if it' there.

@GreLI
Copy link
Member

GreLI commented Oct 17, 2016

You can also enable it in your own config file or through --enable option (as of v0.7.1).

@stephan-v
Copy link

I pulled it in via imagemin and imagemin grabs imagemin-svgo: 5.1.0 which in turns grabbed svgo 0.7.0.

I guess that's where the problem is.

I've added it myself to the file but it does not work properly though.

If I try this:

{
    addAttributesToSVGElement: {
        attribute: ["mySvg", "test"]
    }
}

I will get an error:
Error in parsing SVG: Invalid attribute name

If I try this:

{
    addAttributesToSVGElement: {
        attributes: ["mySvg", "size-big"]
    }
}

I will get an error:
Error in parsing SVG: Attribute without value

Am I using it wrongly here?

@gjjones
Copy link
Contributor Author

gjjones commented Oct 18, 2016

Are you able to put this up as a minimal example in a gist or repo? I'll happily take a look to see what's going on, but I'm having trouble understanding from what you've said.

Also, the first example of attribute expects a single string. attributes will accept and array and add all of them.

@gjjones
Copy link
Contributor Author

gjjones commented Oct 18, 2016

Nevermind, easy enough to repro.

@stephan-v
Copy link

Yes I thought so as well with the single string for a single attribute and I tried that as well but it does not work. This is repo where my gulpfile is located:

https://github.com/stephan-v/svg-workflow

You can take a look if you want. I will try to see why it is not working.

@GreLI GreLI closed this as completed Nov 20, 2016
@Matt-Butler
Copy link

I am also getting this issue. What was the resolution to using the addAttributes plugin?

@Matt-Butler
Copy link

{
      addAttributesToSVGElement: {
        attributes: [`mirror-on-bidi="true"`, `is-static="true"`]
      }
    }

The code above works, but I am unable to add an attribute without a value.

@stephan-v
Copy link

This was never resolved since I used this for a research project. I am afraid that the current implementation is broken/unfinished.

@mpodciwinski
Copy link

the problem still occurs, solution?

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

No branches or pull requests

5 participants