mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
Added prepend() to jqLite
This commit is contained in:
parent
4f2f3c9cbf
commit
89e001b18a
3 changed files with 36 additions and 0 deletions
|
|
@ -1,6 +1,10 @@
|
|||
<a name="0.9.17"><a/>
|
||||
# <angular/> 0.9.17 vegetable-reanimation (in progress) #
|
||||
|
||||
### New Features
|
||||
- Added prepend() to jqLite
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
- Number filter would return incorrect value when fractional part had leading zeros.
|
||||
|
||||
|
|
|
|||
|
|
@ -408,6 +408,20 @@ forEach({
|
|||
});
|
||||
},
|
||||
|
||||
prepend: function(element, node) {
|
||||
if (element.nodeType === 1) {
|
||||
var index = element.firstChild;
|
||||
forEach(new JQLite(node), function(child){
|
||||
if (index) {
|
||||
element.insertBefore(child, index);
|
||||
} else {
|
||||
element.appendChild(child);
|
||||
index = child;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
remove: function(element) {
|
||||
JQLiteDealoc(element);
|
||||
var parent = element.parentNode;
|
||||
|
|
|
|||
|
|
@ -380,6 +380,24 @@ describe('jqLite', function(){
|
|||
});
|
||||
});
|
||||
|
||||
describe('prepend', function(){
|
||||
it('should prepend to empty', function(){
|
||||
var root = jqLite('<div>');
|
||||
expect(root.prepend('<span>abc</span>')).toEqual(root);
|
||||
expect(root.html().toLowerCase()).toEqual('<span>abc</span>');
|
||||
});
|
||||
it('should prepend to content', function(){
|
||||
var root = jqLite('<div>text</div>');
|
||||
expect(root.prepend('<span>abc</span>')).toEqual(root);
|
||||
expect(root.html().toLowerCase()).toEqual('<span>abc</span>text');
|
||||
});
|
||||
it('should prepend text to content', function(){
|
||||
var root = jqLite('<div>text</div>');
|
||||
expect(root.prepend('abc')).toEqual(root);
|
||||
expect(root.html().toLowerCase()).toEqual('abctext');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
describe('remove', function(){
|
||||
it('should remove', function(){
|
||||
|
|
|
|||
Loading…
Reference in a new issue