Skip to content

Commit

Permalink
fit content to <html> instead of <body>
Browse files Browse the repository at this point in the history
most browsers apply a margin of 8px to the `<body>` tag automatically. it's very common for most CSS frameworks to "normalize" this to zero, which is why for most people the <body> size and the <html> size are the same.

since it's not the case for everyone, we can use the <html> size here instead.
  • Loading branch information
browner12 authored Jan 27, 2020
1 parent 6f59695 commit 862f343
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,10 @@ public function fitContent()
{
$this->driver->switchTo()->defaultContent();

$body = $this->driver->findElement(WebDriverBy::tagName('body'));
$html = $this->driver->findElement(WebDriverBy::tagName('html'));

if (! empty($body)) {
$this->resize($body->getSize()->getWidth(), $body->getSize()->getHeight());
if (! empty($html)) {
$this->resize($html->getSize()->getWidth(), $html->getSize()->getHeight());
}

return $this;
Expand Down

0 comments on commit 862f343

Please sign in to comment.