Page MenuHomePhabricator

display:none in headlines is not observed for TOC
Closed, InvalidPublic

Description

Author: claus.colloseus

Description:
If you have - through a template - some content in a minor headline that is hidden through a style="display:none", it will show up in the table of contents.

An example of this behavior is the country-with-flag template http://de.wikipedia.org/wiki/Vorlage:AUT which contains a sorting template http://de.wikipedia.org/wiki/Vorlage:SortKey aimed at geting the word "Österreich" to show up under "O" in sorted tables. However, the country template may also be used in headings like in the URL given above.


Version: unspecified
Severity: normal
URL: http://de.wikipedia.org/wiki/Liste_des_UNESCO-Welterbes_(Europa)

Details

Reference
bz16582

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:23 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz16582.
bzimport added a subscriber: Unknown Object (MLST).

Generating of TOC is based on HTML content. CSS is just presentational layer. The headline is still present even when it's "not visible" - search engines, bots, user agents with CSS off, DOM inspectors etc. still see it thus it's correct behavior to have it in TOC.

Marking as INVALID.

ayg wrote:

More to the point, this isn't realistically possible to fix. We can't tell at parse time what styles might be applied to a given element. You have to just not include the content if you want to use the template in headlines, display: none isn't going to work. display: none is probably a bad choice anyway, since as Danny mentions, the content will still show up for search engines and so on.

Farino wrote:

Although I do not want to support this bug too heavily I would like to add some information to clearify the source of this request. At least in DE-wp more and more templates add a "span style='display:none'" to support propper sorting in tables with the class="sortable" (be aware that we have a lot of theese grazy umlauts). Unfortunatelly thoose templates are sometimes also used in titles or other parsed tags. I understand that you cannot anticipate the CSS-selector that is finally applied to an element, but a hard-coded style would override all external styles anyway so it would technical be possible to remove at least spans with hard-coded "display:none".

ayg wrote:

  1. A hardcoded style wouldn't override a stylesheet rule with !important.
  1. If we parsed only hardcoded styles, we would be creating a very confusing situation, where inline CSS rules have magical functionality that stylesheet rules do not.
  1. Using inline styles is bad practice, and so is display:none'ing things instead of removing them from the DOM to begin with, so we should avoid encouraging those if possible.

Do comments work, maybe? If not, we could consider alternative solutions. For instance, if we allowed HTML5-style custom attributes on all elements, we could make data-sortkey="foo" magically sort the column according to "foo" instead of the contents. That would probably be easier to implement, too.

Farino wrote:

Sorry, I haven't thought of !important. Your proposal comes close to the invention of sliced bread at it would reindroduce the semantics of what the data is. Is there a chance for such a change?

ayg wrote:

I dunno. Not from me right now, I'm too busy with other things. Try filing another bug on that issue, if none already exists. We'd be deliberately ignoring XHTML compatibility if we did this, of course, but IMO we should probably move to HTML5 anyway. :)