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

Fixing nested @ tags not closing properly #30

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

gieoon
Copy link

@gieoon gieoon commented Feb 10, 2023

Closing brackets don't revert to the correct 'before-selector' and are stuck in 'at-group', causing issues with the output CSS where brackets are closed off only at the end.

An example of CSS input:

<style>
@media (min-width: 640px) {
  .sm\:container {
    width: 100%
  }

  @media (min-width: 640px) {
    .sm\:container {
      max-width: 640px
    }
  }
}

p {
    background-color: red;
}
</style>

Currently, this is output as:

@media (min-width: 640px) {
.sm:container {
width: 100%;
}

@media (min-width: 640px) {
.sm:container {
max-width: 640px;
}

p {
background-color: red;
}

}
}

Where brackets are stacked at the end.

With this PR, the output becomes:

@media (min-width: 640px) {
.sm:container {
width: 100%;
}

@media (min-width: 640px) {
.sm:container {
max-width: 640px;
}

}
}

p {
background-color: red;
}

Where brackets are ordered correctly.


This PR also implements this PR from @lwenn where :not (.class1, .class2) is being incorrectly split into two separate classes by applying smarter regex.


I have not tested this rigorously, only with a few short styles. The changes are relatively localized and should be low risk.
I am currently using this fork on larger real CSS datasets. This fork will be undergoing more strenuous testing in the near future.

@gieoon
Copy link
Author

gieoon commented Feb 11, 2023

Added commits to support complex CSS with is:(.class1, .class2, .class3) selectors

e.g.

-o-transition:.3s all;transition:all .3s;will-change:margin-inline-start}.e-container>.e-container>.elementor-element-overlay>.elementor-editor-element-settings:hover>:is(.elementor-editor-element-duplicate,.elementor-editor-element-remove),.elementor-widget .e-container>.elementor-element-overlay>.elementor-editor-element-settings:hover>:is(.elementor-editor-element-duplicate,.elementor-editor-element-remove){-webkit-margin-start:0;margin-inline-start:0}

Where :is(.class1, .class2, .class3) is being split up as : :is(.class1 ... etc.

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

Successfully merging this pull request may close these issues.

1 participant