From 83e98c28ef8aba11e525bf4266f8454232236ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Zaefferer?= Date: Tue, 7 Nov 2006 11:32:21 +0000 Subject: [PATCH] Added test and check for end() when there is no stack or nothing on the stack to pop() --- src/jquery/jquery.js | 3 +++ 1 file changed, 3 insertions(+) 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() ); },