From febb4c1c35cf767ae31fc9fef1f4b4f026ac9de0 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. --- test/testabilityPatch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/testabilityPatch.js') diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js index ac22c72c..d55ff015 100644 --- a/test/testabilityPatch.js +++ b/test/testabilityPatch.js @@ -78,7 +78,7 @@ function dealoc(obj) { function cleanup(element) { element.unbind().removeData(); - for ( var i = 0, children = element.children() || []; i < children.length; i++) { + for ( var i = 0, children = element.contents() || []; i < children.length; i++) { cleanup(jqLite(children[i])); } } -- cgit v1.2.3