-
Notifications
You must be signed in to change notification settings - Fork 154
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
[FEATURE] Add HtmlPruner::removeRedundantClasses #708
Conversation
I've just replied to the comments for now. I'll look at committing some changes tomorrow... 🌙 |
On the basis of the adage “if a job’s worth doing, it’s worth doing well”, I’ve added such a class. I dropped the prefix |
I've made changes based on the review suggestions and repushed. |
In this change I introduced these private methods: private function removeClassesFromNodes(\DOMNodeList $nodeList, array $classesToKeep);
private function removeClassAttributeFromNodes(\DOMNodeList $nodeList); I chose (We also have various instances in the code base of private methods and local variables using ‘node’ in the name, where they are necessarily elements, and perhaps should consider changing the names for clarity, but I’d say not for 3.0.0 – except #717.) |
Yes, this makes sense and sounds good. |
I've renamed accordingly and repushed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks generally very good. Just some minor remarks. And could you please rebase?
Have made suggested changes.
Well, I used I've saved the command prompt transcript which I can post to identify what I might have done wrong... |
I'll do my best to help. |
Some ideas to resolve the git problem:
|
@JakeQZ And if you like, I can also resolve the problem on my machine, force-push and then provide the steps I executed. |
- Add Jake Hotson as author of `HtmlPruner` and `HtmlPrunerTest`; - Remove redundant “list of” from PHPDoc for `removeRedundantClasses()`; - Move branches of `removeRedundantClasses()` into separate methods; - Allow parameter of `removeRedundantClasses()` to have default value; - Add comment clarifying alternate branch in `removeRedundantClasses()` is merely an optimization; - Use `ArrayIntersector` to abstract the array intersection with ‘flipped’ arrays; - Add multiple classes case to `classesToKeepDataProvider()`; - Change ‘html’ to ‘HTML’ in array keys for human consumption; - Split `removeRedundantClassesRemovesOnlyClassesNotToKeep()` into two separate tests; - Refactor test data providers to more cleanly provide the appropriate data for each test. Also added missing preposition to sentence in PHPDoc for `ArrayIntersector`.
- “class names” -> “names of classes” in PHPDoc; - Added specialized assertion methods: `assertSubstringCount` and `assertMinified`.
a39cc86
to
b4b18fd
Compare
Should this PR close #380 when merged? |
I think I've sorted it. It seems that after |
Not yet - there's the final method which takes a |
Oh, yes, that message. The action the message recommends is completely bogus. Just last week, I told exactly that to the attendees at a Git workshop. :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful!
Part of #380.