W3C home > Mailing lists > Public > www-style@w3.org > April 2012

Re: [css-selectors] :contains()

From: Sebastian Zartner <sebastianzartner@gmx.de>
Date: Fri, 20 Apr 2012 14:08:04 +0200
Message-ID: <20120420120804.61320@gmx.net>
To: Allan Sandfeld Jensen <kde@carewolf.com>, www-style@w3.org
> > 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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:52 GMT