This repository was archived by the owner on Jan 31, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 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)
176176 $ items = [];
177177 $ this ->getContainer ()->ksort ();
178178
179+ $ isHtml5 = $ this ->view ->plugin ('doctype ' )->isHtml5 ();
180+
179181 try {
180182 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 ;
182191 }
183192 } catch (Exception \InvalidArgumentException $ e ) {
184193 trigger_error ($ e ->getMessage (), E_USER_WARNING );
Original file line number Diff line number Diff line change @@ -422,6 +422,21 @@ public function testCharset()
422422 );
423423 }
424424
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+
425440 /**
426441 * @group ZF-9743
427442 */
You can’t perform that action at this time.
0 commit comments