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

SVG id attribut is missing #2285

Closed
dgodard opened this issue Jun 12, 2015 · 5 comments · Fixed by #2317
Closed

SVG id attribut is missing #2285

dgodard opened this issue Jun 12, 2015 · 5 comments · Fixed by #2317
Labels

Comments

@dgodard
Copy link

dgodard commented Jun 12, 2015

I want to manage my object imported from SVG by their ID.
But, the 'id' attribute is missing in FabricsJS.

The SVG 'id' attribute is removed in parseUseDirectives function by the line : el2.removeAttribute('id');

@asturur
Copy link
Member

asturur commented Jun 12, 2015

that line should remove id attribute from cloned object that was referenced by use tag. it is correct like that.

the id attribute is not parsed. please check the parsedAttribute array and add "id" there.

check any object fromElement method to see the corret spelling of this array name.

@dgodard
Copy link
Author

dgodard commented Jun 15, 2015

The parsed attributes used by fromElement are defined in fabric.SHARED_ATTRIBUTES (in header.js).

This is my modified version :

/* _FROM_SVG_START_ */
/**
 * Attributes parsed from all SVG elements
 * @type array
 */
fabric.SHARED_ATTRIBUTES = [
  "id",
  "display",
  "transform",
  "fill", "fill-opacity", "fill-rule",
  "opacity",
  "stroke", "stroke-dasharray", "stroke-linecap",
  "stroke-linejoin", "stroke-miterlimit",
  "stroke-opacity", "stroke-width"
];
/* _FROM_SVG_END_ */

Do you think I have to modify object.class.js to manage it as default property of an object ?

@asturur
Copy link
Member

asturur commented Jun 15, 2015

i do not know why is not parsed by default.
We should discuss if it is worth parsing, or if you have to extend the class and override it.

maybe a

fabric.SHARED_ATTRIBUTE.push('id');

in your application is enough.

@kangax
Copy link
Member

kangax commented Jul 1, 2015

I wouldn'd mind adding support for parsing id! Marking as feature.

@kangax kangax added the feature label Jul 1, 2015
@asturur
Copy link
Member

asturur commented Jul 1, 2015

Ok i do a quick PR.

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

Successfully merging a pull request may close this issue.

3 participants