aboutsummaryrefslogtreecommitdiffstats
path: root/src/jqLite.js
diff options
context:
space:
mode:
authorPete Bacon Darwin2012-12-20 17:27:57 +0000
committerPete Bacon Darwin2013-01-09 09:22:35 +0000
commitfebb4c1c35cf767ae31fc9fef1f4b4f026ac9de0 (patch)
treeb921e64097110ae39e533cb8ff6e5329b9c4d9aa /src/jqLite.js
parent76a6047af690781b8238ba7924279470ba76d081 (diff)
downloadangular.js-febb4c1c35cf767ae31fc9fef1f4b4f026ac9de0.tar.bz2
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.
Diffstat (limited to 'src/jqLite.js')
-rw-r--r--src/jqLite.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/jqLite.js b/src/jqLite.js
index d156ae6d..46e0a73c 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) {