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

[TASK] Separate CssInliner::inlineCss and the rendering #654

Merged
merged 1 commit into from
May 14, 2019

Conversation

oliverklee
Copy link
Contributor

This is another step toward making CssInliner a HtmlProcessor.

@oliverklee oliverklee added this to the 2.2.0 milestone Mar 25, 2019
@oliverklee oliverklee self-assigned this Mar 25, 2019
Copy link
Contributor

@JakeQZ JakeQZ left a 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.

$this->css = $css;
$this->process($css);

return $this;
}
Copy link
Contributor

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)?

Copy link
Contributor Author

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);
}
Copy link
Contributor

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?

Copy link
Contributor Author

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)
{
Copy link
Contributor

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?

Copy link
Contributor Author

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();

Copy link
Contributor

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).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@oliverklee
Copy link
Contributor Author

Thanks for the review! I've updated the PR according to the review comments and repushed.

This is another step toward making `CssInliner` a `HtmlProcessor`.
Copy link
Contributor

@JakeQZ JakeQZ left a 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...

@JakeQZ JakeQZ merged commit 720f199 into master May 14, 2019
@JakeQZ JakeQZ deleted the task/inline-css branch May 14, 2019 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants