Skip to content

transition() on attr transform is losing separators in transform list (?). #1472

Closed

Description

@sean-en

Not sure if this is a bug, etc.

When doing a transition on an SVG transform, with both a translate and a rotate, the comma/space separating the translate and rotate is not preserved.

http://jsfiddle.net/peTQL/1/
Here the transition goes from "translate(60,60),rotate(0)" to "translate(80,80),rotate(-90)"
and produces (on inspecting the element) "translate(80,80)rotate(-90)", missing the comma.

While this does not effect the resulting web page in the browser, it is part of the standard ("The individual transform definitions are separated by whitespace and/or a comma.", http://www.w3.org/TR/SVG/coords.html#TransformAttribute) and the comma not being there is causing problems elsewhere.

Activity

  1. mbostock commented on Aug 21, 2013

    @mbostock
    Member

    In the past, some browsers munged the transform attribute, so it was necessary to support transform interpolation explicitly for transitions (see #344). Also, we wanted to support CSS3-style transform interpolation rather than naïve string-based interpolation, which required converting the transform to a standard representation.

    You seem to be correct in that at least one whitespace or comma is required by the specification. However, it doesn’t seem that any browser enforces this strictly, instead treating the whitespace between individual transforms as optional.

    We could fix this in d3.transform and d3.interpolateTransform, but I’m curious to understand exactly how this is breaking something (rather than violating a part of the spec that I’ve never seen enforced).

  2. sean-en commented on Aug 22, 2013

    @sean-en
    Author

    Sorry, I should have made it clearer It's causing problems with libraries (which I'm using for client side saving of the SVG) which assume the presence of the white space.

    I was pointing it out in case it wasn't intended, since there is a reason for it ( #344) I can just bodge the comma back in afterwards.

    Thanks for the swift response.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions