aboutsummaryrefslogtreecommitdiffstats
path: root/test/jqLiteSpec.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 /test/jqLiteSpec.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 'test/jqLiteSpec.js')
-rw-r--r--test/jqLiteSpec.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index b23e23eb..b1fa6b05 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -924,8 +924,8 @@ describe('jqLite', function() {
describe('children', function() {
- it('should select non-text children', function() {
- var root = jqLite('<div>').html('before-<div></div>after-<span></span>');
+ it('should only select element nodes', function() {
+ var root = jqLite('<div><!-- some comment -->before-<div></div>after-<span></span>');
var div = root.find('div');
var span = root.find('span');
expect(root.children()).toJqEqual([div, span]);
@@ -934,11 +934,12 @@ describe('jqLite', function() {
describe('contents', function() {
- it('should select all children nodes', function() {
- var root = jqLite('<div>').html('before-<div></div>after-<span></span>');
+ it('should select all types child nodes', function() {
+ var root = jqLite('<div><!-- some comment -->before-<div></div>after-<span></span></div>');
var contents = root.contents();
- expect(contents.length).toEqual(4);
- expect(jqLite(contents[0]).text()).toEqual('before-');
+ expect(contents.length).toEqual(5);
+ expect(contents[0].data).toEqual(' some comment ');
+ expect(contents[1].data).toEqual('before-');
});
});