Repository: jquery/jquery
File: test/unit/manipulation.js (JavaScript)

Code before:

	// This test case attempts to close the tags which wrap input
	// based on matching done in wrapMap which should be ignored.
	var elem = jQuery( "<td></td></tr></tbody></table><td></td>" );
	assert.strictEqual( elem.length, 2, "Two elements created" );
	assert.strictEqual( elem[ 0 ].nodeName.toLowerCase(), "td", "First element is td" );
	assert.strictEqual( elem[ 1 ].nodeName.toLowerCase(), "td", "Second element is td" );
} );

// Test trustedTypes support in browsers where they're supported (currently Chrome 83+).
// Browsers with no TrustedHTML support still run tests on object wrappers with
// a proper `toString` function.
testIframe(
	"Basic TrustedHTML support (gh-4409)",
	"mock.php?action=trustedHtml",
	function( assert, jQuery, window, document, test ) {

		assert.expect( 5 );

		test.forEach( function( result ) {
			assert.deepEqual( result.actual, result.expected, result.message );
		} );
	}
);

QUnit.test( "should handle custom 'removeondestroy' event correctly", function( assert ) {

	assert.expect( 4 );

	jQuery(
		"<div id='container'>" +
			"<div class='guarded removeself' data-elt='one'>" +
				"Guarded 1" +
			"</div>" +
			"<div class='guarded' data-elt='two'>" +
				"Guarded 2" +
			"</div>" +
			"<div class='guarded' data-elt='three'>" +
				"Guarded 3" +
			"</div>" +
		"</div>"
	).appendTo( "#qunit-fixture" );

	// Define the custom event handler
	jQuery.event.special.removeondestroy = {
	remove: function( ) {
		var $t = jQuery( this );
		assert.step( $t.data( "elt" ) );
		if ( $t.is( ".removeself" ) ) {
			$t.remove();
		}

Review comment (suggestion):
This event is just an example, let's describe the issue here, with a reference to the issue number as well. How about:
```suggestion
QUnit.test( "should handle node removal in event's remove hook (gh-5214)", function( assert ) {
```

Code after:

	// This test case attempts to close the tags which wrap input
	// based on matching done in wrapMap which should be ignored.
	var elem = jQuery( "<td></td></tr></tbody></table><td></td>" );
	assert.strictEqual( elem.length, 2, "Two elements created" );
	assert.strictEqual( elem[ 0 ].nodeName.toLowerCase(), "td", "First element is td" );
	assert.strictEqual( elem[ 1 ].nodeName.toLowerCase(), "td", "Second element is td" );
} );

// Test trustedTypes support in browsers where they're supported (currently Chrome 83+).
// Browsers with no TrustedHTML support still run tests on object wrappers with
// a proper `toString` function.
testIframe(
	"Basic TrustedHTML support (gh-4409)",
	"mock.php?action=trustedHtml",
	function( assert, jQuery, window, document, test ) {

		assert.expect( 5 );

		test.forEach( function( result ) {
			assert.deepEqual( result.actual, result.expected, result.message );
		} );
	}
);

QUnit.test( "should handle node removal in event's remove hook (gh-5214)", function( assert ) {

	assert.expect( 4 );

	jQuery(
		"<div id='container'>" +
		"	<div class='guarded removeself' data-elt='one'>" +
		"		Guarded 1" +
		"	</div>" +
		"	<div class='guarded' data-elt='two'>" +
		"		Guarded 2" +
		"	</div>" +
		"	<div class='guarded' data-elt='three'>" +
		"		Guarded 3" +
		"	</div>" +
		"</div>"
	).appendTo( "#qunit-fixture" );

	// Define the custom event handler
	jQuery.event.special.removeondestroy = {
		remove: function( ) {
			var $t = jQuery( this );
			assert.step( $t.data( "elt" ) );
			if ( $t.is( ".removeself" ) ) {
				$t.remove();
			}