@@ -739,7 +739,7 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
739
739
} ) ;
740
740
741
741
var testReplaceWith = function ( val ) {
742
- expect ( 20 ) ;
742
+ expect ( 21 ) ;
743
743
jQuery ( '#yahoo' ) . replaceWith ( val ( '<b id="replace">buga</b>' ) ) ;
744
744
ok ( jQuery ( "#replace" ) [ 0 ] , 'Replace element with string' ) ;
745
745
ok ( ! jQuery ( "#yahoo" ) [ 0 ] , 'Verify that original element is gone, after string' ) ;
@@ -799,6 +799,9 @@ var testReplaceWith = function(val) {
799
799
var set = jQuery ( "<div/>" ) . replaceWith ( val ( "<span>test</span>" ) ) ;
800
800
equals ( set [ 0 ] . nodeName . toLowerCase ( ) , "span" , "Replace the disconnected node." ) ;
801
801
equals ( set . length , 1 , "Replace the disconnected node." ) ;
802
+
803
+ var non_existant = jQuery ( '#does-not-exist' ) . replaceWith ( val ( "<b>should not throw an error</b>" ) ) ;
804
+ equals ( non_existant . length , 0 , "Length of non existant element." )
802
805
803
806
var $div = jQuery ( "<div class='replacewith'></div>" ) . appendTo ( "body" ) ;
804
807
// TODO: Work on jQuery(...) inline script execution
@@ -827,7 +830,7 @@ test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
827
830
test ( "replaceWith(Function)" , function ( ) {
828
831
testReplaceWith ( functionReturningObj ) ;
829
832
830
- expect ( 21 ) ;
833
+ expect ( 22 ) ;
831
834
832
835
var y = jQuery ( "#yahoo" ) [ 0 ] ;
833
836
0 commit comments