A common problem with the new night mode that is being built out is certain template styles / templates specify a background-color without a color
Example: https://m.mediawiki.org/w/index.php?title=Manual:Database_layout/diagram/1.41.0&minervanightmode=1
Recommendation: https://www.mediawiki.org/wiki/Recommendations_for_night_mode_compatibility_on_Wikimedia_wikis#Always_define_color_when_defining_background
We'd like to setup a linting rule to encourage editors to fix this and also add some code to correct this.
The equivalent JS for style attribute correction might look like this:
$('[style]').each((i,node)=> { const style = node.getAttribute('style'); if ( style.indexOf('background') > -1 && style.indexOf('color') === -1 ) { node.setAttribute('style', style + ';color:#333;') } } )
Examples that we would want to automatically fix:
for background rule a corresponding color: #333 should be added.- INLINE STYLES: https://en.m.wikipedia.org/w/index.php?title=User:Jdlrobson/T356899&minervanightmode=1
- Outcome
- Work out whether correction is possible (on template styles and inline styles)
Focus on detection and reporting aspect of this work.
Work out if a lint rule that works on template styles as well as inline styles is feasible.
Update: The work is more suitable as a tool in css-sanitizer we can utilise the sanitiser in other packages and extensions
- Get a rough estimate of the timeline for getting this to work, and whether this is something that the web team can do with code review from content transform team.
Sign off
- Create tickets for any work discussed here.