@@ -323,6 +323,7 @@ protected function normalizeType($type)
323
323
* Determine if item is valid
324
324
*
325
325
* @param mixed $item
326
+ * @throws Exception\RuntimeException
326
327
* @return bool
327
328
*/
328
329
protected function isValid ($ item )
@@ -334,22 +335,27 @@ protected function isValid($item)
334
335
return false ;
335
336
}
336
337
338
+ $ doctype = $ this ->view ->plugin ('doctype ' );
339
+ if ($ item ->type === 'charset ' && $ doctype ->isXhtml ()) {
340
+ throw new Exception \RuntimeException ('XHTML* doctype has no attribute charset; please use appendHttpEquiv() ' );
341
+ }
342
+
337
343
if (! isset ($ item ->content )
338
- && (! $ this -> view -> plugin ( ' doctype ' ) ->isHtml5 ()
339
- || (! $ this -> view -> plugin ( ' doctype ' ) ->isHtml5 () && $ item ->type !== 'charset ' ))
344
+ && (! $ doctype ->isHtml5 ()
345
+ || (! $ doctype ->isHtml5 () && $ item ->type !== 'charset ' ))
340
346
) {
341
347
return false ;
342
348
}
343
349
344
350
// <meta itemprop= ... /> is only supported with doctype html
345
- if (! $ this -> view -> plugin ( ' doctype ' ) ->isHtml5 ()
351
+ if (! $ doctype ->isHtml5 ()
346
352
&& $ item ->type === 'itemprop '
347
353
) {
348
354
return false ;
349
355
}
350
356
351
357
// <meta property= ... /> is only supported with doctype RDFa
352
- if (! $ this -> view -> plugin ( ' doctype ' ) ->isRdfa ()
358
+ if (! $ doctype ->isRdfa ()
353
359
&& $ item ->type === 'property '
354
360
) {
355
361
return false ;
@@ -458,20 +464,17 @@ public function set($value)
458
464
* Not valid in a non-HTML5 doctype
459
465
*
460
466
* @param string $charset
461
- * @throws Exception\RuntimeException
467
+ * @param Exception\RuntimeException
462
468
* @return HeadMeta Provides a fluent interface
463
469
*/
464
470
public function setCharset ($ charset )
465
471
{
466
- if ($ this ->view ->plugin ('doctype ' )->isXhtml ()) {
467
- throw new Exception \RuntimeException ('XHTML* doctype has no attribute charset ' );
468
- }
469
-
470
472
$ item = new stdClass ;
471
473
$ item ->type = 'charset ' ;
472
474
$ item ->charset = $ charset ;
473
475
$ item ->content = null ;
474
476
$ item ->modifiers = [];
477
+ $ this ->isValid ($ item );
475
478
$ this ->set ($ item );
476
479
477
480
return $ this ;
0 commit comments