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 CSS parsing freeze #236

Merged
merged 44 commits into from Aug 12, 2021
Merged

Fix CSS parsing freeze #236

merged 44 commits into from Aug 12, 2021

Conversation

macbre
Copy link
Owner

@macbre macbre commented Feb 4, 2021

Resolves #233

Use https://github.com/fb55/css-what

  analyze-css:parseRules selector: .someclass:not([ng-show="gcdmShowSystemNotAvailableMessage()"]) +1ms
  analyze-css:parseRules parsed selector: [[{"type":"attribute","name":"class","action":"element","value":"someclass","namespace":null,"ignoreCase":false},{"type":"pseudo","name":"not","data":[[{"type":"attribute","name":"ng-show","action":"equals","value":"gcdmShowSystemNotAvailableMessage()","namespace":null,"ignoreCase":false}]]}]] +1ms

How to reproduce

echo '.someclass:not([ng-show="gcdmShowSystemNotAvailableMessage()"]){display:none}' | DEBUG=* ./bin/analyze-css.js -

Rules to refactor

  • bodySelectors
  • childSelectors
  • multiClassesSelectors
  • qualified
  • stats

@macbre
Copy link
Owner Author

macbre commented Feb 4, 2021

The job running on runner GitHub Actions 3 has exceeded the maximum execution time of 360 minutes.

Oh, nice 🙂

@gmetais
Copy link
Contributor

gmetais commented Feb 4, 2021

Told you 😄

@macbre
Copy link
Owner Author

macbre commented Feb 20, 2021

More debug code added:

  analyze-css:parser Going to parse 0.08 kB of CSS +0ms
  analyze-css:parser CSS parsed +0ms
  analyze-css Event "css" emitted +1ms
  analyze-css Event "stylesheet" emitted +0ms
  analyze-css:parseRules rule: {"type":"rule","selectors":[".someclass:not([ng-show=\"gcdmShowSystemNotAvailableMessage()\"])"],"declarations":[{"type":"declaration","property":"display","value":"none","position":{"start":{"line":1,"column":65},"end":{"line":1,"column":77}}}],"position":{"start":{"line":1,"column":1},"end":{"line":1,"column":78}}} +0ms
  analyze-css Event "rule" emitted +0ms
... [freeze]

We freeze at slick parsing:

  analyze-css:parseRules slickParse: .someclass:not([ng-show="gcdmShowSystemNotAvailableMessage()"]) +0ms

https://runkit.com/embed/50uk20ayu63i

However, the following runs fine:

slick.parse('.someclass:not([ng-show="gcdmShowSystemNotAvailableMessage"])')

The most recent slick version was published 6 years ago. Time to find a replacement -> https://github.com/postcss/postcss

@macbre macbre added this to the Roadmap milestone Jun 16, 2021
@macbre macbre modified the milestones: Roadmap, v1.1.0 Jun 29, 2021
@macbre macbre modified the milestones: v1.1.0, v2.0.0 Aug 3, 2021
@macbre macbre changed the base branch from devel to master August 5, 2021 16:43
  analyze-css:bodySelectors selector: html.modal-popup-mode body {"firstTag":"html","firstHasClass":true,"isDescendantCombinator":false,"isShortExpression":false} +0ms
  analyze-css:bodySelectors selector html.modal-popup-mode body - is redundant +0ms
@macbre
Copy link
Owner Author

macbre commented Aug 6, 2021

CodeFactor found an issue: Complex Method

It's currently on:
rules\bodySelectors.js:40-62
Commit 91926af

@macbre macbre marked this pull request as ready for review August 12, 2021 11:27
@coveralls
Copy link

Pull Request Test Coverage Report for Build 1123694655

  • 88 of 88 (100.0%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 1122988380: 0.0%
Covered Lines: 553
Relevant Lines: 553

💛 - Coveralls

@macbre macbre merged commit beb6935 into master Aug 12, 2021
@macbre macbre deleted the issue-233-css-freeze branch August 12, 2021 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Freezing on a syntax
3 participants