Bug 50809

Summary: Element not updated when referenced gradient has changed
Product: Batik - Now in Jira Reporter: cujyaz
Component: ScriptingAssignee: Batik Developer's Mailing list <batik-dev>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 1.8   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description cujyaz 2011-02-19 00:10:27 UTC
Dynamic modification of gradients doesn't work in Batik:

<?xml version="1.0" encoding="iso-8859-1"?>
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"
     viewBox="-1 -1 4 4" onload="Init()">
  <script type="text/ecmascript"><![CDATA["use strict";
    var SVG= "http://www.w3.org/2000/svg";
    function Init() {
      var elt= document.createElementNS( SVG, "stop" );
      elt.setAttribute( "offset", "0" );
      document.getElementById( "grad" ).appendChild( elt );
    }
  ]]></script>
  <linearGradient id="grad"/>
  <rect id="rect" width="2" height="2" fill="url(#grad)"/>
</svg>

This should display a black square. In Batik, this works only after removing and re-setting the fill attribute:

      document.getElementById( "rect" ).removeAttribute( "fill" );
      document.getElementById( "rect" ).setAttribute( "fill", "url(#grad)" );