Skip to content

Commit 008e375

Browse files
committed
Added head content optimizations.
1 parent 706dda7 commit 008e375

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/HTMLServerComponentsCompiler.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ public function process($content, array $options = [])
202202
}
203203
}
204204

205+
$domDocument->modify(
206+
HTML5DOMDocument::FIX_MULTIPLE_TITLES |
207+
HTML5DOMDocument::FIX_DUPLICATE_METATAGS |
208+
HTML5DOMDocument::FIX_MULTIPLE_HEADS |
209+
HTML5DOMDocument::FIX_MULTIPLE_BODIES |
210+
HTML5DOMDocument::OPTIMIZE_HEAD
211+
);
205212
return $domDocument->saveHTML();
206213
}
207214

tests/Test.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,16 @@ public function testComponentAttribute()
184184
$this->assertTrue($result === $expectedResult);
185185
}
186186

187+
/**
188+
*
189+
*/
190+
public function testHeadContent()
191+
{
192+
193+
$compiler = new \IvoPetkov\HTMLServerComponentsCompiler();
194+
$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>');
195+
$expectedResult = '<!DOCTYPE html>' . "\n" . '<html><head><title>222</title></head><body></body></html>';
196+
$this->assertTrue($result === $expectedResult);
197+
}
198+
187199
}

0 commit comments

Comments
 (0)