html.js .whatever is overqualified. .js whatever is just as efficient, so we should just use that.

Instead of doing this separately by module, I think it would be easier to do it all at once.

CommentFileSizeAuthor
#26 1269586-25.patch7.84 KBericduran
#3 html.js_.patch9.86 KBEverett Zufelt
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Everett Zufelt’s picture

@Jacine

Do you have any idea why html.js was used in the first place?
Other than modifying the following (8.x) does anything need to be done to theme functions / templates to put this in place?

modules/book/book.css:html.js #edit-book-pick-book {
modules/color/color-rtl.css:html.js #preview {
modules/color/color.css:html.js #preview {
modules/contextual/contextual.css:html.js div.contextual-links-wrapper {
modules/openid/openid-rtl.css:html.js #user-login-form li.openid-link,
modules/openid/openid-rtl.css:html.js #user-login li.openid-link {
modules/openid/openid.css:html.js #user-login-form div.form-item-openid-identifier,
modules/openid/openid.css:html.js #user-login div.form-item-openid-identifier {
modules/openid/openid.css:html.js #user-login-form li.openid-link,
modules/openid/openid.css:html.js #user-login li.openid-link {
modules/overlay/overlay-child.css:html.js {
modules/overlay/overlay-child.css:html.js body {
modules/system/system.base-rtl.css:html.js input.form-autocomplete {
modules/system/system.base-rtl.css:html.js input.throbbing {
modules/system/system.base.css:html.js input.form-autocomplete {
modules/system/system.base.css:html.js input.throbbing {
modules/system/system.base.css:html.js fieldset.collapsed {
modules/system/system.base.css:html.js fieldset.collapsed .fieldset-wrapper {
modules/system/system.base.css:html.js .js-hide {
modules/system/system.theme-rtl.css:html.js fieldset.collapsible .fieldset-legend {
modules/system/system.theme-rtl.css:html.js fieldset.collapsed .fieldset-legend {
modules/system/system.theme.css:html.js fieldset.collapsible .fieldset-legend {
modules/system/system.theme.css:html.js fieldset.collapsed .fieldset-legend {
themes/bartik/color/preview.css:html.js #preview {
themes/bartik/css/style-rtl.css:html.js input.form-autocomplete {
themes/bartik/css/style-rtl.css:html.js input.throbbing {
themes/bartik/css/style.css:html.js input.form-autocomplete {
themes/bartik/css/style.css:html.js input.throbbing {
themes/garland/fix-ie-rtl.css:html.js fieldset.collapsible {
themes/garland/fix-ie-rtl.css:html.js fieldset.collapsed {
themes/garland/fix-ie.css:html.js fieldset.collapsible {
themes/garland/fix-ie.css:html.js fieldset.collapsed {
themes/garland/style-rtl.css:html.js fieldset.collapsible .fieldset-legend {
themes/garland/style-rtl.css:html.js fieldset.collapsed .fieldset-legend {
themes/garland/style.css:html.js fieldset.collapsed {
themes/garland/style.css:html.js fieldset.collapsible .fieldset-legend {
themes/garland/style.css:html.js fieldset.collapsed .fieldset-legend {
themes/seven/style.css:html.js fieldset.collapsed {
themes/seven/style.css:html.js input.form-autocomplete {
themes/seven/style.css:html.js input.throbbing {

Jacine’s picture

No, nothing special needs to be done to make this change. The .js is added to the <html> tag with JavaScript. It's just a nice helper class that let's us know that JavaScript is enabled, and style for JS enabled vs. non-JS enabled circumstances.

I think that it was probably written as html.js out of habit, maybe so that it's immediately apparent the it's located on the <html> tag. The same thing is done often in core CSS files, such as using div.selector. Sometimes it's needed, but most of the time it's not. In this case it's definitely not needed, and the making the patch could be a simple find and replace in CSS files.

Everett Zufelt’s picture

Status: Active » Needs review
FileSize
9.86 KB
Damien Tournoud’s picture

I don't see how html.js is overqualified. It makes clear what it is, and avoid possible confusion if/when the same class is used elsewhere then in html. If there is no more rationale then ".js is just as efficient, let's do the change for the sake of it", I would recommend against it.

Jacine’s picture

It's overqualified from a CSS specificity standpoint. Using the html element along with the js class gives it a higher specificity, for no reason, so I'm not sure would you recommend against this.

idflood’s picture

I think this patch should be committed. I see 3 reasons:

  • Overqualified css selector
  • Save a few octets
  • More flexibility (in fact html5 doesn't require a html tag)

I have to agree that the two last can be seen as really minor or not important at all. But if later we decide to put the "js" class on the body tag for any good reason there will be no change needed in the css.

Dave Reid’s picture

Issue tags: -html5

Not sure what this has to do with html5.

Damien Tournoud’s picture

More flexibility (in fact html5 doesn't require a html tag)

Yeah, right ;)

I still see no valid reason for this change. Changing anything just for the sake of changing it is just a bad idea.

mortendk’s picture

@dave well now that were changing markup & css all around drupal to make it clean "HTML5" (the magick buzzword)
then it woudn't make sense not to clean up the frontend where we can now were at it?
if we dont look at the markup & classes as a whole then were doing it wrong

mortendk’s picture

Actually its valid not having eather the html or body tag - cause the browser knows it should be there - its crap for accessability though ;)

But the point here is that what frontend developers really really want is as little pre loaded weight as possible. the drupal way used to be to have tons of helpers "because then the themers might can use it" well were actually asking for as little weight as possible to get the job done.

if we follow the idea of not having legacy code, then we should really start to ask why does this helper class need a html.js and not just the .js

Jacine’s picture

Damien, why do you keep saying this is a change just for the sake of it? The valid reason for this and the only reason is taming the CSS specificity. If you don't agree with the change (and I really don't get why, because we are really trying to clean up core CSS here for front end developers) that's one thing, but to continuously say there is no valid reason and mock people in the process is just wrong. And for the record, not that it's something that would ever be recommended, but @idflood is correct in saying that HTML and BODY tags are NOT required, but that's neither here nor there.

dcmouyard’s picture

+1 on Everett’s patch in #3. Can we RTBC this yet?

@mortendk What is crap for accessibility?

droplet’s picture

Status: Needs review » Needs work

Its inherited, html.js at very top level, so html.js & .js almost same thing.

Needs a reroll.

Damien Tournoud’s picture

@jacine:

... but @idflood is correct in saying that HTML and BODY tags are NOT required, but that's neither here nor there.

That's a common misconception. HTML and BODY are not required in the HTML source. But they *are* reconstructed by the browser when building the DOM.

Everett Zufelt’s picture

Status: Needs work » Needs review

#3: html.js_.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, html.js_.patch, failed testing.

dcrocks’s picture

Just a note that doesn't add much to this discussion: modernizr also adds a 'js' tag to the html element, so if you are using that code you carry two 'js' tags on the html element with your drupal pages. I've never seen code based on modernizr that uses anything but a simple .js selector.

Jacine’s picture

Status: Needs work » Closed (won't fix)

Don't need this aggravation.

Jacine’s picture

That's a common misconception. HTML and BODY are not required in the HTML source. But they *are* reconstructed by the browser when building the DOM.

A misconception by who? I know all about that. We were not talking about how browsers build the DOM, we are talking about what markup authors need to have for a valid HTML document. You are just picking fights here for no reason and trying to block a simple change that hurts no one, which is your prerogative, so have fun, but I don't have to deal with it.

/unsubscribe.

ericduran’s picture

Status: Closed (won't fix) » Needs work

I'm actually re-opening this issue.

For a couple of very simple reasons having nothing to do with, html5, browser magic, or not needing .

The extra specificity is completely pointless!! Is just simply not needed to begin with especially when being used in the way it's currently being used.

That being said the above patch needs work.

ericduran’s picture

Status: Needs work » Needs review

#3: html.js_.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, html.js_.patch, failed testing.

ericduran’s picture

Oh, this needs a re-roll because of the core directories.

droplet’s picture

I think the main purpose of .js class is tell browsers: It is JS enabled..we do something differently" (GLOBALLY, not just for HTML tag). Removing HTML tag or whatever, some of Drupal features may broken. It's another issue.

If not, we should do something like this at beginning...

<html class="js">
<head class="no-js">
</head>
<body class="no-js">
</body>
</html>
ericduran’s picture

The .js class is only use to style or do things differently with css, or to hide things. That's about all.

The .js class does belong in the html. This issue is not related to that.

This is strictly about removing the html.js declaration in the css to a more simpler and less specific .js.

ericduran’s picture

Status: Needs work » Needs review
FileSize
7.84 KB

- won't break anything.
- allows themer to stop using html.js when they really don't want to.

droplet’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.