mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Data: remove the expando when there's no more data
Fixes gh-1760 Close gh-2271
This commit is contained in:
@@ -837,7 +837,24 @@ test("Check proper data removal of non-element descendants nodes (#8335)", 1, fu
|
||||
});
|
||||
|
||||
testIframeWithCallback( "enumerate data attrs on body (#14894)", "data/dataAttrs.html", function( result ) {
|
||||
expect(1);
|
||||
expect( 1 );
|
||||
|
||||
equal(result, "ok", "enumeration of data- attrs on body" );
|
||||
equal( result, "ok", "enumeration of data- attrs on body" );
|
||||
});
|
||||
|
||||
test( "Check that the expando is removed when there's no more data", function() {
|
||||
expect( 1 );
|
||||
|
||||
var key,
|
||||
div = jQuery( "<div/>" );
|
||||
div.data( "some", "data" );
|
||||
equal( div.data( "some" ), "data", "Data is added" );
|
||||
div.removeData( "some" );
|
||||
|
||||
// Make sure the expando is gone
|
||||
for ( key in div[ 0 ] ) {
|
||||
if ( /^jQuery/.test( key ) ) {
|
||||
ok( false, "Expando was not removed when there was no more data" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2657,6 +2657,27 @@ test( "Inline event result is returned (#13993)", function() {
|
||||
equal( result, 42, "inline handler returned value" );
|
||||
});
|
||||
|
||||
test( ".off() removes the expando when there's no more data", function() {
|
||||
expect( 1 );
|
||||
|
||||
var key,
|
||||
div = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );
|
||||
|
||||
div.on( "click", false );
|
||||
div.on( "custom", function() {
|
||||
ok( true, "Custom event triggered" );
|
||||
} );
|
||||
div.trigger( "custom" );
|
||||
div.off( "click custom" );
|
||||
|
||||
// Make sure the expando is gone
|
||||
for ( key in div[ 0 ] ) {
|
||||
if ( /^jQuery/.test( key ) ) {
|
||||
ok( false, "Expando was not removed when there was no more data" );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// This tests are unreliable in Firefox
|
||||
if ( !(/firefox/i.test( window.navigator.userAgent )) ) {
|
||||
test( "Check order of focusin/focusout events", 2, function() {
|
||||
|
||||
Reference in New Issue
Block a user