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

Commit 97dae0d

Browse files
committed
feat(jqLite): add contents()
1 parent 84823b2 commit 97dae0d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/jqLite.js

+5
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* - [bind()](http://api.jquery.com/bind/)
3636
* - [children()](http://api.jquery.com/children/)
3737
* - [clone()](http://api.jquery.com/clone/)
38+
* - [contents()](http://api.jquery.com/contents/)
3839
* - [css()](http://api.jquery.com/css/)
3940
* - [data()](http://api.jquery.com/data/)
4041
* - [eq()](http://api.jquery.com/eq/)
@@ -556,6 +557,10 @@ forEach({
556557
return children;
557558
},
558559

560+
contents: function(element) {
561+
return element.childNodes;
562+
},
563+
559564
append: function(element, node) {
560565
forEach(new JQLite(node), function(child){
561566
if (element.nodeType === 1)

test/jqLiteSpec.js

+10
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,16 @@ describe('jqLite', function() {
731731
});
732732

733733

734+
describe('contents', function() {
735+
it('should select all children nodes', function() {
736+
var root = jqLite('<div>').html('before-<div></div>after-<span></span>');
737+
var contents = root.contents();
738+
expect(contents.length).toEqual(4);
739+
expect(jqLite(contents[0]).text()).toEqual('before-');
740+
});
741+
});
742+
743+
734744
describe('append', function() {
735745
it('should append', function() {
736746
var root = jqLite('<div>');

0 commit comments

Comments
 (0)