This repository was archived by the owner on Jan 31, 2020. It is now read-only.
File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -176,9 +176,18 @@ public function toString($indent = null)
176
176
$ items = [];
177
177
$ this ->getContainer ()->ksort ();
178
178
179
+ $ isHtml5 = $ this ->view ->plugin ('doctype ' )->isHtml5 ();
180
+
179
181
try {
180
182
foreach ($ this as $ item ) {
181
- $ items [] = $ this ->itemToString ($ item );
183
+ $ content = $ this ->itemToString ($ item );
184
+
185
+ if ($ isHtml5 && $ item ->type == 'charset ' ) {
186
+ array_unshift ($ items , $ content );
187
+ continue ;
188
+ }
189
+
190
+ $ items [] = $ content ;
182
191
}
183
192
} catch (Exception \InvalidArgumentException $ e ) {
184
193
trigger_error ($ e ->getMessage (), E_USER_WARNING );
Original file line number Diff line number Diff line change @@ -422,6 +422,21 @@ public function testCharset()
422
422
);
423
423
}
424
424
425
+ public function testCharsetPosition ()
426
+ {
427
+ $ view = new View ();
428
+ $ view ->plugin ('doctype ' )->__invoke ('HTML5 ' );
429
+
430
+ $ view ->plugin ('headMeta ' )
431
+ ->setProperty ('description ' , 'foobar ' )
432
+ ->setCharset ('utf-8 ' );
433
+
434
+ $ this ->assertEquals (
435
+ '<meta charset="utf-8"> ' . PHP_EOL
436
+ . '<meta property="description" content="foobar"> ' ,
437
+ $ view ->plugin ('headMeta ' )->toString ());
438
+ }
439
+
425
440
/**
426
441
* @group ZF-9743
427
442
*/
You can’t perform that action at this time.
0 commit comments