Skip to content

Commit

Permalink
#142 insert font-display declaration before the font declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
tbela99 committed Aug 22, 2021
1 parent 18ca971 commit 24a087d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions helpers/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Gzip\Helpers;

use Gzip\GZipHelper;
use TBela\CSS\Compiler;
//use TBela\CSS\Compiler;
use TBela\CSS\Element;
use TBela\CSS\Element\Stylesheet;
use TBela\CSS\Interfaces\ElementInterface;
Expand Down Expand Up @@ -112,7 +112,15 @@ public function processHTML($html, array $options = [])
}

$copy = $query->copy();
$copy->getParent()->addDeclaration('font-display', $options['fontdisplay']);

$declaration = new Element\Declaration();
$declaration->setName('font-display');
$declaration->setValue($options['fontdisplay']);

/**
* @var RuleListInterface
*/
$copy->getParent()->insert($declaration, 0);

$headStyle->append($copy->getRoot());
}
Expand Down Expand Up @@ -385,7 +393,7 @@ public function processHTML($html, array $options = [])
}

$position = isset($attributes['data-position']) && $attributes['data-position'] == 'head' ? 'head' : 'body';
$links[$position]['style'][] = !empty($css_options['compress']) ? (new Compiler($css_options))->setContent($matches[2])->compile() : $matches[2];
$links[$position]['style'][] = !empty($css_options['compress']) ? (new Renderer($css_options))->renderAst(new Parser($matches[2])) : $matches[2];

return '';
}, $html);
Expand Down

0 comments on commit 24a087d

Please sign in to comment.