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

Allow specifying replacements as a callback #70

Open
joepie91 opened this issue Jul 23, 2020 · 3 comments
Open

Allow specifying replacements as a callback #70

joepie91 opened this issue Jul 23, 2020 · 3 comments

Comments

@joepie91
Copy link

Currently, replaceSymbols only accepts a mapping of values. This is problematic because the same value may need to be represented differently in different contexts (reference, and there's no way to do that right now.

An API that would solve this, would be something like:

icssUtils.replaceSymbols(css, (symbol, context) => {
	let mappedSymbol = someMapping[symbol];

	if (context === "decl") {
		return mappedSymbol;
	} else {
		return mappedSymbol.replace(/ /g, ".");
	}
});
@alexander-akait
Copy link
Member

Not sure it is real fix bug, when we replace we should known what it was composing from selector

@joepie91
Copy link
Author

What usecase do you have in mind where that is necessary?

At least for the composed-class-name issue that shouldn't be necessary, as the correct formatting is dependent entirely on where the identifier appears (class names cannot appear in rule declarations, and vice versa).

@alexander-akait
Copy link
Member

Not really, when we receive something (It can bee selector/value/media query) from another file, we do not know whether it is, so we should keep context where we get value before, we should change :import('file.css') { test: test from selector } (just idea) it will not fundamentally solve the problem, but rather a hack

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