Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
StyleTag | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
sourceToDom | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
getConfig | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\ParserTests; |
5 | |
6 | use Wikimedia\Parsoid\Core\Sanitizer; |
7 | use Wikimedia\Parsoid\DOM\DocumentFragment; |
8 | use Wikimedia\Parsoid\Ext\ExtensionModule; |
9 | use Wikimedia\Parsoid\Ext\ExtensionTagHandler; |
10 | use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI; |
11 | use Wikimedia\Parsoid\Utils\DOMCompat; |
12 | |
13 | class StyleTag extends ExtensionTagHandler implements ExtensionModule { |
14 | /** @inheritDoc */ |
15 | public function sourceToDom( |
16 | ParsoidExtensionAPI $extApi, string $content, array $args |
17 | ): DocumentFragment { |
18 | $domFragment = $extApi->htmlToDom( '' ); |
19 | $style = $domFragment->ownerDocument->createElement( 'style' ); |
20 | DOMCompat::setInnerHTML( $style, $content ); |
21 | Sanitizer::applySanitizedArgs( $extApi->getSiteConfig(), $style, $args ); |
22 | $domFragment->appendChild( $style ); |
23 | return $domFragment; |
24 | } |
25 | |
26 | /** @inheritDoc */ |
27 | public function getConfig(): array { |
28 | return [ |
29 | 'name' => 'StyleTag', |
30 | 'tags' => [ |
31 | [ 'name' => 'style', 'handler' => self::class ], |
32 | ], |
33 | ]; |
34 | } |
35 | } |