@@ -739,7 +739,7 @@ test("insertAfter(String|Element|Array<Element>|jQuery)", function() {
739739} ) ;
740740
741741var testReplaceWith = function ( val ) {
742- expect ( 20 ) ;
742+ expect ( 21 ) ;
743743 jQuery ( '#yahoo' ) . replaceWith ( val ( '<b id="replace">buga</b>' ) ) ;
744744 ok ( jQuery ( "#replace" ) [ 0 ] , 'Replace element with string' ) ;
745745 ok ( ! jQuery ( "#yahoo" ) [ 0 ] , 'Verify that original element is gone, after string' ) ;
@@ -800,6 +800,9 @@ var testReplaceWith = function(val) {
800800 equals ( set [ 0 ] . nodeName . toLowerCase ( ) , "span" , "Replace the disconnected node." ) ;
801801 equals ( set . length , 1 , "Replace the disconnected node." ) ;
802802
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." ) ;
805+
803806 var $div = jQuery ( "<div class='replacewith'></div>" ) . appendTo ( "body" ) ;
804807 // TODO: Work on jQuery(...) inline script execution
805808 //$div.replaceWith("<div class='replacewith'></div><script>" +
@@ -827,7 +830,7 @@ test("replaceWith(String|Element|Array<Element>|jQuery)", function() {
827830test ( "replaceWith(Function)" , function ( ) {
828831 testReplaceWith ( functionReturningObj ) ;
829832
830- expect ( 21 ) ;
833+ expect ( 22 ) ;
831834
832835 var y = jQuery ( "#yahoo" ) [ 0 ] ;
833836
0 commit comments