On Tue, 22 Apr 2003, Michael Day wrote: > > I read this and it's certainly interesting. It seems to me that :has() is > the most useful aspect, in that it doesn't introduce new syntax (#) and is > very easy to read: > > form:has(textarea) It gets a bit confusing with, e.g.: h1:has(+ p) /* an h1 that has a p after it */ > However I find :matches() very difficult to understand, and need to > re-read such selectors several times to figure them out. That isn't too surprising given the power of the pseudo-class. > I feel that if such complicated selectors are really necessary, it's > almost worth bringing in XPath, which would fit more comfortably than > trying to stretch CSS further. How is XPath easier to use or understand than the equivalent CSS with :matches()? (You could just be more familiar with XPath than CSS.) Could you show the XPath equivalents for the examples at the bottom of:? http://lists.w3.org/Archives/Public/www-style/2002May/0037.html (Having said that, some people would like to extend CSS to allow XPath expressions as well as Selector expressions.) > Anyway, I'm definitely interested in implementing :has, but will > probably steer clear of :matches for now, until I run into an example > where I actually need it. The :matches() form with '#' at the start is equivalent to :has(), with the '#' in the middle is equivalent to a :has() followed by a :matches() with the '#' at the end, and with the '#' at the end it is useful for checking that there are multiple paths to the element. I'm not actually sure that the latter is strictly needed. For example: :matches(.bar #):matches(.baz #) ...is equivalent to: .bar.baz *, .bar .baz *, .baz .bar * For each additional :matches(... #) you exponentionally increase the number of selectors you have to put in the list though. Note: If you do implement this, make sure to do it as :-foo-has(). This is not yet in a CR spec (it isn't in any spec in fact), and is highly likely to change at least a bit before getting in a spec, if it ever does. For example, the current definition makes: a:matches(b) ...useless. Nothing that simple should be that useless IMHO. :-) Maybe the proposal should be changed to imply the # at the start instead of at the end (so :matches() without # becomes equivalent to :has()). -- Ian Hickson )\._.,--....,'``. fL "meow" /, _.. \ _\ ;`._ ,. http://index.hixie.ch/ `._.-(,_..'--(,_..'`-.;.'Received on Tuesday, 22 April 2003 17:56:39 GMT
This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:21 GMT