W3C home > Mailing lists > Public > www-style@w3.org > September 2013

Re: [cssom][css-display][css-cascade] revisiting "default display"

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 6 Sep 2013 12:08:54 -0700
Message-ID: <CAAWBYDDGWTxvuvuYfeoZxuRTxAAHLz2jvC3VW+cFzLLqsKKYwg@mail.gmail.com>
To: Mike Sherov <mike.sherov@gmail.com>
Cc: "www-style@w3.org" <www-style@w3.org>
On Fri, Sep 6, 2013 at 2:36 AM, Mike Sherov <mike.sherov@gmail.com> wrote:
> 2. A bit more insidiously, a javascript library wants to "show" a div that
> is already "hidden" through an element selector in the author style sheet:
> div {display:none;}. Can Display Level 3 address this? The current spec
> says:
>
> The computed value of box is the specified value, unlessdisplay-outside has
> the value none, in which case the computed value of box is none as well.
>
> I believe this prevents a JS library like jQuery from overcoming authors who
> use element selectors to define display:none. This may not seem like a big
> use case, but happens often enough. We're left with the situation where
> Display 3 still needs a mechanism by which an element can be reverted to its
> "default display". Now, we can add a value to display-outside like default
> that accomplishes this, but now its starting to sound very familiar to the
> generic "default" keyword that was just dropped from cascade level 3.
>
> To be clear, currently a javascript library must append an iframe to the
> page to get at the "default value" of display for the div. CSSOM had at one
> point defined an interface created by dbaron called
> getDefaultComputedStyle() to essentially emulate the iframe hack. In
> conjunction, Cascading 3 at one point had a "default value" to define what
> value gDCS returns.
>
> I know I raised this issue and subsequently acquiesced when Cascading Level
> 3 was still LC, but I find myself still needing a solution to this problem
> not yet covered by any spec.

*Nothing* can address this problem.  Getting the initial value *kinda*
helps *today*, because most people still use either display:block or
display:inline for everything, but that's it.  As flexbox and grid
become more popular, elements will commonly be intended to use those
displays, and then the "default value" is worthless.

I'm curious why jQuery uses an iframe hack.  Is it just to be
future-proof?  Just keeping around an array of default-block element
names should be sufficient if you're not trying to be robust against
future element additions (and if it's exposed, authors can just add to
it in that case until jQuery updates).

The only way to actually let an element be hidden by default and then
show with the correct display type is for authors to use "box: none;"
in the first place, rather than "display:none".  "display:none" is
just a pernicious legacy mistake.

So I still don't think it's worthwhile to add back default values.  It
simply doesn't help this use-case sufficiently to be worthwhile imo.

~TJ
Received on Friday, 6 September 2013 19:09:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:34 UTC