[css-selectors] :contains()

There's a discussion at https://bugzil.la/221981 about adding the :contains() pseudo-class selector to the Mozilla CSS core.
According to Ian Hickson (http://lists.w3.org/Archives/Public/www-style/2005Dec/0155.html) and David Baron (https://bugzil.la/221981#c15) this feature was dropped from the spec due to a lack of implementations.
This mail aims for a re-introduction of :contains() into the spec and to discuss its implementation.

Syntax:
  :contains( <string> )

Possible use cases for :contains() are:
- styling negative numbers (https://bugzil.la/221981#c30)
- highlighting Sundays in a calendar
- highlighting search matches in a table
- hiding parts of a page (https://bugzil.la/221981#c4)

The discussion mentions several pros and cons regarding its implementation:
Pro:
- allows styling elements depending on their content
- avoids workarounds with JavaScript or semantic mark up

Contra:
- introduces security issues (https://bugzil.la/221981#c12)
- slows down page speed (https://bugzil.la/221981#c3)


So far only simple substring matches were discussed in https://bugzil.la/221981.
Though the functionality of :contains() could be further enhanced by:

1. allowing to match regular expressions:
Syntax:
  :contains( <string> | <regular expression> )

Example:
  .author:contains(/owner|committer/)

2. allowing to use it as parent selector:
Syntax:
  :contains( <string> | <selector> )

Example:
  #thread:contains(.deletedPost)

Any thoughts on this?

Sebastian
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

Received on Tuesday, 17 April 2012 13:07:21 UTC