refactor: Remove 1.39 check

This commit is contained in:
Hannes 2023-01-23 14:03:27 +01:00
parent e6cb46f4a6
commit dcc4fd7b9f
No known key found for this signature in database
GPG key ID: 0EADE441303A09B4
3 changed files with 14 additions and 17 deletions

View file

@ -38,5 +38,10 @@
},
"extra": {
"installer-name": "TemplateStylesExtender"
},
"config": {
"allow-plugins": {
"composer/installers": true
}
}
}

View file

@ -27,7 +27,7 @@ use Wikimedia\CSS\Sanitizer\StylePropertySanitizer;
class PropertySanitizerHook {
/**
* @param StylePropertySanitizer &$propertySanitizer
* @param StylePropertySanitizer $propertySanitizer
* @param TemplateStylesMatcherFactory $matcherFactory
*/
public static function onSanitize( &$propertySanitizer, $matcherFactory ): void {

View file

@ -33,7 +33,6 @@ use Wikimedia\CSS\Grammar\KeywordMatcher;
use Wikimedia\CSS\Grammar\MatcherFactory;
use Wikimedia\CSS\Grammar\Quantifier;
use Wikimedia\CSS\Grammar\WhitespaceMatcher;
use Wikimedia\CSS\Objects\Token;
use Wikimedia\CSS\Sanitizer\StylePropertySanitizer;
class TemplateStylesExtender {
@ -55,13 +54,6 @@ class TemplateStylesExtender {
] )
);
if ( method_exists( $factory, 'cssSingleEasingFunction' ) ) {
// MediaWiki 1.39+ / css-sanitizer 4.0.0+
$cssSingleEasingFunction = $factory->cssSingleEasingFunction();
} else {
$cssSingleEasingFunction = $factory->cssSingleTimingFunction();
}
$anyProperty = Quantifier::star(
new Alternative( [
$var,
@ -75,7 +67,7 @@ class TemplateStylesExtender {
$factory->frequency(),
$factory->resolution(),
$factory->position(),
$cssSingleEasingFunction,
$factory->cssSingleEasingFunction(),
$factory->comma(),
$factory->cssWideKeywords(),
new KeywordMatcher( [
@ -245,17 +237,17 @@ class TemplateStylesExtender {
$propertySanitizer->addKnownProperties( [
'aspect-ratio' => new Alternative( [
$factory->cssWideKeywords(),
new Juxtaposition([
new Juxtaposition( [
$factory->number(),
Quantifier::optional(
new Juxtaposition([
new WhitespaceMatcher(['significant' => false]),
new DelimMatcher('/'),
new WhitespaceMatcher(['significant' => false]),
new Juxtaposition( [
new WhitespaceMatcher( [ 'significant' => false ] ),
new DelimMatcher( '/' ),
new WhitespaceMatcher( [ 'significant' => false ] ),
$factory->number()
])
] )
)
]),
] ),
] )
] );
} catch ( InvalidArgumentException $e ) {