Re: [cssom] Make CSSStyleSheet constructable

|  |  I don't see how? The tabs are not in the template.
|
|  Then you need a way add "invisible" classes from the component.

Now that I think about it, you could even use a normal namespace for the use 
case. I do believe that the external document using the tab component may 
also want to apply some custom style to the selected tab or tab-strip. I'm 
not sure at all it makes sense to hide this information to him since he can 
retreive it back from other (complicated) ways anyway.



For example, you may have two kinds of tab-stips (the ones that become blue 
when selected and the ones that become red). If you have a "@namespace 
tab-data" to get the selection properties, you can simply have the following 
declaration in your document's stylesheet:

    h2.red[tab-data|selected] { color: red !important; }
    h2.blue[tab-data|selected] { color: blue !important; }

that would override the default style defined in your template's stylesheet:

    h2[tab-data|selected] { color: black; }

If your component doens't leak the selection status, you can't apply those 
'overidden' styles easily.



By the way, your current solution (relying on nth-of-type to show the right 
tab) fails to handle correctly the insertion of new tabs at runtime. If you 
insert a new tab before the currently selected tab, the focus will move to 
the previous tab without any user interaction. If you're using an attribute, 
you don't have the same issue. 

Received on Saturday, 20 October 2012 10:55:20 UTC