You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was about to pull length function implementation (as in #1542), but realized that it would first probably make sense to propose a minor improvement for the extract function since it's closely related.
Currently, a scalar value (e.g. any non-array/list value) handling by extract is somewhat undefined. Certain types just pass through while others rise a errors, for example:
results {
c: extract(123, 1); // OK, outputs c: extract(123, 1);
d: extract(#123, 1); // non_object_property_loadError: error evaluating function `extract`
c: extract('123', 1); // undefined_methodError: Object 1 has no method 'genCSS'
a: extract(name, 1); // undefined_methodError: Object n has no method 'genCSS'
// etc.
}
So my proposal is: both extract and length should treat a single value as an array of length 1. The rationale behind this is quite simple I think: any code working with an arbitrary number of values (as a variable(s) or a mixin argument(s)) would be able to handle both array/list and scalar input in the same uniform manner.
Here's a typical use-case example I think of:
(Feature request)
I was about to pull
length
function implementation (as in #1542), but realized that it would first probably make sense to propose a minor improvement for theextract
function since it's closely related.Currently, a scalar value (e.g. any non-array/list value) handling by
extract
is somewhat undefined. Certain types just pass through while others rise a errors, for example:So my proposal is: both
extract
andlength
should treat a single value as an array of length 1. The rationale behind this is quite simple I think: any code working with an arbitrary number of values (as a variable(s) or a mixin argument(s)) would be able to handle both array/list and scalar input in the same uniform manner.Here's a typical use-case example I think of:
CSS output:
That's it, no need for any conditionals, specialized mixin, etc...
Thanks.
The text was updated successfully, but these errors were encountered: