bug: Fix declaring css vars

This commit is contained in:
Hannes 2021-07-19 19:30:28 +02:00
parent fe4ff8d5cb
commit 4fe8910a35
No known key found for this signature in database
GPG key ID: 371029119C5F0D51

View file

@ -27,6 +27,7 @@ use Wikimedia\CSS\Grammar\MatcherFactory;
use Wikimedia\CSS\Grammar\TokenMatcher;
use Wikimedia\CSS\Grammar\UnorderedGroup;
use Wikimedia\CSS\Objects\CSSObject;
use Wikimedia\CSS\Objects\Declaration;
use Wikimedia\CSS\Objects\Token;
use Wikimedia\CSS\Sanitizer\StylePropertySanitizer;
@ -122,15 +123,14 @@ class StylePropertySanitizerExtender extends StylePropertySanitizer {
/**
* @param CSSObject $object
* @return CSSObject|\Wikimedia\CSS\Objects\Declaration|null
* @return CSSObject|Declaration|null
*/
protected function doSanitize( CSSObject $object ) {
$parent = parent::doSanitize( $object );
if ( substr( strtolower( $object->getName() ), 0, 2 ) === '--' ) {
$this->clearSanitizationErrors();
if ( strpos( $object->getName(), '--' ) !== 0 ) {
return parent::doSanitize( $object );
}
return $parent;
$this->clearSanitizationErrors();
return $object;
}
}