File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<a name =" 0.9.17 " ><a />
22# <angular /> 0.9.17 vegetable-reanimation (in progress) #
33
4+ ### New Features
5+ - Added prepend() to jqLite
6+
7+
48### Bug Fixes
59- Number filter would return incorrect value when fractional part had leading zeros.
610
Original file line number Diff line number Diff line change @@ -408,6 +408,20 @@ forEach({
408408 } ) ;
409409 } ,
410410
411+ prepend : function ( element , node ) {
412+ if ( element . nodeType === 1 ) {
413+ var index = element . firstChild ;
414+ forEach ( new JQLite ( node ) , function ( child ) {
415+ if ( index ) {
416+ element . insertBefore ( child , index ) ;
417+ } else {
418+ element . appendChild ( child ) ;
419+ index = child ;
420+ }
421+ } ) ;
422+ }
423+ } ,
424+
411425 remove : function ( element ) {
412426 JQLiteDealoc ( element ) ;
413427 var parent = element . parentNode ;
Original file line number Diff line number Diff line change @@ -380,6 +380,24 @@ describe('jqLite', function(){
380380 } ) ;
381381 } ) ;
382382
383+ describe ( 'prepend' , function ( ) {
384+ it ( 'should prepend to empty' , function ( ) {
385+ var root = jqLite ( '<div>' ) ;
386+ expect ( root . prepend ( '<span>abc</span>' ) ) . toEqual ( root ) ;
387+ expect ( root . html ( ) . toLowerCase ( ) ) . toEqual ( '<span>abc</span>' ) ;
388+ } ) ;
389+ it ( 'should prepend to content' , function ( ) {
390+ var root = jqLite ( '<div>text</div>' ) ;
391+ expect ( root . prepend ( '<span>abc</span>' ) ) . toEqual ( root ) ;
392+ expect ( root . html ( ) . toLowerCase ( ) ) . toEqual ( '<span>abc</span>text' ) ;
393+ } ) ;
394+ it ( 'should prepend text to content' , function ( ) {
395+ var root = jqLite ( '<div>text</div>' ) ;
396+ expect ( root . prepend ( 'abc' ) ) . toEqual ( root ) ;
397+ expect ( root . html ( ) . toLowerCase ( ) ) . toEqual ( 'abctext' ) ;
398+ } ) ;
399+ } ) ;
400+
383401
384402 describe ( 'remove' , function ( ) {
385403 it ( 'should remove' , function ( ) {
You can’t perform that action at this time.
0 commit comments