Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed an issue with script nodes being removed incorrectly, fixes #3737.

  • Loading branch information...
commit 29bf601f3495ced43fbb6152bf9306f2618bb955 1 parent afb0508
@jeresig jeresig authored
Showing with 5 additions and 2 deletions.
  1. +1 −1  src/core.js
  2. +4 −1 test/unit/core.js
View
2  src/core.js
@@ -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"))) );
View
5 test/unit/core.js
@@ -899,7 +899,7 @@ test("append(String|Element|Array<Element>|jQuery)", function() {
});
test("appendTo(String|Element|Array<Element>|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' );
@@ -916,6 +916,9 @@ test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {
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:" :
"This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
Please sign in to comment.
Something went wrong with that request. Please try again.