]> source.dussan.org Git - jquery.git/commitdiff
Fixed an issue with script nodes being removed incorrectly, fixes #3737.
authorJohn Resig <jeresig@gmail.com>
Sat, 10 Jan 2009 01:07:59 +0000 (01:07 +0000)
committerJohn Resig <jeresig@gmail.com>
Sat, 10 Jan 2009 01:07:59 +0000 (01:07 +0000)
src/core.js
test/unit/core.js

index fe5dbc6bf053b91764b2c5fbcf8a042a590dfb9d..4047170ebe9201748e440040570dbdcdb9a064f0 100644 (file)
@@ -922,7 +922,7 @@ jQuery.extend({
                if ( fragment ) {
                        for ( var i = 0; ret[i]; i++ ) {
                                if ( jQuery.nodeName( ret[i], "script" ) ) {
-                                       scripts.push( ret[i].parentNode.removeChild( ret[i] ) );
+                                       scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
                                } else {
                                        if ( ret[i].nodeType === 1 )
                                                ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
index ef36c4f784798aebe65ac85fb863c1626678e023..1ec3487d0a94a2af623fcbff862fbc864d47c3e5 100644 (file)
@@ -899,7 +899,7 @@ test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {
 });
 
 test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
-       expect(6);
+       expect(7);
        var defaultText = 'Try them out:'
        jQuery('<b>buga</b>').appendTo('#first');
        equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' );
@@ -915,6 +915,9 @@ test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
        jQuery([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
        equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" );
 
+       reset();
+       ok( jQuery(document.createElement("script")).appendTo("body").length, "Make sure a disconnected script can be appended." );
+
        reset();
        expected = document.querySelectorAll ?
                "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:" :