Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
feat(jqLite): add contents()
Browse files Browse the repository at this point in the history
  • Loading branch information
mhevery committed Jan 25, 2012
1 parent 84823b2 commit 97dae0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions test/jqLiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,16 @@ describe('jqLite', function() {
});


describe('contents', function() {
it('should select all children nodes', function() {
var root = jqLite('<div>').html('before-<div></div>after-<span></span>');
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('<div>');
Expand Down

0 comments on commit 97dae0d

Please sign in to comment.