-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Overhaul JS Function API #2510
Comments
Reopening since we still need to track the progress and implementation of the proposal. |
This proposal is now officially out for review. It will remain that way for at least a month (potentially longer depending on discussion), at which point we'll move on to implementation. |
It's been a month and there have been no objections, so I'm going to mark the proposal as accepted and start merging it into the main spec directory. |
This is now usable in Dart Sass 1.45.0-rc.1! We'd love people's feedback on it before we launch a full stable release some time next week. |
This is still missing support for some value types, but the function definition infrastructure is in place. See sass/sass#2510 Closes #72
This is still missing support for some value types, but the function definition infrastructure is in place. See sass/sass#2510 Closes #72
The JavaScript function API shared by Dart Sass and Node Sass needs an overhaul. The current API has a number of issues:
Values are mutable. This goes against the grain of how values work within Sass, and makes it difficult to implement the API efficiently in Dart Sass.
It's hard to verify argument types with a nice error. Compare to Dart Sass's
assert*()
functions.It's hard to follow Sass's conventions for dealing with objects, such as:
false
andnull
as falsey and everything else as truthy.There's no representation of first-class function values.
There's no representation of an argument list value that may contain keyword arguments.
Maps are represented as a list of pairs, without any way of accessing a value using its key other than iterating through the entire list.
Numbers represent their units as a single string in an undocumented format, making it very difficult to work with them if they have more than just a single numerator unit.
The
this
context includes a bunch of undocumented information without a clear use-case.We should design a new API that addresses these issues and makes it easy to write importers that work similarly to built-in Sass functions.
The text was updated successfully, but these errors were encountered: