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

suit regexp is weak #16

Closed
giuseppeg opened this issue Sep 23, 2016 · 7 comments
Closed

suit regexp is weak #16

giuseppeg opened this issue Sep 23, 2016 · 7 comments

Comments

@giuseppeg
Copy link

giuseppeg commented Sep 23, 2016

Hi, I know that regexps are expensive but the one for suit is very flaky and weak.

For instance the plugin resets things like

.Component[aria-hidden="true"] {}

which results in specificity issues e.g.:

.Component { 
  font-size: 3em;
}

.Component[aria-hidden="true"] {
  display: none;
}

Is compiled to

.Component,
.Component[aria-hidden="true"] {
   font-size: medium;
}

.Component { 
  font-size: 3em;
}

.Component[aria-hidden="true"] {
  display: none;
}

and because .Component[aria-hidden="true"] is more specific than .Component font-size: 3em is overridden.

You may want to use postcss-bem-linter's regexps.

We are considering to add this plugin to suitcss and this is a blocker.
Let me know if you need some help ✌️

@giuseppeg
Copy link
Author

@maximkoretskiy ping

@maximkoretskiy
Copy link
Owner

Hi. Sorry for long response. I will be able to implement it next on next week end.
Would U like to make PR to get this feature faster?

@giuseppeg
Copy link
Author

@maximkoretskiy no worries, thank you! I'll let you know if I find the time to work on it but otherwise feel free to start if you can/want/have time ;)

@simonsmith
Copy link
Contributor

@giuseppeg Should attributes with a selector always be ignored? Is this the only bug or is there a list of rules to write against here?

I can take a look at this

@giuseppeg
Copy link
Author

giuseppeg commented Sep 27, 2016

@simonsmith the only things to reset are component roots and descendants I suppose, everything else should be ignored.

.Component {}
.namespace-Component {}
.Component-descendant {}
.namespace-Component-descendant {}

So yes attributes with a selector should be ignored because they will always be more specific than the above.

One may be tempted to add the attribute selector case to the current check but keep in mind that this plugin can run on anything (utilities files, resets and non-suit compliant code) so we really want to make sure that we reset only components classes.

@simonsmith
Copy link
Contributor

I see, okay.

We can safely ignore pseudo classes too? Current version checks for presence of : anywhere in the selector

@giuseppeg
Copy link
Author

I guess so.
When this is fixed I think that we should approach this integration in a tdd way to make sure that we don't ship something broken or flaky in preprocessor v3 – but this has nothing to do with Maxim's plugin.

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

3 participants