Re: Collapsing elements

On Thursday 21 February 2008 11:10, Daniel Glazman wrote:
> Bert Bos wrote:
> > Another example:
> >
> >     div:initial * {display: none}
> >     div:initial h2 {display: block}
> >
> >     ...
> >     <div>
> >       <h2>Heading of this section</h2>
> >       <p>First paragraph...
> >       ...
> >     </div>
>
> Right, that works for LI and sub-lists. But how do you
> query from JS the state of such a list item, expanded or
> collapsed ? Checking the computed value of the display
> property on all children of that LI is not a workable
> solution.
>
> We need to be able to query 'something' directly from the LI.
> That means a solution based uniquely on the display property
> of the children is not enough. We need an attribute on the LI
> or a unique CSS property setting the expanded/folded status
> of the item.

A pseudo-class represents a state. According to CSS, elements can be 
active, visited, link, first-child, disabled, target, invalid, etc. I'm 
adding one more: initial.

How do you currently query CSS states from Javascript? Can't you 
generalize (one of) the existing methods to include ':initial' as well?

And there is actually nothing special about the LI. In my example the LI 
*doesn't* have an ':initial' state. There may be any number of elements 
whose states influence the style of the LI, because of cascading or 
inheritance.



Bert
-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos                               W3C/ERCIM
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France

Received on Thursday, 21 February 2008 15:08:12 UTC