Re: [css-selectors] :contains()

> > I assume you mean the 'textContent' property.
> > This would be a speed boost in many cases, though you would also lose
> > functionality. E.g. imagine something like this:
> > 
> > <p>This is an <strong>important</strong> sentence.</p>
> > 
> > Then you wouldn't have the possibility to style the paragraph by
> searching
> > for the word 'important'.
> I think that can be solved using already existing features of CSS
> selector, especially level 4.
How?

What if you have this:
  <p>This is an <strong>important</strong> sentence.</p>
  <p>This is another important sentence</p>
  <p>This is a third <strong>very <em>important</em></strong> sentence</p>

I imagine all three paragraphs to be matched using p:contains("important").

> p:contains('important'), p! *:contains('imporant')
What does that exclamation mark mean here?

> 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.
> (Technically you will also miss the opportunity to match 'word' in
> something 
> like: <span>wo<em>rd</em></span>, but is that needed?)
There will be cases (like the text search I mentioned earlier), in which you will want this.

Example:
  <p>This is an <strong>important</strong> sentence.</p>

This should be matched by :contains("important sentence").

> Appropos :empty though. We end up with the same question in :contains.
> Should the match happen before or after text-transformations? After is 
> not very feasible, but if matching happens before then white-space 
> might not be what you expect it to be.
I do not see any clear statement related to this at http://www.w3.org/TR/selectors4/#empty-pseudo.
Regarding 'text-transform' :contains() should not be influenced by that. It should check the actual node contents. If you want to match case insensitive, then you should use a regexp for that like :contains(/word/i).

Sebastian
-- 
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!                                  
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a

Received on Friday, 20 April 2012 12:08:41 UTC