title: fabricjs - extend toSVG to export custom properties
body: <p>According to <a href="http://fabricjs.com/fabric-intro-part-3#serialization" rel="nofollow noreferrer">this part of the doc</a>, it is possible to extend the <code>toSVG()</code> method to export custom properties. Unfortunately, it is unclear as if we should override <code>toSVG()</code> itself, or rather the <code>toObject()</code> method.</p>
  
  <p>My problem is, I've used this bit of code </p>
  
  <pre><code>fabric.SHARED_ATTRIBUTES.push('class')
  fabric.Path.ATTRIBUTE_NAMES.push('class')
  fabric.Image.ATTRIBUTE_NAMES.push('class')
  </code></pre>
  
  <p>So that my imported SVGs objects would have CSS classes. Unfortunately, when using <code>toSVG()</code>, these classes are nowhere to be found in the generated SVG, therefore resulting in <a href="https://s3.eu-central-1.amazonaws.com/balibart-s3/Products/5c336024154fc41ae787c93e/Mockups/front.svg" rel="nofollow noreferrer">this kind of non-blended SVGs</a> (if you set the CSS <code>mix-blend-mode</code> property to <code>'multiply'</code> for the <code>paths</code>, you'll see the correct image.</p>
  
  <p>How can I tweak <code>toSVG()</code> so that the <code>class</code> property gets exported in my SVG ? DO I have to modify the <code>toSVG()</code> method for every object in the imported SVG ?</p>