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

JS API custom functions have no context options? #1611

Closed
dasiux opened this issue Jan 26, 2022 · 2 comments
Closed

JS API custom functions have no context options? #1611

dasiux opened this issue Jan 26, 2022 · 2 comments

Comments

@dasiux
Copy link

dasiux commented Jan 26, 2022

When using the custom fuctions: https://sass-lang.com/documentation/js-api/interfaces/Options#functions
I was looking for context information, like path of the file where the function is being executed to be able to resolve relative paths for example.

I have not used the custom functions for the node-sass or the dart-sass legacy api, but according to this as i understand it: #1233 there should be a context object that should hold that information even when using the new dart-sass JS API.

I don't seem to be able to retrieve that information using sass@^1.49.0, either because its not there or I'm too stupid to find it,
you can find a repository with a reproducable setup here:
https://github.com/dasiux/sass-functions-context-test

I've run it with osx@11.5.2 on node@^v10.x.x but i assume the node version is not the problem, also sync or async does not and should not make a difference.

Would be great to find a solution for this, thanks for any help in advance.

@Awjin
Copy link
Contributor

Awjin commented Feb 2, 2022

This is working as intended—the new JS API does not modify the this context, in order to prevent unexpected behavior.

@Awjin Awjin closed this as completed Feb 2, 2022
@dasiux
Copy link
Author

dasiux commented Feb 2, 2022

This is working as intended—the new JS API does not modify the this context, in order to prevent unexpected behavior.

So there is no way to aquire the context information in the current state? not even the file path where the function was called?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants