Skip to content

Commit 54005b9

Browse files
committed
convert typed array spec in integer, number, color, etc
1 parent b125396 commit 54005b9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/lib/coerce.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ exports.valObjectMeta = {
100100
requiredOpts: [],
101101
otherOpts: ['dflt', 'min', 'max', 'arrayOk'],
102102
coerceFunction: function(v, propOut, dflt, opts) {
103+
if(isTypedArraySpec(v)) v = decodeTypedArraySpec(v);
104+
103105
if(!isNumeric(v) ||
104106
(opts.min !== undefined && v < opts.min) ||
105107
(opts.max !== undefined && v > opts.max)) {
@@ -121,6 +123,8 @@ exports.valObjectMeta = {
121123
return;
122124
}
123125

126+
if(isTypedArraySpec(v)) v = decodeTypedArraySpec(v);
127+
124128
if(v % 1 || !isNumeric(v) ||
125129
(opts.min !== undefined && v < opts.min) ||
126130
(opts.max !== undefined && v > opts.max)) {
@@ -161,6 +165,8 @@ exports.valObjectMeta = {
161165
requiredOpts: [],
162166
otherOpts: ['dflt', 'arrayOk'],
163167
coerceFunction: function(v, propOut, dflt) {
168+
if(isTypedArraySpec(v)) v = decodeTypedArraySpec(v);
169+
164170
if(tinycolor(v).isValid()) propOut.set(v);
165171
else propOut.set(dflt);
166172
}
@@ -203,6 +209,8 @@ exports.valObjectMeta = {
203209
requiredOpts: [],
204210
otherOpts: ['dflt', 'arrayOk'],
205211
coerceFunction: function(v, propOut, dflt) {
212+
if(isTypedArraySpec(v)) v = decodeTypedArraySpec(v);
213+
206214
if(v === 'auto') propOut.set('auto');
207215
else if(!isNumeric(v)) propOut.set(dflt);
208216
else propOut.set(modHalf(+v, 360));

0 commit comments

Comments
 (0)