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

[CLEANUP] Move CSS parsing to a separate class #1014

Merged
merged 7 commits into from
Apr 18, 2021
Merged

Conversation

JakeQZ
Copy link
Contributor

@JakeQZ JakeQZ commented Apr 13, 2021

Part of #734 and #544. Relates to #994.

@JakeQZ JakeQZ added the cleanup label Apr 13, 2021
@JakeQZ JakeQZ added this to the 6.0.0 milestone Apr 13, 2021
@JakeQZ JakeQZ self-assigned this Apr 13, 2021
@JakeQZ JakeQZ marked this pull request as draft April 13, 2021 23:33
src/Utilities/ParsedCss.php Outdated Show resolved Hide resolved
@JakeQZ
Copy link
Contributor Author

JakeQZ commented Apr 13, 2021

This still needs a TestCase for the new class, but I'd be interested in your initial thoughts and comments (@oliverklee?). Note that this is just a refactoring: the original code from CssInliner has mostly been cut and pasted to the new class, 'warts and all'.

@JakeQZ
Copy link
Contributor Author

JakeQZ commented Apr 13, 2021

This change is analogous to the second commit in #1015, so you can see how it might turn out when we introduce sabberworm/php-css-parser to do the 'heavy lifting'.

Copy link
Contributor

@oliverklee oliverklee left a comment

Choose a reason for hiding this comment

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

I like this refactoring a lot.

src/CssInliner.php Show resolved Hide resolved
src/Utilities/ParsedCss.php Outdated Show resolved Hide resolved
@JakeQZ JakeQZ force-pushed the refactor/css-parsing branch 12 times, most recently from 6ff10cf to 37bb360 Compare April 17, 2021 14:29
src/CssInliner.php Outdated Show resolved Hide resolved
src/CssInliner.php Show resolved Hide resolved
src/Utilities/CssDocument.php Outdated Show resolved Hide resolved
src/Utilities/CssDocument.php Outdated Show resolved Hide resolved
src/Utilities/CssDocument.php Outdated Show resolved Hide resolved
src/Utilities/CssDocument.php Outdated Show resolved Hide resolved
Also clarify the class description in the DocBlock.
This clarifies that not all at-rules are rendered.  Also rename the associated
property, and add note in the DocBlock for the method that `@charset` rules are
discarded.
@JakeQZ JakeQZ marked this pull request as ready for review April 17, 2021 15:09
@JakeQZ
Copy link
Contributor Author

JakeQZ commented Apr 17, 2021

I've made the changes initially suggested. I've also finished off writing the TestCase so this is ready for full review now - I've cleared the 'draft'/WIP status of the PR.

Copy link
Contributor

@oliverklee oliverklee left a comment

Choose a reason for hiding this comment

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

Already looks very good! I've added my comments.

tests/Unit/Utilities/CssDocumentTest.php Outdated Show resolved Hide resolved
src/Utilities/CssDocument.php Show resolved Hide resolved
src/Utilities/CssDocument.php Outdated Show resolved Hide resolved
src/Utilities/CssDocument.php Outdated Show resolved Hide resolved
src/Utilities/CssDocument.php Outdated Show resolved Hide resolved
tests/Unit/Utilities/CssDocumentTest.php Show resolved Hide resolved
tests/Unit/Utilities/CssDocumentTest.php Show resolved Hide resolved
tests/Unit/Utilities/CssDocumentTest.php Outdated Show resolved Hide resolved
tests/Unit/Utilities/CssDocumentTest.php Outdated Show resolved Hide resolved
tests/Unit/Utilities/CssDocumentTest.php Show resolved Hide resolved
@JakeQZ
Copy link
Contributor Author

JakeQZ commented Apr 17, 2021

Have commited changes as suggested.

Copy link
Contributor

@oliverklee oliverklee left a comment

Choose a reason for hiding this comment

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

Beautiful!

@oliverklee oliverklee merged commit c8f8950 into main Apr 18, 2021
@oliverklee oliverklee deleted the refactor/css-parsing branch April 18, 2021 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants