Skip to content

Commit

Permalink
Fixed an issue with script nodes being removed incorrectly, fixes #3737.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeresig committed Jan 10, 2009
1 parent afb0508 commit 29bf601
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core.js
Expand Up @@ -922,7 +922,7 @@ jQuery.extend({
if ( fragment ) { if ( fragment ) {
for ( var i = 0; ret[i]; i++ ) { for ( var i = 0; ret[i]; i++ ) {
if ( jQuery.nodeName( ret[i], "script" ) ) { 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 { } else {
if ( ret[i].nodeType === 1 ) if ( ret[i].nodeType === 1 )
ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
Expand Down
5 changes: 4 additions & 1 deletion test/unit/core.js
Expand Up @@ -899,7 +899,7 @@ test("append(String|Element|Array<Element>|jQuery)", function() {
}); });


test("appendTo(String|Element|Array<Element>|jQuery)", function() { test("appendTo(String|Element|Array<Element>|jQuery)", function() {
expect(6); expect(7);
var defaultText = 'Try them out:' var defaultText = 'Try them out:'
jQuery('<b>buga</b>').appendTo('#first'); jQuery('<b>buga</b>').appendTo('#first');
equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' ); equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' );
Expand All @@ -915,6 +915,9 @@ test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
jQuery([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap'); jQuery([document.getElementById('first'), document.getElementById('yahoo')]).appendTo('#sap');
equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" ); 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(); reset();
expected = document.querySelectorAll ? expected = document.querySelectorAll ?
"This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:" : "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:" :
Expand Down

0 comments on commit 29bf601

Please sign in to comment.