From e3cf259a93692d41bbb953ddc938765cbe9c24a4 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 21 Jun 2011 13:45:40 -0400 Subject: [PATCH] Fixed issues with number of elements returned by selector in dom module --- kis.js | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/kis.js b/kis.js index d2a18ed..a486ecc 100644 --- a/kis.js +++ b/kis.js @@ -412,6 +412,12 @@ { sel = _sel(sel); + if(sel.length < 2) + { + callback(sel); + return; + } + for(var x in sel) { callback(sel[x]); @@ -436,10 +442,17 @@ hide: function(sel) { sel = _sel(sel); - - this.each(sel, function(e){ - e.style.display = "none"; - }); + + if(sel.length > 1) + { + this.each(sel, function(e){ + e.style.display = "none"; + }); + } + else + { + sel.style.display = "none"; + } }, show: function(sel, type) @@ -451,9 +464,16 @@ type="block"; } - this.each(sel, function(e){ - e.style.display = type; - }); + if(sel.length > 1) + { + this.each(sel, function(e){ + e.style.display = type; + }); + } + else + { + sel.style.display = type; + } } };