]> source.dussan.org Git - jquery.git/commitdiff
Fixed bug #178
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Sat, 16 Sep 2006 15:50:35 +0000 (15:50 +0000)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Sat, 16 Sep 2006 15:50:35 +0000 (15:50 +0000)
src/jquery/jquery.js

index ac263bcedff45b0fc35822e2437c8ed37d8a37ff..dca186744cd58d79818b63aab2a5f44bdd846be6 100644 (file)
@@ -1916,15 +1916,17 @@ jQuery.extend({
         */
        sibling: function(elem, pos, not) {
                var elems = [];
-
-               var siblings = elem.parentNode.childNodes;
-               for ( var i = 0; i < siblings.length; i++ ) {
-                       if ( not === true && siblings[i] == elem ) continue;
-
-                       if ( siblings[i].nodeType == 1 )
-                               elems.push( siblings[i] );
-                       if ( siblings[i] == elem )
-                               elems.n = elems.length - 1;
+               
+               if(elem) {
+                       var siblings = elem.parentNode.childNodes;
+                       for ( var i = 0; i < siblings.length; i++ ) {
+                               if ( not === true && siblings[i] == elem ) continue;
+       
+                               if ( siblings[i].nodeType == 1 )
+                                       elems.push( siblings[i] );
+                               if ( siblings[i] == elem )
+                                       elems.n = elems.length - 1;
+                       }
                }
 
                return jQuery.extend( elems, {