From: Jörn Zaefferer Date: Tue, 7 Nov 2006 11:32:21 +0000 (+0000) Subject: Added test and check for end() when there is no stack or nothing on the stack to... X-Git-Tag: 1.0.4~55 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=83e98c28ef8aba11e525bf4266f8454232236ca0;p=jquery.git Added test and check for end() when there is no stack or nothing on the stack to pop() --- diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 35a6ceb2b..567e6a0fa 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -944,12 +944,15 @@ jQuery.fn = jQuery.prototype = { * @result $("p").find("span").end() == [

...

] * * @test ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' ); + * ok( $('#yahoo').end(), 'Check for end with nothing to end' ); * * @name end * @type jQuery * @cat DOM/Traversing */ end: function() { + if( !(this.stack && this.stack.length) ) + return this; return this.get( this.stack.pop() ); },