Opened 12 years ago

Closed 12 years ago

#5844 closed defect (fixed)

[patch][ccla]Cannot apply gradient fill after clearing an SVG based dojox.gfx.Surface

Reported by: Adam Peller Owned by: Eugene Lazutkin
Priority: high Milestone: 1.1
Component: DojoX GFX Version: 1.0
Keywords: Cc: owenb@…
Blocked By: Blocking:

Description

If I create a dojox.gfx.Surface in an SVG based browser (e.g. Firefox) and then at some point call

mySurface.clear(); // where mySurface is the instance of dojox.gfx.Surface

then subsequently adding shapes to the surface which use gradient fills, results in the fills not being rendered.

The root cause of the problem is that the clear method in dojox.gfx.svg.Container removes the "defs" node from the svg node. This means that the defNode variable belonging to the surface is pointing at a node which is detached from the rest of the DOM.

Proposed fix from OwenB (IBM) to maintain any existing references to the defNode:

dojox/gfx/svg.js:

	clear: function(){
		// summary: removes all shapes from a group/surface					
		var r = this.rawNode;
		while(r.lastChild) {
			r.removeChild(r.lastChild);
		}
				
		var d = this.defNode;
		if (d) {
			while (d.lastChild) {
				d.removeChild(d.lastChild);
			}
			r.appendChild(d);
		}

		//return this.inherited(arguments);	// self
		return dojox.gfx.shape.Container.clear.apply(this, arguments);
	},

Change History (2)

comment:1 Changed 12 years ago by Eugene Lazutkin

Milestone: 1.1
Status: newassigned

comment:2 Changed 12 years ago by Eugene Lazutkin

Resolution: fixed
Status: assignedclosed

(In [12592]) Applying patch from OwenB under IBM"s CCLA for "vanishing" gradients

after clearing a surface. Thx, OwenB! Minor clean up. Fixes #5844. !strict

Note: See TracTickets for help on using tickets.