Skip to content

Commit 5a7674d

Browse files
jbedardmgol
authored andcommitted
Data: test that delete is not used on DOM nodes
(test cherry-picked from 0e98243) Closes gh-2479
1 parent 29266e0 commit 5a7674d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/unit/event.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2725,6 +2725,30 @@ QUnit.test( "Inline event result is returned (#13993)", function( assert ) {
27252725
assert.equal( result, 42, "inline handler returned value" );
27262726
} );
27272727

2728+
QUnit.test( ".off() removes the expando when there's no more data", function( assert ) {
2729+
assert.expect( 2 );
2730+
2731+
var key,
2732+
div = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
2733+
2734+
div.on( "click", false );
2735+
div.on( "custom", function() {
2736+
assert.ok( true, "Custom event triggered" );
2737+
} );
2738+
div.trigger( "custom" );
2739+
div.off( "click custom" );
2740+
2741+
// Make sure the expando is gone
2742+
for ( key in div[ 0 ] ) {
2743+
if ( /^jQuery/.test( key ) ) {
2744+
assert.strictEqual(
2745+
div[ 0 ][ key ], undefined,
2746+
"Expando was not removed when there was no more data"
2747+
);
2748+
}
2749+
}
2750+
} );
2751+
27282752
QUnit.test( "preventDefault() on focusin does not throw exception", function( assert ) {
27292753
assert.expect( 1 );
27302754

0 commit comments

Comments
 (0)