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

Trim issue in parseStyleString while parseSVGdocument #2241

Closed
maertz opened this issue May 28, 2015 · 4 comments · Fixed by #2256
Closed

Trim issue in parseStyleString while parseSVGdocument #2241

maertz opened this issue May 28, 2015 · 4 comments · Fixed by #2256

Comments

@maertz
Copy link

maertz commented May 28, 2015

Safari 5 fails on "parseSVGdocument" while it tries to "parseStyleString".

You except always to have at least two elements while splitting the "chunk" but for some reason in Safari 5 it returns just a single empty string, not sure why was to lazy to fully trace it down.

Following simple check worked for me on Line: 3089

  function parseStyleString(style, oStyle) {
    var attr, value;
    style.replace(/;$/, '').split(';').forEach(function (chunk) {
      var pair = chunk.split(':');

      if ( pair.length > 1 ) {

        attr = normalizeAttr(pair[0].trim().toLowerCase());
        value = normalizeValue(attr, pair[1].trim());

        oStyle[attr] = value;
      }
    });
maertz added a commit to amcharts/export that referenced this issue May 28, 2015
* Added: Generalized fallback; does a lookup on the Blob constructor
* Fix: Wait for lazy images, triggers capture callback only when all
images have been fully loaded
* Discovered: [Safari 5
issue](fabricjs/fabric.js#2241) please adapt
fabric.js to solve it
@asturur
Copy link
Member

asturur commented May 28, 2015

sorry can you post the svg you where parsing? maybe there is some malfoned style.

@maertz
Copy link
Author

maertz commented May 28, 2015

looks like the ending whitespace on the SVG element makes the trouble, also reproducible in modern browser e.G first example.

http://codepen.io/amcharts/full/48deb24b8ea12573c230eec57194bb53/

@asturur
Copy link
Member

asturur commented Jun 1, 2015

i confirm the space is breaking import.
Also style on svg element does not have any effect on the resulting pathGroup (at least for width and height )

@maertz
Copy link
Author

maertz commented Jun 2, 2015

thanks for hanging in

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

Successfully merging a pull request may close this issue.

3 participants