<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>183237</bug_id>
          
          <creation_ts>2018-02-28 18:10:54 -0800</creation_ts>
          <short_desc>Nested CSS transforms on SVG elements not updated after page load</short_desc>
          <delta_ts>2020-12-22 08:02:28 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>SVG</component>
          <version>Safari 11</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Amit Patel">redblobgames</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>duvrai</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1402805</commentid>
    <comment_count>0</comment_count>
      <attachid>334792</attachid>
    <who name="Amit Patel">redblobgames</who>
    <bug_when>2018-02-28 18:10:54 -0800</bug_when>
    <thetext>Created attachment 334792
HTML page that demonstrates the SVG+CSS+transform bug

I created an SVG with a &lt;g&gt; element that is rotated +30deg and a &lt;text&gt; element inside the g that&apos;s rotated -30deg. The text should end up rotated 0deg.

  &lt;style&gt;
      g.rotated { transform: rotate(30deg); }
      g.rotated text { transform: rotate(-30deg); }
  &lt;/style&gt;

  &lt;svg viewBox=&quot;-150 -150 300 300&quot;&gt;
    &lt;g class=&quot;normal&quot;&gt;
      &lt;rect x=&quot;-50&quot; y=&quot;-50&quot; width=&quot;100&quot; height=&quot;100&quot; /&gt;
      &lt;text&gt;Test&lt;/text&gt;
    &lt;/g&gt;
  &lt;/svg&gt;

Live URL: https://www.redblobgames.com/x/1809-safari-svg-css-bug/test-case-reduction.html — click the button to change the class from &quot;normal&quot; to &quot;rotated&quot;. If the class is &quot;rotated&quot; at page load, it renders correctly. If it&apos;s changed from &quot;normal&quot; to &quot;rotated&quot; after page load, it renders incorrectly — it applies the rotation to &lt;g&gt; but not to &lt;text&gt;. My guess is that the rendering of &lt;g&gt; is being cached. (The rect is there just to make it easier to see the rotation)

It works correctly (text rotation is 0deg) in Firefox 58.0.2 and Chrome 64.0.3282.186 (Mac OS High Sierra 10.13.3). It does not work correctly in Safari 11.0.3 (13604.5.6) or WebKit Build r229115 (February 28, 2018, 5:11 PM PST). It also does not work correctly in Safari iOS 11.2.6. IE/Edge does not yet support CSS transforms on SVG elements so I did not test there.

(Background: I encountered this while making a css transition with transforms on svg elements https://www.redblobgames.com/x/1808-hex-half-directions/ , distilled down, found that it wasn&apos;t related to the css transition.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1403430</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-03-02 17:07:48 -0800</bug_when>
    <thetext>&lt;rdar://problem/38088345&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1716215</commentid>
    <comment_count>2</comment_count>
    <who name="Thomas Duvrai">duvrai</who>
    <bug_when>2020-12-22 08:02:28 -0800</bug_when>
    <thetext>I looked a bit further and found similar bugs in SVG styles, the simplest one being:

&lt;text style=&quot;transform: translateX(20%)&quot;&gt;

It won&apos;t work, while it&apos;s fine when using px instead of %. Credit: https://stackoverflow.com/questions/58230668/

But if you apply the style after page load it won&apos;t even work with px. A working fix is to wrap the &lt;text&gt; element in a &lt;g&gt; element and apply the transform style there.

More examples in my fiddle:
https://jsfiddle.net/duvrai/pyus1nc9/</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>334792</attachid>
            <date>2018-02-28 18:10:54 -0800</date>
            <delta_ts>2018-02-28 18:10:54 -0800</delta_ts>
            <desc>HTML page that demonstrates the SVG+CSS+transform bug</desc>
            <filename>test-case-reduction.html</filename>
            <type>text/html</type>
            <size>1119</size>
            <attacher name="Amit Patel">redblobgames</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxoZWFkPgogIDxzdHlsZT4KICAgICAgc3ZnIHsgb3V0bGluZTogMnB4
IGRhc2hlZCBncmF5OyB3aWR0aDogNDAlOyB9CiAgICAgIHRleHQgeyB0ZXh0LWFuY2hvcjogbWlk
ZGxlOyB9CiAgICAgIHJlY3QgeyBmaWxsOiBoc2woMjAwLCA1MCUsIDUwJSk7IH0KICAgICAgCiAg
ICAgIGcucm90YXRlZCB7IHRyYW5zZm9ybTogcm90YXRlKDMwZGVnKTsgfQogICAgICBnLnJvdGF0
ZWQgdGV4dCB7IHRyYW5zZm9ybTogcm90YXRlKC0zMGRlZyk7IH0KICA8L3N0eWxlPgo8L2hlYWQ+
Cjxib2R5PgogIDxoMj5BY3R1YWw8L2gyPgoKICA8c3ZnIHZpZXdCb3g9Ii0xNTAgLTE1MCAzMDAg
MzAwIj4KICAgIDxnIGNsYXNzPSJub3JtYWwiPgogICAgICA8cmVjdCB4PSItNTAiIHk9Ii01MCIg
d2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiIC8+CiAgICAgIDx0ZXh0PlRlc3Q8L3RleHQ+CiAgICA8
L2c+CiAgPC9zdmc+CgogIDxwPgogICAgQ2xpY2sgdG8gc2V0IDxjb2RlPmNsYXNzPC9jb2RlPiB0
byA8YnV0dG9uIG9uY2xpY2s9ImRvY3VtZ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