From 86cac55c7ce16e8adeae46649218d1b76fe222e3 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 20 Dec 2012 17:27:57 +0000 Subject: fix(jqLite): children() should only return elements The jQuery implementation of children only returns child nodes of the given element that are elements themselves. The previous jqLite implementation was returning all nodes except those that are text nodes. Use jQLite.contents() to get all the child nodes. The jQuery implementation of contents returns [] if the object has no child nodes. The previous jqLite implementation was returning undefined, causing a stack overflow in test/testabilityPatch.js when it tried to `cleanup()` a window object. The testabilityPatch was incorrectly using children() rather than contents() inside cleanup() to iterate down through all the child nodes of the element to clean up. --- src/jqLite.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/jqLite.js') diff --git a/src/jqLite.js b/src/jqLite.js index 2afcef54..1222d6da 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -647,14 +647,14 @@ forEach({ children: function(element) { var children = []; forEach(element.childNodes, function(element){ - if (element.nodeName != '#text') + if (element.nodeType === 1) children.push(element); }); return children; }, contents: function(element) { - return element.childNodes; + return element.childNodes || []; }, append: function(element, node) { -- cgit v1.2.3