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

Words "left" and "right" flipped in selectors before a comma #35

Closed
NiviJah opened this issue Jun 14, 2015 · 4 comments
Closed

Words "left" and "right" flipped in selectors before a comma #35

NiviJah opened this issue Jun 14, 2015 · 4 comments

Comments

@NiviJah
Copy link

NiviJah commented Jun 14, 2015

Consider this example

[class*="span"].pull-right,
.row-fluid [class*="span"].pull-right {
  float: right;
}

the code doesn't take the "," as end of rule and therefor transform it as well.
I'm kindda new to Regex but I came up with this solution for now :

lookAheadNotLetterPattern = '(?![a-zA-Z]|[\\,])'
@Krinkle
Copy link
Member

Krinkle commented Dec 24, 2016

@NiviJah A comma , cannot be the end of a rule in valid CSS. A rule is either ended explicitly with a semi-colon ; or implicitly by the closing curly brace }.

What bug are you experiencing? The given example seems to flip without problems.

https://cssjanus.github.io/#input/%5Bclass*%3D%22span%22%5D.pull-right%2C%0A.row-fluid%20%5Bclass*%3D%22span%22%5D.pull-right%20%7B%0A%20%20float%3A%20right%3B%0A%7D

/* CSSJanus output */

[class*="span"].pull-left,
.row-fluid [class*="span"].pull-right {
  float: left;
}

@YairRand
Copy link
Contributor

@Krinkle In the example, the first use of the selector ".pull-right" is being flipped to ".pull-left", which is not the typical or expected behaviour. (Note that this is fixed in #36 .)

@Krinkle Krinkle reopened this Feb 11, 2018
@Krinkle Krinkle changed the title "lookAheadNotLetterPattern" should also consider "," as end of rule Words "left" and "right" flipped in selectors before a comma Feb 11, 2018
@Krinkle
Copy link
Member

Krinkle commented Feb 11, 2018

Thanks, I did see that being flipped but assumed that was intentional.

But then I noticed that we don't have explicit code for that indeed. And more importantly, we currently only flip the words "left" and "right" in selectors before a comma.

.foo-left,
.bar-left,
.baz-left { }

This would currently flip foo and bar but not baz. That is indeed a bug, and I agree that the fix should be to not alter the class names.

@Krinkle
Copy link
Member

Krinkle commented Feb 11, 2018

@YairRand I looked through the individual commits and diffs of #36, but couldn't find a specific diff that would address this. Could you submit a separate PR against current master for that bit?

YairRand added a commit to YairRand/cssjanus that referenced this issue Feb 11, 2018
Change lookAheadNotOpenBracePattern to allow selectors to match "" patterns (eg [class="span"]) and selectors with comments interspersed. This fixes issue wikimedia#35, where text before either comments or attribute selectors using double quotes were not being considered part of the selector, and having text flipped as though they were part of rules. (Eg `.right [class="span"] { float: right; }` was flipped to `.left` .)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants