Support Point argument reading for Style#shadowOffset.

This commit is contained in:
Jürg Lehni 2014-09-19 18:43:00 +02:00
parent 52dd24097f
commit e5995527e8

View file

@ -127,6 +127,7 @@ var Style = Base.extend(new function() {
Base.each(defaults, function(value, key) { Base.each(defaults, function(value, key) {
var isColor = /Color$/.test(key), var isColor = /Color$/.test(key),
isPoint = key === 'shadowOffset',
part = Base.capitalize(key), part = Base.capitalize(key),
flag = flags[key], flag = flags[key],
set = 'set' + part, set = 'set' + part,
@ -190,12 +191,16 @@ var Style = Base.extend(new function() {
if (value && value.clone) if (value && value.clone)
value = value.clone(); value = value.clone();
this._values[key] = value; this._values[key] = value;
} else if (isColor && !(value && value.constructor === Color)) { } else {
// Convert to a Color and stored result of conversion. var ctor = isColor ? Color : isPoint ? Point : null;
this._values[key] = value = Color.read([value], 0, if (ctor && !(value && value.constructor === ctor)) {
{ readNull: true, clone: true }); // Convert to a Color / Point, and stored result of the
if (value) // conversion.
value._owner = owner; this._values[key] = value = ctor.read([value], 0,
{ readNull: true, clone: true });
if (value && isColor)
value._owner = owner;
}
} }
return value; return value;
} }