Re: [css-selectors] :contains()

On Friday 20 April 2012, Kang-Hao (Kenny) Lu wrote:
> (12/04/20 16:48), Allan Sandfeld Jensen wrote:
> > I think that can be solved using already existing features of CSS
> > selector, especially level 4.
> > 
> > p:contains('important'), p! *:contains('imporant')
> 
> I heard that (from [1], for what it's worth) the subject marker is going
> to be removed soon for performance reasons, so ... we probably shouldn't
> assume that this still exists.
> 
I assume part of the functionality will arrive in another form then, because 
it is one of the most requested features. The generic subject selector might 
be overkill, but something similar for just children and descendants would be 
more feasible.

If a subject selector is not introduced and :contains is implemented, then I 
wil predict seeing :contains abused to simulate the feature, anyway the 
problems with dynamic restyling are very similar for the two features.

In any case I would argue for :contains matching only direct text-nodes, 
because it avoids the problems with deeper dependencies, issues that it would 
share with any generic subject-selector solution. 

> > This is what I meant. The only thing really missing right now to be able
> > to match against the content of text-nodes. Only :empty does that right
> > now.
> 
> Sorry but I am lost here. May I ask for an example here?
> 
I just meant :empty is the only selector responding to changes in text-nodes 
currently. Inserting a non-empty text-node for instance, or inserting text 
into an empty one.

The issue I raised with white-space, is that the :empty selector is currently 
somewhat useless, since it doesn't know if new-lines are significant or not. 
This means elements where start and end tag are only separated by a new-line 
are not considered empty. The real problem with that is that whether the new-
line is significant or not, is, for HTML, based on a CSS property. So it is not 
possible to resolve before evaluating selectors, at least not without 
introducing CSS styling paradoxes :o)

Cheers
`Allan

Received on Sunday, 22 April 2012 09:54:47 UTC