flobacher / SVGInjector2

Fast, caching, dynamic inline SVG DOM injection library
MIT License
57 stars 8 forks source link

Copy all Attributes #4

Closed flobacher closed 7 years ago

flobacher commented 8 years ago

Copy all the attributes of the target HTML-Tag to the injected SVG

ghost commented 7 years ago

Hi @flobacher I'm looking to do something like this, mainly I want the onClick attribute. Would you like me to submit a PR for this?

flobacher commented 7 years ago

This would be great!Thank you very much in advance!Regards, FlorianOn Jan 24, 2017 5:32 AM, Michael Baldwin notifications@github.com wrote:Hi @flobacher I'm looking to do something like this, mainly I want the onClick attribute. Would you like me to submit a PR for this?

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

ghost commented 7 years ago

Fork of a Fork

Ok so I already forked the original SVGInjector repo and when I go to fork this repo, I get this warning:

screen shot 2017-01-25 at 18 39 36

Which Path

I'm not sure on how best to bring my fork up to date with your fork. So I see two paths from here:

  1. You could help advise me on where to go from here so I can submit the PR.

  2. I provide you with the necessary code and you can make the change.

This line is the one that needs updating. Here would be the fastest, simple fix to include all attributes.

var imgData = [].filter.call(el.attributes, function (at) {
  return true;
});
flobacher commented 7 years ago

hey! thx.. I take a look at it.. copying of attributes, happens in other places as well, so I have to do some more changes and test afterwards.. Concerning PRs.. you can just fork my Repo, since my version will not be merged back to the original svg-repo (created ad PR and asked for it, but it was ignored ever since, so I gave up)

ghost commented 7 years ago

Too bad, this repo has a lot of great fixes to the original SVGInjector 😢 I think the original repo has been abandoned by its maintainer though.

In terms of this issue, I've found a temporary fix by wrapping svg elements in a div container, which lets me handle onClick and other attributes. Thus, I won't be pursuing a PR on this anymore. I'll let you know if I need this and come back to it.

Thanks!