Skip to content

Commit

Permalink
Added head content optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivopetkov committed Feb 11, 2019
1 parent 706dda7 commit 008e375
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/HTMLServerComponentsCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ public function process($content, array $options = [])
}
}

$domDocument->modify(
HTML5DOMDocument::FIX_MULTIPLE_TITLES |
HTML5DOMDocument::FIX_DUPLICATE_METATAGS |
HTML5DOMDocument::FIX_MULTIPLE_HEADS |
HTML5DOMDocument::FIX_MULTIPLE_BODIES |
HTML5DOMDocument::OPTIMIZE_HEAD
);
return $domDocument->saveHTML();
}

Expand Down
12 changes: 12 additions & 0 deletions tests/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,16 @@ public function testComponentAttribute()
$this->assertTrue($result === $expectedResult);
}

/**
*
*/
public function testHeadContent()
{

$compiler = new \IvoPetkov\HTMLServerComponentsCompiler();
$result = $compiler->process('<html><head><title>111</title></head><body><component src="data:base64,' . base64_encode('<html><head><title>222</title></head></html>') . '" /></body></html>');
$expectedResult = '<!DOCTYPE html>' . "\n" . '<html><head><title>222</title></head><body></body></html>';
$this->assertTrue($result === $expectedResult);
}

}

0 comments on commit 008e375

Please sign in to comment.