mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
feat(jqLite): add contents()
This commit is contained in:
parent
84823b2eff
commit
97dae0d0a0
2 changed files with 15 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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>');
|
||||
|
|
|
|||
Loading…
Reference in a new issue