-
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
[TASK] Separate CssInliner::inlineCss and the rendering #654
Conversation
f3e262c
to
c080a14
Compare
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 good though there are a few instances where additional minor change may be required to ensure code consistency - see individual comments.
src/Emogrifier/CssInliner.php
Outdated
$this->css = $css; | ||
$this->process($css); | ||
|
||
return $this; | ||
} |
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.
Could we dispense with this method and instead rename process()
to inlineCss()
(and have it return $this
for chaining)?
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.
Done.
@@ -399,7 +364,6 @@ protected function process() | |||
|
|||
// grab any existing style blocks from the html and append them to the existing CSS | |||
// (these blocks should be appended so as to have precedence over conflicting styles in the existing CSS) | |||
$allCss = $this->css; | |||
if ($this->isStyleBlocksParsingEnabled) { | |||
$allCss .= $this->getCssFromAllStyleNodes($xPath); | |||
} |
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.
This modifies the parameter passed to the function. Should the parameter be a separate entity (e.g. $css
) with the preceding line being changed to $allCss = $css;
rather than removed?
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.
Done.
@@ -430,11 +440,11 @@ public function wbrTagDataProvider() | |||
* | |||
* @dataProvider wbrTagDataProvider | |||
*/ | |||
public function emogrifyByDefaultRemovesWbrTag($html) | |||
public function renderByDefaultRemovesWbrTag($html) | |||
{ |
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.
Should the method name be inlineCss...
rather than render...
, since it's the inlineCss
method that removes these elements?
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.
Done.
|
||
$result = $subject->emogrify(); | ||
$result = $subject->render(); | ||
|
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.
Now that inlineCss()
performs the action being tested, the blank lines separating 'set-up', 'execute' and 'check result' no longer achieve that logical grouping (this also applies to many other tests below).
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.
Done.
Thanks for the review! I've updated the PR according to the review comments and repushed. |
c080a14
to
167b011
Compare
This is another step toward making `CssInliner` a `HtmlProcessor`.
167b011
to
cc60d45
Compare
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.
Nice one. We can't be far away now from the point when CssInliner
can actually be changed to extends AbstractHtmlProcessor
...
This is another step toward making
CssInliner
aHtmlProcessor
.