Svg Importer: Fix handling of getDefinition for color values.

This commit is contained in:
Jonathan Puckey 2012-11-08 14:29:48 +01:00
parent 6bbc78eaef
commit 494874ec8f
2 changed files with 18 additions and 17 deletions

View file

@ -29,18 +29,20 @@ var GradientStop = this.GradientStop = Base.extend(/** @lends GradientStop# */{
* ramp {@default 0}
*/
initialize: function(arg0, arg1) {
if (arg1 === undefined && Array.isArray(arg0)) {
// [color, rampPoint]
this.setColor(arg0[0]);
this.setRampPoint(arg0[1]);
} else if (arg0.color) {
// stop
this.setColor(arg0.color);
this.setRampPoint(arg0.rampPoint);
} else {
// color [, rampPoint]
this.setColor(arg0);
this.setRampPoint(arg1);
if (arg0) {
if (arg1 === undefined && Array.isArray(arg0)) {
// [color, rampPoint]
this.setColor(arg0[0]);
this.setRampPoint(arg0[1]);
} else if (arg0 && arg0.color) {
// stop
this.setColor(arg0.color);
this.setRampPoint(arg0.rampPoint);
} else {
// color [, rampPoint]
this.setColor(arg0);
this.setRampPoint(arg1);
}
}
},

View file

@ -237,8 +237,8 @@ new function() {
var definitions = {};
function getDefinition(value) {
var match = value.match(/#([^)']+)/);
return definitions[match ? match[1] : value];
var match = value.match(/\(#([^)']+)/);
return match && definitions[match[1]];
}
var importers = {
@ -359,9 +359,8 @@ new function() {
? parseFloat(value, 10)
: entry.type === 'array'
? value.split(/[\s,]+/g).map(parseFloat)
: entry.type === 'color'
? getDefinition(value)
: value);
: entry.type === 'color' && getDefinition(value)
|| value);
} else {
switch (name) {
case 'id':