From 76a6047af690781b8238ba7924279470ba76d081 Mon Sep 17 00:00:00 2001 From: Keyamoon Date: Thu, 20 Dec 2012 03:18:47 +0330 Subject: fix(jqLite): make next() ignore non-element nodes next() is supposed to return the next sibling *element* so it should ignore text nodes. To achieve this, nextElementSibling() should be used instead of nextSibling(). --- src/jqLite.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/jqLite.js b/src/jqLite.js index 8305f0c3..d156ae6d 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -718,7 +718,16 @@ forEach({ }, next: function(element) { - return element.nextSibling; + if (element.nextElementSibling) { + return element.nextElementSibling; + } + + // IE8 doesn't have nextElementSibling + var elm = element.nextSibling; + while (elm != null && elm.nodeType !== 1) { + elm = elm.nextSibling; + } + return elm; }, find: function(element, selector) { -- cgit v1.2.3