Page MenuHomePhabricator

Add css classes client-nojs and client-js for styling
Closed, ResolvedPublic

Description

Author: john

Description:
Add a class to the HTML element to identify clients that have Javascript on would aid developers in hiding things that are Javascript only and do not have a fallback, without having to add them via Javascript.

Example:

.client-nojs #someThing { display: none }

Would hide the #someThing element from showing when Javascript was off, and

.client-js #gizmo { color: blue;

Would set #gizmo to have a blue text color when javascript was on


Version: 1.17.x
Severity: enhancement

Details

Reference
bz30497

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:49 PM
bzimport set Reference to bz30497.

john wrote:

Added feature

Attached:

I was worried this could lead to some style flicker, but since we seem to have put the page startup module very early on now there's nothing to render yet at the time we change the class. Probably ok then. :D

Committed for trunk/1.19 in r95318.

jelle.zijlstra wrote:

This is now causing MediaWiki-generated HTML pages to fail the W3C validator, because html apparently is not allowed to have a class. See [[WP:VPT#There is no attribute "class"]]. Could these classes perhaps be put in <body> instead?

(In reply to comment #4)

This is now causing MediaWiki-generated HTML pages to fail the W3C validator,
because html apparently is not allowed to have a class. See [[WP:VPT#There is
no attribute "class"]]. Could these classes perhaps be put in <body> instead?

Classes are allowed on the HTML element as of HTML5 as far as I know. Besides, the specification is only important as far as it does not contrast reality. The reality is that all browsers support it in HTML4 as well and it's in the specification as of HTML5.

Does it provide a benefit there over being at body?

(In reply to comment #6)

Does it provide a benefit there over being at body?

Not that I can think of. I went from the assumption we'd have the compatibility issue just like with moving the other classes 'off' of <body>. But it looks like this was added relatively recently (ie: not in 1.18).

So, go ahead and change it. But do it now, and do it quickly, before 1.19 gets branched and the argument becomes "Is breaking compatibility worth moving the class from <html> to <body> simply to put it with the rest of the classes?".

john wrote:

Nope reverted, <body> isn't available at that point.