Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
StyleTag
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 sourceToDom
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
 getConfig
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\Parsoid\ParserTests;
5
6use Wikimedia\Parsoid\Core\Sanitizer;
7use Wikimedia\Parsoid\DOM\DocumentFragment;
8use Wikimedia\Parsoid\Ext\ExtensionModule;
9use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
10use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
11use Wikimedia\Parsoid\Utils\DOMCompat;
12
13class 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}