ronantakizawa/codereview-bench huggingface dataset:
Repository: jquery/jquery
File: test/middleware-mockserver.cjs (JavaScript)

Code before:
				resp.end( "<error>ERROR</error>" );
			}
		}, next );
	},
	atom: function( _req, resp ) {
		resp.writeHead( 200, { "content-type": "atom+xml" } );
		resp.end( "<root><element /></root>" );
	},
	script: function( req, resp ) {
		const headers = {};
		if ( req.query.header === "ecma" ) {
			headers[ "content-type" ] = "application/ecmascript";
		} else if ( "header" in req.query ) {
			headers[ "content-type" ] = "text/javascript";
		} else {
			headers[ "content-type" ] = "text/html";
		}

		if ( req.query.cors ) {
			headers[ "access-control-allow-origin" ] = "*";
		}

		if ( resp.set ) {
			resp.set( headers );
		} else {
			resp.writeHead( 200, headers );
		}

		if ( req.query.callback ) {
			resp.end( `${ cleanCallback( req.query.callback ) }(${ JSON.stringify( {
				headers: req.headers
			} ) })` );
		} else {
			resp.end( "QUnit.assert.ok( true, \"mock executed\" );" );
		}
	},
	testbar: function( _req, resp ) {
		resp.writeHead( 200 );
		resp.end(
			"this.testBar = 'bar'; " +
			"jQuery('#ap').html('bar'); " +
			"QUnit.assert.ok( true, 'mock executed');"
		);
	},
	json: function( req, resp ) {
		const headers = {};
		if ( req.query.header ) {
			headers[ "content-type" ] = "application/json";
		}
		if ( req.query.cors ) {
			headers[ "access-control-allow-origin" ] = "*";

Review comment (suggestion):
@timmywil What's the reason for the above `resp.set` check? Is it to cater to Express as well? If that's the case, why wasn't this needed in other functions using `writeHead`? I see this has been added in #5318.

Code after:
				resp.end( "<error>ERROR</error>" );
			}
		}, next );
	},
	atom: function( _req, resp ) {
		resp.writeHead( 200, { "content-type": "atom+xml" } );
		resp.end( "<root><element /></root>" );
	},
	script: function( req, resp ) {
		const headers = {};
		if ( req.query.header === "ecma" ) {
			headers[ "content-type" ] = "application/ecmascript";
		} else if ( "header" in req.query ) {
			headers[ "content-type" ] = "text/javascript";
		} else {
			headers[ "content-type" ] = "text/html";
		}

		if ( req.query.cors ) {
			headers[ "access-control-allow-origin" ] = "*";
		}

		resp.writeHead( 200, headers );

		if ( req.query.callback ) {
			resp.end( `${ cleanCallback( req.query.callback ) }(${ JSON.stringify( {
				headers: req.headers
			} ) })` );
		} else {
			resp.end( "QUnit.assert.ok( true, \"mock executed\" );" );
		}
	},
	testbar: function( _req, resp ) {
		resp.writeHead( 200 );
		resp.end(
			"this.testBar = 'bar'; " +
			"jQuery('#ap').html('bar'); " +
			"QUnit.assert.ok( true, 'mock executed');"
		);
	},
	json: function( req, resp ) {
		const headers = {};
		if ( req.query.header ) {
			headers[ "content-type" ] = "application/json";
		}
		if ( req.query.cors ) {
			headers[ "access-control-allow-origin" ] = "*";
		}
		resp.writeHead( 200, headers );
		if ( req.query.array ) {
			resp.end( JSON.stringify(
Repository: jquery/jquery
File: build/release/cdn.js (JavaScript)

Code before:
				text = fs
					.readFileSync( builtFile, "utf8" )
					.replace(
						/"file":"([^"]+)"/,
						"\"file\":\"" + unpathedFile.replace( /\.min\.map/, ".min.js\"" )
					)
					.replace(
						/"sources":\["([^"]+)"\]/,
						"\"sources\":[\"" + unpathedFile.replace( /\.min\.map/, ".js" ) + "\"]"
					);
				fs.writeFileSync( releaseFile, text );
			} else if ( builtFile !== releaseFile ) {
				shell.cp( "-f", builtFile, releaseFile );
			}
		} );
	} );
}

async function makeArchives( Release ) {
	Release.chdir( Release.dir.repo );

	async function makeArchive( { cdn, filesMap, cdnFolder } ) {
		return new Promise( ( resolve, reject ) => {
			if ( Release.preRelease ) {
				console.log(
					"Skipping archive creation for " + cdn + "; this is a beta release."
				);
				resolve();
				return;
			}

			console.log( "Creating production archive for " + cdn );

			let i, sum, result;
			const archiver = require( "archiver" )( "zip" );
			const md5file = cdnFolder + "/" + cdn + "-md5.txt";
			const output = fs.createWriteStream(
				cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip"
			);
			const rmd5 = /[a-f0-9]{32}/;
			const rver = /@VER/;

			output.on( "close", resolve );

			output.on( "error", ( err ) => {
				reject( err );
			} );

			archiver.pipe( output );

			let finalFilesMap = Object.create( null );

Review comment (suggestion):
Let's use template literals for such things:
```suggestion
					`Skipping archive creation for ${ cdn }; this is a beta release.`
```

Code after:
				text = fs
					.readFileSync( builtFile, "utf8" )
					.replace(
						/"file":"([^"]+)"/,
						`"file":"${ unpathedFile.replace( /\.min\.map/, ".min.js" ) }"`
					)
					.replace(
						/"sources":\["([^"]+)"\]/,
						`"sources":["${ unpathedFile.replace( /\.min\.map/, ".js" ) }"]`
					);
				fs.writeFileSync( releaseFile, text );
			} else if ( builtFile !== releaseFile ) {
				shell.cp( "-f", builtFile, releaseFile );
			}
		} );
	} );
}

async function makeArchives( Release ) {
	Release.chdir( Release.dir.repo );

	async function makeArchive( { cdn, filesMap, cdnFolder } ) {
		return new Promise( ( resolve, reject ) => {
			if ( Release.preRelease ) {
				console.log(
					`Skipping archive creation for ${ cdn }; this is a beta release.`
				);
				resolve();
				return;
			}

			console.log( "Creating production archive for " + cdn );

			let i, sum, result;
			const archiver = require( "archiver" )( "zip" );
			const md5file = cdnFolder + "/" + cdn + "-md5.txt";
			const output = fs.createWriteStream(
				cdnFolder + "/" + cdn + "-jquery-" + Release.newVersion + ".zip"
			);
			const rmd5 = /[a-f0-9]{32}/;
			const rver = /@VER/;

			output.on( "close", resolve );

			output.on( "error", ( err ) => {
				reject( err );
			} );

			archiver.pipe( output );

			let finalFilesMap = Object.create( null );
Repository: jquery/jquery
File: test/runner/listeners.js (JavaScript)

Code before:
					return;
				}

				objects.push( value );

				if ( Array.isArray( value ) ) {

					// If it is an array, replicate the array.
					return value.map( derez );
				} else {

					// If it is an object, replicate the object.
					var nu = Object.create( null );
					Object.keys( value ).forEach( function( name ) {
						nu[ name ] = derez( value[ name ] );
					} );
					return nu;
				}
			}

			// Serialize Symbols as string representations so they are
			// sent over the wire after being stringified.
			if ( typeof value === "symbol" ) {
				var ctor = Symbol.keyFor( value ) !== undefined ? "Symbol.for" : "Symbol";
				return ctor + "(" + JSON.stringify( value.description ) + ")";
			}

			return value;
		}
		return derez( object );
	}

	function send( type, data ) {
		var json = JSON.stringify( {
			id: id,
			type: type,
			data: data ? decycle( data ) : undefined
		} );
		var request = new XMLHttpRequest();
		request.open( "POST", "/api/report", true );
		request.setRequestHeader( "Content-Type", "application/json" );
		request.send( json );
		return request;
	}

	// Send acknowledgement to the server.
	send( "ack" );

	QUnit.on( "testEnd", function( data ) {
		send( "testEnd", data );
	} );

Review comment (bug):
Note that `JSON.stringify` also fails to round-trip bigints, NaN, ±Infinity, and undefined. If we start caring about those cases, we should switch to a higher-order encoding similar to [Endo "Smallcaps"](https://github.com/endojs/endo/blob/1813f35432e266a4998c090f32b184b166d5d47f/packages/marshal/src/encodeToSmallcaps.js#L47-L67) (_in which e.g. the array `[0, 42n, NaN, -Infinity, undefined, "#"]` would be encoded as `[0, "+42", "#NaN", "#-Infinity", "#undefined", "!#"]`_).

Code after:
					return;
				}

				objects.push( value );

				if ( Array.isArray( value ) ) {

					// If it is an array, replicate the array.
					return value.map( derez );
				} else {

					// If it is an object, replicate the object.
					var nu = Object.create( null );
					Object.keys( value ).forEach( function( name ) {
						nu[ name ] = derez( value[ name ] );
					} );
					return nu;
				}
			}

			// Serialize Symbols as string representations so they are
			// sent over the wire after being stringified.
			if ( typeof value === "symbol" ) {

				// We can *describe* unique symbols, but note that their identity
				// (e.g., `Symbol() !== Symbol()`) is lost
				var ctor = Symbol.keyFor( value ) !== undefined ? "Symbol.for" : "Symbol";
				return ctor + "(" + JSON.stringify( value.description ) + ")";
			}

			return value;
		}
		return derez( object );
	}

	function send( type, data ) {
		var json = JSON.stringify( {
			id: id,
			type: type,
			data: data ? decycle( data ) : undefined
		} );
		var request = new XMLHttpRequest();
		request.open( "POST", "/api/report", true );
		request.setRequestHeader( "Content-Type", "application/json" );
		request.send( json );
		return request;
	}

	// Send acknowledgement to the server.
	send( "ack" );
Repository: jquery/jquery
File: test/runner/listeners.js (JavaScript)

Code before:
				}

				objects.push( value );

				if ( Array.isArray( value ) ) {

					// If it is an array, replicate the array.
					return value.map( derez );
				} else {

					// If it is an object, replicate the object.
					var nu = Object.create( null );
					Object.keys( value ).forEach( function( name ) {
						nu[ name ] = derez( value[ name ] );
					} );
					return nu;
				}
			}

			// Serialize Symbols as string representations so they are
			// sent over the wire after being stringified.
			if ( typeof value === "symbol" ) {
				var ctor = Symbol.keyFor( value ) !== undefined ? "Symbol.for" : "Symbol";
				return ctor + "(" + JSON.stringify( value.description ) + ")";
			}

			return value;
		}
		return derez( object );
	}

	function send( type, data ) {
		var json = JSON.stringify( {
			id: id,
			type: type,
			data: data ? decycle( data ) : undefined
		} );
		var request = new XMLHttpRequest();
		request.open( "POST", "/api/report", true );
		request.setRequestHeader( "Content-Type", "application/json" );
		request.send( json );
		return request;
	}

	// Send acknowledgement to the server.
	send( "ack" );

	QUnit.on( "testEnd", function( data ) {
		send( "testEnd", data );
	} );


Review comment (suggestion):
```suggestion
				// We can *describe* unique symbols, but note that their identity
				// (e.g., `Symbol() !== Symbol()`) is lost
				var ctor = Symbol.keyFor( value ) !== undefined ? "Symbol.for" : "Symbol";
```

Code after:
				}

				objects.push( value );

				if ( Array.isArray( value ) ) {

					// If it is an array, replicate the array.
					return value.map( derez );
				} else {

					// If it is an object, replicate the object.
					var nu = Object.create( null );
					Object.keys( value ).forEach( function( name ) {
						nu[ name ] = derez( value[ name ] );
					} );
					return nu;
				}
			}

			// Serialize Symbols as string representations so they are
			// sent over the wire after being stringified.
			if ( typeof value === "symbol" ) {

				// We can *describe* unique symbols, but note that their identity
				// (e.g., `Symbol() !== Symbol()`) is lost
				var ctor = Symbol.keyFor( value ) !== undefined ? "Symbol.for" : "Symbol";
				return ctor + "(" + JSON.stringify( value.description ) + ")";
			}

			return value;
		}
		return derez( object );
	}

	function send( type, data ) {
		var json = JSON.stringify( {
			id: id,
			type: type,
			data: data ? decycle( data ) : undefined
		} );
		var request = new XMLHttpRequest();
		request.open( "POST", "/api/report", true );
		request.setRequestHeader( "Content-Type", "application/json" );
		request.send( json );
		return request;
	}

	// Send acknowledgement to the server.
	send( "ack" );

	QUnit.on( "testEnd", function( data ) {
Repository: jquery/jquery
File: build/release/post-release.sh (Shell)

Code before:
	exit 1
fi

if [[ -z "$2" ]] then
	echo "Blog URL is not set (2nd argument)"
	exit 1
fi

# Push files to cdn repo
npm run release:cdn $1
cd $cdn
git add -A
git commit -m "jquery: Add version $1"

# Wait for confirmation from user to push changes to cdn repo
read -p "Press enter to push changes to cdn repo"
git push
cd -

# Push files to dist repo
npm run release:dist $1 $2
cd $dist
git add -A
npm version $1

# Wait for confirmation from user to push changes to dist repo
read -p "Press enter to push changes to dist repo"
git push --follow-tags
cd -

# Restore AUTHORS URL
sed -i "s/$1\/AUTHORS.txt/main\/AUTHORS.txt/" package.json
git add package.json

# Remove built files from tracking.
# Leave the changelog.md committed.
# Leave the tmp folder as some files are needed
# after the release (such as for emailing archives).
npm run build:clean
git commit -m "Release: remove dist files from main branch"

# Wait for confirmation from user to push changes
read -p "Press enter to push changes to main branch"
git push


Review comment (bug):
`npm version` wasn't quite right. Aside from the need to commit first anyway, the correct version is already set at this point in the package.json. But more importantly, there's no `.npmrc` in the jquery-dist repo, so the tag name would be wrong. We could add one, but again, all that's needed is a tag.

Also, annotating the tag is recommended in the `git tag` documentation for releases.

> Annotated tags are meant for release while lightweight tags are meant for private or temporary object labels.

release-it does already annotate the tag for the jquery repo.

Code after:
	exit 1
fi

if [[ -z "$2" ]] then
	echo "Blog URL is not set (2nd argument)"
	exit 1
fi

# Push files to cdn repo
npm run release:cdn $1
cd $cdn
git add -A
git commit -m "jquery: Add version $1"

# Wait for confirmation from user to push changes to cdn repo
read -p "Press enter to push changes to cdn repo"
git push
cd -

# Push files to dist repo
npm run release:dist $1 $2
cd $dist
git add -A
git commit -m "Release: $1"
# -s to sign and annotate tag (recommended for releases)
git tag -s $1 -m "Release: $1"

# Wait for confirmation from user to push changes to dist repo
read -p "Press enter to push changes to dist repo"
git push --follow-tags
cd -

# Restore AUTHORS URL
sed -i "s/$1\/AUTHORS.txt/main\/AUTHORS.txt/" package.json
git add package.json

# Remove built files from tracking.
# Leave the changelog.md committed.
# Leave the tmp folder as some files are needed
# after the release (such as for emailing archives).
npm run build:clean
git commit -m "Release: remove dist files from main branch"

# Wait for confirmation from user to push changes
read -p "Press enter to push changes to main branch"
git push
Repository: jquery/jquery
File: test/unit/manipulation.js (JavaScript)

Code before:
function getAll( context, tag ) {

	// Support: IE <=9 - 11+
	// Use typeof to avoid zero-argument method invocation on host objects (trac-15151)
	var ret;

	if ( typeof context.querySelectorAll !== "undefined" ) {
		ret = context.querySelectorAll( tag || "*" );

	} else {
		ret = [];
	}

	if ( tag === undefined || tag && nodeName( context, tag ) ) {
		return jQuery.merge( [ context ], ret );
	}

	return ret;
}

QUnit.test( "should retrieve all elements with a specific tag", function( assert ) {
    assert.expect( 1 );
    var context = document.createElement( "div" );
    context.innerHTML = "<span></span><span></span>";

    var result = getAll( context, "span" );
    assert.equal( result.length, 2, "Found two span elements" );
} );

QUnit.test( "should retrieve all elements if no tag is specified", function( assert ) {
    assert.expect( 1 );
    var context = document.createElement( "div" );
    context.innerHTML = "<span></span><span></span>";

    var result = getAll( context );
    assert.equal( result.length, 3, "Found three elements including the context itself" );
} );

QUnit.test( "should retrieve elements including the context if it matches the tag", function( assert ) {
    assert.expect( 1 );
    var context = document.createElement( "div" );
    context.innerHTML = "<div></div><span></span>";

    var result = getAll( context, "div" );
    assert.equal( result.length, 2, "Found two div elements including the context itself" );
} );

QUnit.test( "should return an empty array if no matching elements are found", function( assert ) {
    assert.expect( 1 );
    var context = document.createElement( "div" );
    context.innerHTML = "<span></span><span></span>";

Review comment (suggestion):
This test is calling a locally defined `getAll`; this is not actually testing your changes.

What we need instead is a test confirming the issue that led to this PR is fixed - i.e. #5214.

Code after:
		"		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();
			}
		}
	};

	// Attach an empty handler to trigger the `remove`
	// logic for the custom event when the element is removed.
	jQuery( ".guarded" ).on( "removeondestroy", function( ) { } );

	// Trigger the event's removal logic by emptying the container
	jQuery( "#container" ).empty();

	assert.verifySteps( [ "one", "two", "three" ], "All elements were processed in order" );
} );
Repository: jquery/jquery
File: test/unit/manipulation.js (JavaScript)

Code before:
QUnit.test( "should handle custom '_se-custom-destroy' event correctly", function( assert ) {

	// Set up the HTML structure using innerHTML within #qunit-fixture

	assert.expect( 2 );

	var fixture = jQuery( "#qunit-fixture" );

	fixture.html( `
    <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>
  ` );

	// JavaScript code to be tested

  jQuery.event.special[ "_se-custom-destroy" ] = {
    remove: function( _handleObj ) {
		var $t = jQuery( this );
		console.log( $t.data( "elt" ) );
		if ( $t.is( ".removeself" ) ) {
			$t.remove();
			}
		}
	};

	// Attach the custom event handler

	jQuery( ".guarded" ).on( "_se-custom-destroy", function( ) { } );

	// Spy on console.log

	var consoleLog = console.log;

	var logMessages = [];

	console.log = function( message ) {
	logMessages.push( message );
	};

	// Trigger the event by emptying the container

	jQuery( "#container" ).empty( );

Review comment (suggestion):
Here & in many other places there are still indentation issues - code in a block not indented, spaces used instead of tabs, etc. Please configure your editor to have visible whitespace, it will make it easier for you to properly follow the style guide.

Code after:
	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();
			}
		}
	};

	// Attach an empty handler to trigger the `remove`
	// logic for the custom event when the element is removed.
	jQuery( ".guarded" ).on( "removeondestroy", function( ) { } );

	// Trigger the event's removal logic by emptying the container
	jQuery( "#container" ).empty();

	assert.verifySteps( [ "one", "two", "three" ], "All elements were processed in order" );
} );
Repository: jquery/jquery
File: test/unit/manipulation.js (JavaScript)

Code before:
	// Set up the HTML structure using innerHTML within #qunit-fixture

	assert.expect( 2 );

	var fixture = jQuery( "#qunit-fixture" );

	fixture.html( `
    <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>
  ` );

	// JavaScript code to be tested

  jQuery.event.special[ "_se-custom-destroy" ] = {
    remove: function( _handleObj ) {
		var $t = jQuery( this );
		console.log( $t.data( "elt" ) );
		if ( $t.is( ".removeself" ) ) {
			$t.remove();
			}
		}
	};

	// Attach the custom event handler

	jQuery( ".guarded" ).on( "_se-custom-destroy", function( ) { } );

	// Spy on console.log

	var consoleLog = console.log;

	var logMessages = [];

	console.log = function( message ) {
	logMessages.push( message );
	};

	// Trigger the event by emptying the container

	jQuery( "#container" ).empty( );

	// Verify that the elements with class 'removeself' were removed

Review comment (suggestion):
Instead of patching `console.log`, use `assert.step` with `assert.verifySteps`:
https://qunitjs.com/api/assert/step/

Code after:
	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();
			}
		}
	};

	// Attach an empty handler to trigger the `remove`
	// logic for the custom event when the element is removed.
	jQuery( ".guarded" ).on( "removeondestroy", function( ) { } );

	// Trigger the event's removal logic by emptying the container
	jQuery( "#container" ).empty();

	assert.verifySteps( [ "one", "two", "three" ], "All elements were processed in order" );
} );
Repository: jquery/jquery
File: test/unit/manipulation.js (JavaScript)

Code before:
    <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>
  ` );

	// JavaScript code to be tested

  jQuery.event.special[ "_se-custom-destroy" ] = {
    remove: function( _handleObj ) {
		var $t = jQuery( this );
		console.log( $t.data( "elt" ) );
		if ( $t.is( ".removeself" ) ) {
			$t.remove();
			}
		}
	};

	// Attach the custom event handler

	jQuery( ".guarded" ).on( "_se-custom-destroy", function( ) { } );

	// Spy on console.log

	var consoleLog = console.log;

	var logMessages = [];

	console.log = function( message ) {
	logMessages.push( message );
	};

	// Trigger the event by emptying the container

	jQuery( "#container" ).empty( );

	// Verify that the elements with class 'removeself' were removed

	assert.equal( jQuery( ".removeself" ).length, 0, "Elements with class 'removeself' should be removed" );

	// Verify console logs

	assert.deepEqual( logMessages, [ "one", "two", "three" ], "Console logs should match the data-elt attributes" );


Review comment (suggestion):
```suggestion
	// Attach an empty handler to trigger the `remove`
	// logic for the custom event when the element is removed.
```

Code after:
		"	</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();
			}
		}
	};

	// Attach an empty handler to trigger the `remove`
	// logic for the custom event when the element is removed.
	jQuery( ".guarded" ).on( "removeondestroy", function( ) { } );

	// Trigger the event's removal logic by emptying the container
	jQuery( "#container" ).empty();

	assert.verifySteps( [ "one", "two", "three" ], "All elements were processed in order" );
} );