Fixed Issue 137: Can't change gradient of a text element

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@489 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Alexis Deveria 2009-08-27 18:42:46 +00:00
parent 60020d9cc2
commit 74c398b151
1 changed files with 12 additions and 2 deletions

View File

@ -2273,11 +2273,10 @@ function SvgCanvas(c)
// find out if there is a duplicate gradient already in the defs
var duplicate_grad = findDuplicateGradient(grad);
var defs = findDefs();
// no duplicate found, so import gradient into defs
if (!duplicate_grad) {
grad = defs.appendChild( svgdoc.importNode(grad, true) );
// get next id and set it on the grad
grad.id = getNextId();
}
@ -2568,6 +2567,17 @@ function SvgCanvas(c)
if (attr == "#text") elem.textContent = val;
else elem.setAttribute(attr, val);
selectedBBoxes[i] = this.getBBox(elem);
if(elem.nodeName == 'text' && (val+'').indexOf('url') == 0) {
// Hack for Firefox new-gradient-on-text-bug
// Seems like the only way a new gradient is accepted is by creating a new elem
elem.setAttribute(attr, val);
var clone = elem.cloneNode(true)
elem.parentNode.insertBefore(clone, elem);
elem.parentNode.removeChild(elem);
elem = clone;
canvas.clearSelection();
canvas.addToSelection([elem],true);
}
// Timeout needed for Opera & Firefox
setTimeout(function() {
selectorManager.requestSelector(elem).resize(selectedBBoxes[i]);