From 97dae0d0a0226ee527771578bfad1342d51bf4dd Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Wed, 14 Dec 2011 09:28:35 +0100 Subject: [PATCH] feat(jqLite): add contents() --- src/jqLite.js | 5 +++++ test/jqLiteSpec.js | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/jqLite.js b/src/jqLite.js index e7412904a04b..9e16f8ecca04 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -35,6 +35,7 @@ * - [bind()](http://api.jquery.com/bind/) * - [children()](http://api.jquery.com/children/) * - [clone()](http://api.jquery.com/clone/) + * - [contents()](http://api.jquery.com/contents/) * - [css()](http://api.jquery.com/css/) * - [data()](http://api.jquery.com/data/) * - [eq()](http://api.jquery.com/eq/) @@ -556,6 +557,10 @@ forEach({ return children; }, + contents: function(element) { + return element.childNodes; + }, + append: function(element, node) { forEach(new JQLite(node), function(child){ if (element.nodeType === 1) diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index 5936395ed5cd..3abe4549eedf 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -731,6 +731,16 @@ describe('jqLite', function() { }); + describe('contents', function() { + it('should select all children nodes', function() { + var root = jqLite('
').html('before-
after-'); + var contents = root.contents(); + expect(contents.length).toEqual(4); + expect(jqLite(contents[0]).text()).toEqual('before-'); + }); + }); + + describe('append', function() { it('should append', function() { var root = jqLite('
');