Re: Text selector [was Re: breaking overflow]

On Jan 4, 2010, at 6:32 AM, Tab Atkins Jr. wrote:

> The simplest rule that covers reasonable cases is
> that it matches on the DOM, and adjacent text nodes are treated as
> being together for the purpose of matching.  I still don't support
> matching across element boundaries, as it will work in a non-intuitive
> manner.  
[...]
> Rather than deal with this sort of confusion, I think it's better to
> just say that you can't cross element boundaries at all.  This will
> still result in confusion sometimes (particularly when the text has an
> otherwise-invisible <span> in it or the like), but it will be lesser,
> and easier to understand.  (I think explaining the way pseudoelements
> get broken up into multiple pieces and how that effects some
> properties is much more difficult than explaining "all the text has to
> be together in the element to match".)

Yes, I agree.


> This means that for Boris's examples, 1, 5, and 6 would match, 3 and 4
> would not.  I'm not sure what I feel is best for 2 - I could go either
> way, whichever seems more consistent.  

The reason I'd make an exception for comments is that they are supposed to be there just for people reading the code (or in some cases for machines to be able to identify sections of code), but are intended to have no other effects usually. I would not want an author to avoid commenting his code, just for fear of how it might restrict styling.

>> As an aside, I believe it would also be beneficial to have the ability to
>> include multiple strings in the same selector, something like ::text("foo
>> bar", "test text").
> 
> Yeah, I can see the use for that.  I'd consider it necessary, in fact,
> now that you mention it.

I would prefer the second argument to be regexp to be switches for case sensitivity and globalness (with global the default, however). So for instance:

::text("foo") = matches "foo" but not "Foo", as often as it occurs
::text("foo","g")  = matches "foo" but not "Foo", as often as it occurs
::text("foo","ig")  = matches "foo" and "Foo", as often as they occur
::text("foo","i")  = matches "foo" or "Foo", first occurrence only (order within DOM text node(s))
::text("foo","")  = matches "foo" but not "Foo", first occurrence only

To match more than one string, just use regexp:

::text("foo bar|test text")

Received on Monday, 4 January 2010 17:21:54 UTC