Bug in $() in jQuery v1.1.1?

View: New views
11 Messages — Rating Filter:   Alert me  

Bug in $() in jQuery v1.1.1?

by Dan G. Switzer, II :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've got the following test case that performs quite a bit different between
v1.0.4 and v1.1.1.

In the code below v1.0.4 returns an undefined object for both test
cases--which certainly seems like it would be the expected behavior (I mean
if an element doesn't exist, it shouldn't be returned.) Also, the statements
should for all intents and purposes return the exact same results.

However, in v1.1.1 I you get radically different results. The first case
returns the context element--which definitely seems wrong--and the second
test returns an empty element--which seems like an unexpected behavior.

Should v1.1.1 really be returning an empty element if no match exists?

-Dan

PS - Here's the test.

<ul id="idTest">
  <li class="selected2">
    Item 1
  </li>
  <li>
    Item 2
  </li>
  <li>
    Item 3
  </li>
</ul>

<input type="button" value="test" onclick="bug()" />

<script type="text/javascript">
function bug(){

  // v1.1.1 returns parent element (the UL--which is the context element)
  // v1.0.4 returns undefined
  alert(
    $("li.selected", document.getElementById("idTest"))[0]
  );

  // v1.1.1 returns an empty element
  // v1.0.4 returns undefined
  alert(
    $("#idTest li.selected")[0]
  );
}
</script>


_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: Bug in $() in jQuery v1.1.1?

by John Resig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dan -

I'm fairly certain that this has already been fixed in SVN, by Joern.
It was an issue with the fact that [0] had a value, while .length was
set to 0.

Maybe Joern can confirm that this has, in fact, been fixed.

--John

On 1/30/07, Dan G. Switzer, II <dswitzer@...> wrote:

> I've got the following test case that performs quite a bit different between
> v1.0.4 and v1.1.1.
>
> In the code below v1.0.4 returns an undefined object for both test
> cases--which certainly seems like it would be the expected behavior (I mean
> if an element doesn't exist, it shouldn't be returned.) Also, the statements
> should for all intents and purposes return the exact same results.
>
> However, in v1.1.1 I you get radically different results. The first case
> returns the context element--which definitely seems wrong--and the second
> test returns an empty element--which seems like an unexpected behavior.
>
> Should v1.1.1 really be returning an empty element if no match exists?
>
> -Dan
>
> PS - Here's the test.
>
> <ul id="idTest">
>   <li class="selected2">
>     Item 1
>   </li>
>   <li>
>     Item 2
>   </li>
>   <li>
>     Item 3
>   </li>
> </ul>
>
> <input type="button" value="test" onclick="bug()" />
>
> <script type="text/javascript">
> function bug(){
>
>   // v1.1.1 returns parent element (the UL--which is the context element)
>   // v1.0.4 returns undefined
>   alert(
>     $("li.selected", document.getElementById("idTest"))[0]
>   );
>
>   // v1.1.1 returns an empty element
>   // v1.0.4 returns undefined
>   alert(
>     $("#idTest li.selected")[0]
>   );
> }
> </script>
>
>
> _______________________________________________
> jQuery mailing list
> discuss@...
> http://jquery.com/discuss/
>

_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: Bug in $() in jQuery v1.1.1?

by Jörn Zaefferer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

John Resig schrieb:
> Dan -
>
> I'm fairly certain that this has already been fixed in SVN, by Joern.
> It was an issue with the fact that [0] had a value, while .length was
> set to 0.
>
> Maybe Joern can confirm that this has, in fact, been fixed.
>  
 From what I can see in the example code, that is exactly the issue I fixed.

In case you want to test it with your copy of jQuery, modify pushStack
to look like this:

pushStack: function( a ) {
        var ret = jQuery(a);
        ret.prevObject = this;
        return ret;
},

--
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: Bug in $() in jQuery v1.1.1?

by Dan G. Switzer, II :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Jörn,

>In case you want to test it with your copy of jQuery, modify pushStack
>to look like this:
>
>pushStack: function( a ) {
> var ret = jQuery(a);
> ret.prevObject = this;
> return ret;
>},

Yes, that does indeed fix the problem! I guess I should have searched the
archives better.

-Dan


_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: Bug in $() in jQuery v1.1.1?

by John Resig :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Yes, that does indeed fix the problem! I guess I should have searched the
> archives better.

I don't think it was mentioned on the mailing list - we hunted it down
and destroyed it on IRC, I think. Don't feel bad :-)

--John

_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Parent Message unknown Re: Bug in $() in jQuery v1.1.1?

by sholby :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 30 janv. 07, at 22:27, Jörn Zaefferer wrote:

> In case you want to test it with your copy of jQuery, modify pushStack
> to look like this:
>
> pushStack: function( a ) {
> var ret = jQuery(a);
> ret.prevObject = this;
> return ret;
> },

Fwiw, i modified my jquery.js with this, and discovered that it broke the
Accordion plugin somewhat. I use Accordion with a setting to start with no
submenu open:

$(".deroulant").Accordion({
    header: 'a.pliant',
    active: 'false'
});

and after making the "fix" in jquery, all submenus were opened when i opened the
main menu, with assorted weirdness when clicking. So perhaps Accordion will need
a fix too...

Best regards,

--
  Stéphane Nahmani / sholby
  sholby@...
  http://www.sholby.net/

_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: Bug in $() in jQuery v1.1.1?

by Jörn Zaefferer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Stéphane Nahmani schrieb:

> Fwiw, i modified my jquery.js with this, and discovered that it broke the
> Accordion plugin somewhat. I use Accordion with a setting to start with no
> submenu open:
>
> $(".deroulant").Accordion({
>     header: 'a.pliant',
>     active: 'false'
> });
>
> and after making the "fix" in jquery, all submenus were opened when i opened the
> main menu, with assorted weirdness when clicking. So perhaps Accordion will need
> a fix too...
>  
Ok, I'll check it.

--
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: Bug in $() in jQuery v1.1.1?

by Jörn Zaefferer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Stéphane Nahmani schrieb:

> On 30 janv. 07, at 22:27, Jörn Zaefferer wrote:
>
>  
>> In case you want to test it with your copy of jQuery, modify pushStack
>> to look like this:
>>
>> pushStack: function( a ) {
>> var ret = jQuery(a);
>> ret.prevObject = this;
>> return ret;
>> },
>>    
>
> Fwiw, i modified my jquery.js with this, and discovered that it broke the
> Accordion plugin somewhat. I use Accordion with a setting to start with no
> submenu open:
>
> $(".deroulant").Accordion({
>     header: 'a.pliant',
>     active: 'false'
> });
>
> and after making the "fix" in jquery, all submenus were opened when i opened the
> main menu, with assorted weirdness when clicking. So perhaps Accordion will need
> a fix too...
>  
Could you try version 1.1 of the plugin?
http://bassistance.de/jquery-plugins/jquery-plugin-accordion/

It should work fine now.

--
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: Bug in $() in jQuery v1.1.1?

by sholby :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 3 févr. 07, at 12:50, Jörn Zaefferer wrote:

> Could you try version 1.1 of the plugin?
> http://bassistance.de/jquery-plugins/jquery-plugin-accordion/
>
> It should work fine now.

Hello Jörn,

Thanks for the new version. However, the issue is still the same if i  
use the SVN modified version of JQuery (unpacked).
I'm sending you a coupl of screenshots offlist, so you can see what i  
mean.

Best,


--
   stéphane nahmani
   courriel : sholby@...
   web      : http://www.sholby.net/


_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: Bug in $() in jQuery v1.1.1?

by Jörn Zaefferer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Stéphane Nahmani schrieb:
> Thanks for the new version. However, the issue is still the same if i  
> use the SVN modified version of JQuery (unpacked).
> I'm sending you a coupl of screenshots offlist, so you can see what i  
> mean.
>  
Could you please try the latest revision of jQuery? I've uploaded it
here, in case you don't have svn access:
http://jquery.bassistance.de/dist/jquery.js

--
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/

Re: Bug in $() in jQuery v1.1.1?

by sholby :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 3 févr. 07, at 14:13, Jörn Zaefferer wrote:

> Could you please try the latest revision of jQuery? I've uploaded it
> here, in case you don't have svn access:

Actually i don't. I tried with this version, and the issue remains as  
before. I'm wondering if this could be related to the fact that it's  
*not* packed? Unlikely, but...

--
   stéphane nahmani
   courriel : sholby@...
   web      : http://www.sholby.net/


_______________________________________________
jQuery mailing list
discuss@...
http://jquery.com/discuss/