feat(jqLite): add contents()

This commit is contained in:
Misko Hevery 2011-12-14 09:28:35 +01:00
parent 84823b2eff
commit 97dae0d0a0
2 changed files with 15 additions and 0 deletions

View file

@ -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)

View file

@ -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>');