mirror of
https://github.com/octfx/mediawiki-extensions-TemplateStylesExtender.git
synced 2024-12-04 20:59:10 +00:00
Merge branch 'release/v1.0.1'
This commit is contained in:
commit
aefe659761
24
README.md
24
README.md
|
@ -27,3 +27,27 @@ Enables or disables `@media (prefers-color-scheme)` queries.
|
|||
`$wgTemplateStylesExtenderEnableCssVars`
|
||||
Default: `true`
|
||||
Enables or disables css variable support.
|
||||
|
||||
## Notes on CSS vars
|
||||
Currently using `:root` selectors won't work due to template styles prepending `.mw-parser-output`.
|
||||
|
||||
One possible fix is to wrap the entire content into a `div` element and adding the declarations to this, e.g.
|
||||
```css
|
||||
div#content-wrap {
|
||||
--padding: 10px
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: var( --padding )
|
||||
}
|
||||
```
|
||||
|
||||
Wikitext
|
||||
```html
|
||||
<div id="content-wrap">
|
||||
<div class=".content">
|
||||
The WikiText...
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mediawiki/template-styles-extender",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"type": "mediawiki-extension",
|
||||
"description": "Extends TemplateStyles with new CSS properties",
|
||||
"homepage": "http://www.mediawiki.org/wiki/Extension:TemplateStylesExtender",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "TemplateStylesExtender",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"author": [
|
||||
"Octfx"
|
||||
],
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue