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

fix: improve support for each #103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

armano2
Copy link

@armano2 armano2 commented Sep 20, 2023

Adds missing tests and improves support to @each object

fixes #88, fixes #91, fixes #59

@@ -38,7 +38,7 @@ export default function getValueAsObject(value) {
const matchWrappingParens = /^\(([\W\w]*)\)$/g;

// match a property name (any-possible_name)
const matchDeclaration = /^([\w-]+)\s*:\s*([\W\w]+)\s*$/;
const matchDeclaration = /^["']?([\w-]+)["']?\s*:\s*([\W\w]+)\s*$/;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quoted keys where not supported

@@ -55,7 +55,7 @@ export default function transformEachAtrule(rule, opts) {
// return the @each statement options (@each NAME in LIST, @each NAME ITERATOR in LIST)
const getEachOpts = (node, opts) => {
const params = node.params.split(matchInOperator);
const args = (params[0] || '').trim().split(' ');
const args = (params[0] || '').trim().split(/[\s,]+/);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@each $value, $key in $arrayTest {

support for sass syntax -> comma

Comment on lines +70 to +73
const reverseParams = incname && !Array.isArray(list)
if (reverseParams) {
return { incname: varname, varname: incname, list };
}
Copy link
Author

@armano2 armano2 Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of object if 2 arguments are passed, its key, value

."1"-arrayTest {
content: "1";
}
."2"-arrayTest {
Copy link
Author

@armano2 armano2 Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this idffers from sass, as sass removes "', not sure if you want me to remove it to

removal of quotes is only present if string is \w_ from what i observed

@armano2
Copy link
Author

armano2 commented Feb 24, 2024

@Nunnius for time beeing this and few other fixes are released as postcss-advanced-variables-fixes
https://github.com/armano2/postcss-advanced-variables

@meduzen
Copy link

meduzen commented Feb 24, 2024

@Nunnius for time beeing this and few other fixes are released as postcss-advanced-variables-fixes https://github.com/armano2/postcss-advanced-variables

Do you plan to update the README.md of your project to explain it’s a fork, and that it can be downloaded from postcss-advanced-variables-fixes instead of postcss-advanced-variables?

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