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

baseVal not supported #32

Open
nornagon opened this issue Mar 12, 2019 · 3 comments
Open

baseVal not supported #32

nornagon opened this issue Mar 12, 2019 · 3 comments

Comments

@nornagon
Copy link

nornagon commented Mar 12, 2019

I'm using path-data-polyfill, which uses baseVal to get x/y/width/height/etc. values from <rect>, <ellipse>, etc. elements. It would be great to implement this in svgdom!

@Fuzzyma
Copy link
Member

Fuzzyma commented Mar 13, 2019

Unfortunately that's not as easy as it sounds. You basically need to intercept all access to the node to return the correct attribute.
Feel free to open a PR to implement this feature!

@nornagon
Copy link
Author

It looks like HTMLLinkElement exposes some direct properties, could baseVal be handled in a similar manner?

The properties for which baseVal works are quite limited and well-defined per element type, at least for shapes:

  • rect - x, y, width, height, rx, ry
  • circle - cx, cy, r
  • ellipse - cx, cy, rx, ry
  • path - none
  • line - x1, y1, x2, y2
  • polyline - none
  • polygon - none

baseVal is useful for parsing SVG lengths, as in <rect width="10cm" height="10cm"/>. getAttribute works fine for the raw value but it would be great if svgdom could handle the lengths.

@Fuzzyma
Copy link
Member

Fuzzyma commented Mar 15, 2019

There is more. Everything in svg is animatable. Everything which is animatable has baseVal and animVal properties. For e.g. polygon you have points with a pointlist which of it also has x and y.
I think its not as easy as you think it is. But if you want enhance a special bit of svgdom you are welcome to do so. If you only need some properties, just add them :)

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

2 participants