define( [
"../core",
- "../core/nodeName"
-], function( jQuery, nodeName ) {
+ "../core/nodeName",
+ "../var/arr"
+], function( jQuery, nodeName, arr ) {
"use strict";
var ret;
if ( typeof context.getElementsByTagName !== "undefined" ) {
- ret = context.getElementsByTagName( tag || "*" );
+
+ // Use slice to snapshot the live collection from gEBTN
+ ret = arr.slice.call( context.getElementsByTagName( tag || "*" ) );
} else if ( typeof context.querySelectorAll !== "undefined" ) {
ret = context.querySelectorAll( tag || "*" );
test( "<noembed><noembed/><img src=url404 onerror=xss(12)>" );
}
} );
+
+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();
+ }
+ }
+ };
+
+ // 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" );
+} );
+