Skip to content
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

Closed
5 tasks done
nex3 opened this issue Apr 27, 2018 · 4 comments · Fixed by #3076 or sass/embedded-host-node#90
Closed
5 tasks done

Overhaul JS Function API #2510

nex3 opened this issue Apr 27, 2018 · 4 comments · Fixed by #3076 or sass/embedded-host-node#90
Assignees
Labels
JS API About the shared JS API

Comments

@nex3
Copy link
Contributor

nex3 commented Apr 27, 2018


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:

    • Treating false and null as falsey and everything else as truthy.
    • Treating all values as lists, and treating maps as lists of pairs.
    • Treating empty lists and empty maps as the same value.
    • Using 1-based indexes for lists and strings, and negative indexes to count from the back.
    • Indexing the Unicode codepoints of strings rather than UTF-16 code units.
  • 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.

@nex3 nex3 added the JS API About the shared JS API label Apr 27, 2018
@nex3 nex3 added this to To do in JS API Overhaul via automation Apr 27, 2018
@Awjin Awjin self-assigned this Mar 23, 2020
@nex3 nex3 mentioned this issue May 14, 2021
5 tasks
JS API Overhaul automation moved this from To do to Done Aug 2, 2021
@nex3
Copy link
Contributor Author

nex3 commented Aug 6, 2021

Reopening since we still need to track the progress and implementation of the proposal.

@nex3 nex3 reopened this Aug 6, 2021
@nex3 nex3 moved this from Done to In design in JS API Overhaul Aug 6, 2021
@nex3
Copy link
Contributor Author

nex3 commented Aug 6, 2021

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.

@nex3
Copy link
Contributor Author

nex3 commented Sep 7, 2021

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.

@nex3 nex3 moved this from In design to In development in JS API Overhaul Sep 7, 2021
@nex3
Copy link
Contributor Author

nex3 commented Dec 1, 2021

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.

nex3 added a commit to sass/embedded-host-node that referenced this issue Dec 21, 2021
This is still missing support for some value types, but the function
definition infrastructure is in place.

See sass/sass#2510
Closes #72
nex3 added a commit to sass/embedded-host-node that referenced this issue Dec 21, 2021
This is still missing support for some value types, but the function
definition infrastructure is in place.

See sass/sass#2510
Closes #72
JS API Overhaul automation moved this from In development to Done Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JS API About the shared JS API
Projects
2 participants