Revert data.js rewrite.

Reverts the following commits:

commit f717226b3a
Author: Rick Waldron <waldron.rick@gmail.com>
Date:   Mon Dec 31 18:06:38 2012 -0500

Only splice from internal arrays when item actually exists.

commit b9cdc4136b
Author: Rick Waldron <waldron.rick@gmail.com>
Date:   Mon Dec 31 16:20:35 2012 -0500

Updates to data.js re-write to pass events and manipulation

commit d1de3000c6
Author: Rick Waldron <waldron.rick@gmail.com>
Date:   Mon Dec 31 15:09:45 2012 -0500

2.0: Rewrite data.js
This commit is contained in:
Dave Methvin
2013-01-03 20:39:15 -05:00
parent 0d540c3750
commit 445dbd9d95
5 changed files with 326 additions and 341 deletions

View File

@@ -200,51 +200,47 @@ var Globals = (function() {
*/
QUnit.expectJqData = function( elems, key ) {
var i, elem, expando;
QUnit.current_testEnvironment.checkJqData = true;
if ( jQuery.cache ) {
QUnit.current_testEnvironment.checkJqData = true;
if ( elems.jquery && elems.toArray ) {
elems = elems.toArray();
}
if ( !jQuery.isArray( elems ) ) {
elems = [ elems ];
}
if ( elems.jquery && elems.toArray ) {
elems = elems.toArray();
}
if ( !jQuery.isArray( elems ) ) {
elems = [ elems ];
for ( i = 0; i < elems.length; i++ ) {
elem = elems[i];
// jQuery.data only stores data for nodes in jQuery.cache,
// for other data targets the data is stored in the object itself,
// in that case we can't test that target for memory leaks.
// But we don't have to since in that case the data will/must will
// be available as long as the object is not garbage collected by
// the js engine, and when it is, the data will be removed with it.
if ( !elem.nodeType ) {
// Fixes false positives for dataTests(window), dataTests({}).
continue;
}
for ( i = 0; i < elems.length; i++ ) {
elem = elems[i];
expando = elem[ jQuery.expando ];
// jQuery.data only stores data for nodes in jQuery.cache,
// for other data targets the data is stored in the object itself,
// in that case we can't test that target for memory leaks.
// But we don't have to since in that case the data will/must will
// be available as long as the object is not garbage collected by
// the js engine, and when it is, the data will be removed with it.
if ( !elem.nodeType ) {
// Fixes false positives for dataTests(window), dataTests({}).
continue;
}
expando = elem[ jQuery.expando ];
if ( expando === undefined ) {
// In this case the element exists fine, but
// jQuery.data (or internal data) was never (in)directly
// called.
// Since this method was called it means some data was
// expected to be found, but since there is nothing, fail early
// (instead of in teardown).
notStrictEqual( expando, undefined, "Target for expectJqData must have an expando, for else there can be no data to expect." );
if ( expando === undefined ) {
// In this case the element exists fine, but
// jQuery.data (or internal data) was never (in)directly
// called.
// Since this method was called it means some data was
// expected to be found, but since there is nothing, fail early
// (instead of in teardown).
notStrictEqual( expando, undefined, "Target for expectJqData must have an expando, for else there can be no data to expect." );
} else {
if ( expectedDataKeys[expando] ) {
expectedDataKeys[expando].push( key );
} else {
if ( expectedDataKeys[expando] ) {
expectedDataKeys[expando].push( key );
} else {
expectedDataKeys[expando] = [ key ];
}
expectedDataKeys[expando] = [ key ];
}
}
}
};
QUnit.config.urlConfig.push( {
id: "jqdata",
@@ -262,38 +258,33 @@ var Globals = (function() {
fragmentsLength = 0,
cacheLength = 0;
if ( jQuery.cache ) {
// Only look for jQuery data problems if this test actually
// provided some information to compare against.
if ( QUnit.urlParams.jqdata || this.checkJqData ) {
for ( i in jQuery.cache ) {
expectedKeys = expectedDataKeys[i];
actualKeys = jQuery.cache[i] ? keys( jQuery.cache[i] ) : jQuery.cache[i];
if ( !QUnit.equiv( expectedKeys, actualKeys ) ) {
deepEqual( actualKeys, expectedKeys, "Expected keys exist in jQuery.cache" );
}
delete jQuery.cache[i];
delete expectedDataKeys[i];
}
// In case it was removed from cache before (or never there in the first place)
for ( i in expectedDataKeys ) {
deepEqual( expectedDataKeys[i], undefined, "No unexpected keys were left in jQuery.cache (#" + i + ")" );
delete expectedDataKeys[i];
// Only look for jQuery data problems if this test actually
// provided some information to compare against.
if ( QUnit.urlParams.jqdata || this.checkJqData ) {
for ( i in jQuery.cache ) {
expectedKeys = expectedDataKeys[i];
actualKeys = jQuery.cache[i] ? keys( jQuery.cache[i] ) : jQuery.cache[i];
if ( !QUnit.equiv( expectedKeys, actualKeys ) ) {
deepEqual( actualKeys, expectedKeys, "Expected keys exist in jQuery.cache" );
}
delete jQuery.cache[i];
delete expectedDataKeys[i];
}
// In case it was removed from cache before (or never there in the first place)
for ( i in expectedDataKeys ) {
deepEqual( expectedDataKeys[i], undefined, "No unexpected keys were left in jQuery.cache (#" + i + ")" );
delete expectedDataKeys[i];
}
// Reset data register
expectedDataKeys = {};
}
// Reset data register
expectedDataKeys = {};
// Allow QUnit.reset to clean up any attached elements before checking for leaks
QUnit.reset();
if ( jQuery.cache ) {
for ( i in jQuery.cache ) {
++cacheLength;
}
for ( i in jQuery.cache ) {
++cacheLength;
}
jQuery.fragments = {};
@@ -343,7 +334,7 @@ var Globals = (function() {
} else {
delete jQuery.ajaxSettings;
}
// Cleanup globals
Globals.cleanup();