mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Manipulation: Support $el.html(selfRemovingScript)
Don't try to remove a script element that has already removed itself.
Fixes gh-5377
Closes gh-5378
(cherry-picked from commit 937923d9ee
)
This commit is contained in:
parent
b922eed934
commit
cbc15c9c31
@ -36,7 +36,9 @@ define( [
|
||||
}
|
||||
}
|
||||
}
|
||||
doc.head.appendChild( script ).parentNode.removeChild( script );
|
||||
if ( doc.head.appendChild( script ).parentNode ) {
|
||||
script.parentNode.removeChild( script );
|
||||
}
|
||||
}
|
||||
|
||||
return DOMEval;
|
||||
|
@ -1871,6 +1871,21 @@ QUnit[
|
||||
}, 1000 );
|
||||
} );
|
||||
|
||||
QUnit.test( "html(self-removing script) (gh-5377)", function( assert ) {
|
||||
assert.expect( 2 );
|
||||
|
||||
var $fixture = jQuery( "#qunit-fixture" );
|
||||
|
||||
$fixture.html(
|
||||
[
|
||||
"<script>document.currentScript.parentNode.removeChild( document.currentScript ); QUnit.assert.ok( true, 'removed document.currentScript' );</script>",
|
||||
"<div>",
|
||||
"<script>document.currentScript.parentNode.removeChild( document.currentScript ); QUnit.assert.ok( true, 'removed inner document.currentScript' );</script>",
|
||||
"</div>"
|
||||
].join( "" )
|
||||
);
|
||||
} );
|
||||
|
||||
QUnit.test( "html(Function) with incoming value -- direct selection", function( assert ) {
|
||||
|
||||
assert.expect( 4 );
|
||||
|
Loading…
Reference in New Issue
Block a user