-
Notifications
You must be signed in to change notification settings - Fork 464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support maps in list context (index, nth, etc) #1930
Comments
I do see the difference, but wonder if this is actually indended behavior. IMHO this is quite a "funky" feature so to speak (never seen any similar "index" function with "hash-maps") //CC @chriseppstein $test-map : (
key : 20px,
);
foo {
bar: index($test-map, ("key" 20px) );
baz: index($test-map, ("key", 20px) );
ibar: inspect(index($test-map, ("key" 20px) )); // 1
ibaz: inspect(index($test-map, ("key", 20px) )); // null
} Yields in ruby sass:
|
For context, when a map is used with index (instead of a list) it's treated a list of lists. i.e. This applies for all list functions. This is documented in the Sass changelog for 3.3.
|
Would be great if someone could come up with a complete list, or better spec test suite for all related functions, since this doesn't seem to be related to index only (I don't think |
On another note this should probably be connected to a refactoring with selector lists, since all three types seem to share some common properties (iterable etc). Would probably help we had this covered in AST directly and not having to implement the logic again in each function (nth, inspect, etc). One of the main issues with lists is that we sometimes have nested lists (specially in regard to functions arguments). Selector_Lists became IMO quite stable during the recent refactorings for selector functions and parent selector handling. But there is also a big potential for further refactorings. And I'm really not sure if the initial design for Complex, Compound, Simple selector was such a great design. I don't mean the types per se, but how it is handled with head and tail as the approach |
Sass maps are ordered. As such, the pairs within them have an intrinsic index based on insertion order. |
Ouch. So we need to implement them as the list of (k,v) items, never the hash map... |
We Edit: sorry, I though it was an ordered map. I changed that one once, but we can easily go back to an ordered map. We "just" need to implement the indexed access in libsass functions. Amend: from a short check it seems that we need to add a |
Example file, sasstest.scss :
Expected output (using ruby sass 3.4.21) :
sasstest.scss:14 DEBUG: 2
Output with libsass :
sasstest.scss:14 DEBUG: null
The text was updated successfully, but these errors were encountered: