yeah, looks like it would work to me. much more concise, too. nice  
job. And thanks for pointing it out.

Cheers,

--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com




On Sep 13, 2008, at 9:00 PM, E. Myller wrote:

>
> Hello.
>
> I'm that "someone on twitter" and I think i have a simpler solution...
>
> I dont think it's better to work with a RegExp when we can do it by
> simply string methods.
>
> On my own JS Library, utm, i just did the following:
>
> ...
> // s[3] is the matching value we're looking for
> _s[2] == '~=' && (' ' + attr + ' ').indexOf(' ' + _s[3] + ' ') >= 0 ||
> _s[2] == '*=' && attr.indexOf(_s[3]) >= 0 ||
> ...
>
> Hope it might work.
> the full source can be found at http://utmproject.org/ .
>
>
> On Sep 13, 6:54 pm, Karl Swedberg <[EMAIL PROTECTED]> wrote:
>> Hi folks,
>>
>> Someone on Twitter just alerted me to an error in one of the  
>> attribute
>> selectors: ~= .
>>
>> According to the W3C[1]:
>>         E[foo~="bar"]         an E element whose "foo" attribute  
>> value is a list of
>> space-separated values, one of which is exactly equal to "bar"
>>
>> So given $('[class~=bar]') , the following should match:
>>
>>         class="foo bar" , class="bar" , class= "baz foo bar"
>>
>> but these should not match:
>>
>>         class="foobar" class="barfoo" class="foo barbaz"
>>
>> Currently, jQuery is treating ~= the same as *= , which is clearly
>> incorrect, in line 347 of selector.js:
>>
>>         (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0
>>
>> I have a couple ideas for dealing with the two attribute selectors
>> separately. I'm sure they can be improved on greatly. I'm interested
>> in your thoughts:
>>
>> 1: Regular Expression:
>>
>>         // before the if statement:
>>         var sd = new RegExp('^(.* +)?' + m[5] + '( +.*)?$');
>>
>>         //within the if statement:
>>         type == "*=" && z.indexOf(m[5]) >= 0 ||
>>         type == "~=" && sd.test(z)
>>
>> 2. Array:
>>
>>         //within the if statement:
>>         type == "*=" && z.indexOf(m[5]) >= 0 ||
>>         type == "~=" && jQuery.inArray(m[5],z.split(' ')) > -1
>>
>> So, what do you think? Is it worth fixing this? Is there a better
>> solution?
>>
>> [1]http://www.w3.org/TR/css3-selectors/
>>
>> --Karl
>>
>> ____________
>> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to