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

Re: [css-selectors] :contains()

From: Allan Sandfeld Jensen <kde@carewolf.com>
Date: Thu, 19 Apr 2012 12:21:00 +0200
To: www-style@w3.org
Message-Id: <201204191221.00633.kde@carewolf.com>
On Tuesday 17 April 2012, Sebastian Zartner wrote:
> 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?
> 
I see a few things that needs to be clarified and could potentially make 
:contains() work better. Back when I did the CSS3 selectors for KHTML (I still 
believe the one of the only implementations of :contains()). I made it match 
against innerText. Today I am starting to think that if reintroduced :contains 
perhaps should only match on direct text node children of the element. 

Currently text nodes are one of the only parts of the DOM not matchable by CSS 
selectors, but there is no reason to make :contains computationally expensive 
by allowing it to match innerText. If it only matched direct text-nodes it 
would still be useful for the listed examples but much faster. 

Making it regular expression based on top of that would make it even more 
useful. In fact without regular expression it is still quite limited in 
usefulnes.

`Allan
Received on Thursday, 19 April 2012 10:21:38 GMT

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