[FEATURE] Render selector#1446
Conversation
JakeQZ
left a comment
There was a problem hiding this comment.
It would definitely be good to be able to render selectors minified.
However, as noted in #1398 (review), it is not straightforward to achieve that from the codebase as it stands.
I don't think the render() method should be responsible for reparsing the selector, which is already parsed by DeclarationBlock::parseSelector():
render()should be able to simply output what it has according to theOutputFormat;- adding separate parsing functionality here is duplicating functionality.
I think the problem that needs to be solved first is #1325 - i.e. how Selector is represented.
Sorry to be the bearer of bad news, but I think there's quite a bit of initial refactoring needed so that we can have a nice clean solution to this.
If you have any thoughts on solving #1325, they would be very welcome - thanks :) <3
|
I don't know the code well enough for such deep changes as the ones you suggest. PHP-CSS-Parser/src/RuleSet/DeclarationBlock.php Lines 293 to 305 in 2b61cd5 Something like this: while (true) {
$selector = self::parseSelector($parserState, $comments);
$selectors[] = self::cleanSelector($selector);
if (!$parserState->consumeIfComes(',')) {
break;
}
}
|
This is a PR draft for selector tidying to transform this:
into this:
There are no specific tests yet, and there are improvements that can be made, I just want to get your approval before I polish things up.