<commit_before>module("data", { teardown: moduleTeardown });

test("expando", function(){
	expect(1);

	equal(jQuery.expando !== undefined, true, "jQuery is exposing the expando");
});

test( "jQuery.data & removeData, expected returns", function() {
	expect(4);
	var elem = document.body;

	equal(
		jQuery.data( elem, "hello", "world" ), "world",
		"jQuery.data( elem, key, value ) returns value"
	);
	equal(
		jQuery.data( elem, "hello" ), "world",
		"jQuery.data( elem, key ) returns value"
	);
	deepEqual(
		jQuery.data( elem, { goodnight: "moon" }), { goodnight: "moon" },
		"jQuery.data( elem, obj ) returns obj"
	);
	equal(
		jQuery.removeData( elem, "hello" ), undefined,
		"jQuery.removeData( elem, key, value ) returns undefined"
	);

});

test( "jQuery._data & _removeData, expected returns", function() {
	expect(4);
	var elem = document.body;

	equal(
		jQuery._data( elem, "hello", "world" ), "world",
		"jQuery._data( elem, key, value ) returns value"
	);
	equal(
		jQuery._data( elem, "hello" ), "world",
		"jQuery._data( elem, key ) returns value"
	);
	deepEqual(
		jQuery._data( elem, { goodnight: "moon" }), { goodnight: "moon" },
		"jQuery._data( elem, obj ) returns obj"
	);
	equal(
		jQuery._removeData( elem, "hello" ), undefined,
		"jQuery._removeData( elem, key, value ) returns undefined"
	);
});

test( "jQuery.hasData no side effects", function() {
	expect(1);
	var obj = {};

	jQuery.hasData( obj );

	equal( Object.getOwnPropertyNames( obj ).length, 0,
		"No data expandos where added when calling jQuery.hasData(o)"
	);
});

function dataTests (elem) {
	var oldCacheLength, dataObj, internalDataObj, expected, actual;

	equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" );
	strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" );

	dataObj = jQuery.data(elem);
	equal( typeof dataObj, "object", "Calling data with no args gives us a data object reference" );
	strictEqual( jQuery.data(elem), dataObj, "Calling jQuery.data returns the same data object when called multiple times" );

	strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" );

	dataObj["foo"] = "bar";
	equal( jQuery.data(elem, "foo"), "bar", "Data is readable by jQuery.data when set directly on a returned data object" );

	strictEqual( jQuery.hasData(elem), true, "jQuery.hasData agrees data exists when data exists" );

	jQuery.data(elem, "foo", "baz");
	equal( jQuery.data(elem, "foo"), "baz", "Data can be changed by jQuery.data" );
	equal( dataObj["foo"], "baz", "Changes made through jQuery.data propagate to referenced data object" );

	jQuery.data(elem, "foo", undefined);
	equal( jQuery.data(elem, "foo"), "baz", "Data is not unset by passing undefined to jQuery.data" );

	jQuery.data(elem, "foo", null);
	strictEqual( jQuery.data(elem, "foo"), null, "Setting null using jQuery.data works OK" );

	jQuery.data(elem, "foo", "foo1");

	jQuery.data(elem, { "bar" : "baz", "boom" : "bloz" });
	strictEqual( jQuery.data(elem, "foo"), "foo1", "Passing an object extends the data object instead of replacing it" );
	equal( jQuery.data(elem, "boom"), "bloz", "Extending the data object works" );

	jQuery._data(elem, "foo", "foo2", true);
	equal( jQuery._data(elem, "foo"), "foo2", "Setting internal data works" );
	equal( jQuery.data(elem, "foo"), "foo1", "Setting internal data does not override user data" );

	internalDataObj = jQuery._data( elem );
	ok( internalDataObj, "Internal data object exists" );
	notStrictEqual( dataObj, internalDataObj, "Internal data object is not the same as user data object" );

	strictEqual( elem.boom, undefined, "Data is never stored directly on the object" );

	jQuery.removeData(elem, "foo");
	strictEqual( jQuery.data(elem, "foo"), undefined, "jQuery.removeData removes single properties" );

	jQuery.removeData(elem);
	strictEqual( jQuery._data(elem), internalDataObj, "jQuery.removeData does not remove internal data if it exists" );

	jQuery.data(elem, "foo", "foo1");
	jQuery._data(elem, "foo", "foo2");

	equal( jQuery.data(elem, "foo"), "foo1", "(sanity check) Ensure data is set in user data object" );
	equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );

	strictEqual( jQuery._data(elem, jQuery.expando), undefined, "Removing the last item in internal data destroys the internal data object" );

	jQuery._data(elem, "foo", "foo2");
	equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );

	jQuery.removeData(elem, "foo");
	equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" );
}

test("jQuery.data(div)", 25, function() {
	var div = document.createElement("div");

	dataTests(div);

	// We stored one key in the private data
	// assert that nothing else was put in there, and that that
	// one stayed there.
	QUnit.expectJqData(div, "foo");
});

test("jQuery.data({})", 25, function() {
	dataTests({});
});

test("jQuery.data(window)", 25, function() {
	// remove bound handlers from window object to stop potential false positives caused by fix for #5280 in
	// transports/xhr.js
	jQuery(window).off("unload");

	dataTests(window);
});

test("jQuery.data(document)", 25, function() {
	dataTests(document);

	QUnit.expectJqData(document, "foo");
});

test("jQuery.data(<embed>)", 25, function() {
	dataTests( document.createElement("embed") );
});

test("jQuery.data(<applet>)", 25, function() {
	dataTests( document.createElement("applet") );
});

test("jQuery.data(object/flash)", 25, function() {
	var flash = document.createElement("object");
	flash.setAttribute( "classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" );

	dataTests( flash );
});

test("jQuery.data(object/applet)", 25, function() {
	var applet = document.createElement("object");
	applet.setAttribute( "classid", "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" );

	dataTests( applet );
});

test("jQuery.data(comment)", 25, function() {
	dataTests( document.createComment("") );
});

test("jQuery.data(text)", 25, function() {
	dataTests( document.createTextNode("") );
});

test(".data()", function() {
	expect(5);

	var div = jQuery("#foo");
	strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" );
	div.data("test", "success");<commit_msg>Removes unnecessary "object/applet" element test from data tests.<commit_after>module("data", { teardown: moduleTeardown });

test("expando", function(){
	expect(1);

	equal(jQuery.expando !== undefined, true, "jQuery is exposing the expando");
});

test( "jQuery.data & removeData, expected returns", function() {
	expect(4);
	var elem = document.body;

	equal(
		jQuery.data( elem, "hello", "world" ), "world",
		"jQuery.data( elem, key, value ) returns value"
	);
	equal(
		jQuery.data( elem, "hello" ), "world",
		"jQuery.data( elem, key ) returns value"
	);
	deepEqual(
		jQuery.data( elem, { goodnight: "moon" }), { goodnight: "moon" },
		"jQuery.data( elem, obj ) returns obj"
	);
	equal(
		jQuery.removeData( elem, "hello" ), undefined,
		"jQuery.removeData( elem, key, value ) returns undefined"
	);

});

test( "jQuery._data & _removeData, expected returns", function() {
	expect(4);
	var elem = document.body;

	equal(
		jQuery._data( elem, "hello", "world" ), "world",
		"jQuery._data( elem, key, value ) returns value"
	);
	equal(
		jQuery._data( elem, "hello" ), "world",
		"jQuery._data( elem, key ) returns value"
	);
	deepEqual(
		jQuery._data( elem, { goodnight: "moon" }), { goodnight: "moon" },
		"jQuery._data( elem, obj ) returns obj"
	);
	equal(
		jQuery._removeData( elem, "hello" ), undefined,
		"jQuery._removeData( elem, key, value ) returns undefined"
	);
});

test( "jQuery.hasData no side effects", function() {
	expect(1);
	var obj = {};

	jQuery.hasData( obj );

	equal( Object.getOwnPropertyNames( obj ).length, 0,
		"No data expandos where added when calling jQuery.hasData(o)"
	);
});

function dataTests (elem) {
	var oldCacheLength, dataObj, internalDataObj, expected, actual;

	equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" );
	strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" );

	dataObj = jQuery.data(elem);
	equal( typeof dataObj, "object", "Calling data with no args gives us a data object reference" );
	strictEqual( jQuery.data(elem), dataObj, "Calling jQuery.data returns the same data object when called multiple times" );

	strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" );

	dataObj["foo"] = "bar";
	equal( jQuery.data(elem, "foo"), "bar", "Data is readable by jQuery.data when set directly on a returned data object" );

	strictEqual( jQuery.hasData(elem), true, "jQuery.hasData agrees data exists when data exists" );

	jQuery.data(elem, "foo", "baz");
	equal( jQuery.data(elem, "foo"), "baz", "Data can be changed by jQuery.data" );
	equal( dataObj["foo"], "baz", "Changes made through jQuery.data propagate to referenced data object" );

	jQuery.data(elem, "foo", undefined);
	equal( jQuery.data(elem, "foo"), "baz", "Data is not unset by passing undefined to jQuery.data" );

	jQuery.data(elem, "foo", null);
	strictEqual( jQuery.data(elem, "foo"), null, "Setting null using jQuery.data works OK" );

	jQuery.data(elem, "foo", "foo1");

	jQuery.data(elem, { "bar" : "baz", "boom" : "bloz" });
	strictEqual( jQuery.data(elem, "foo"), "foo1", "Passing an object extends the data object instead of replacing it" );
	equal( jQuery.data(elem, "boom"), "bloz", "Extending the data object works" );

	jQuery._data(elem, "foo", "foo2", true);
	equal( jQuery._data(elem, "foo"), "foo2", "Setting internal data works" );
	equal( jQuery.data(elem, "foo"), "foo1", "Setting internal data does not override user data" );

	internalDataObj = jQuery._data( elem );
	ok( internalDataObj, "Internal data object exists" );
	notStrictEqual( dataObj, internalDataObj, "Internal data object is not the same as user data object" );

	strictEqual( elem.boom, undefined, "Data is never stored directly on the object" );

	jQuery.removeData(elem, "foo");
	strictEqual( jQuery.data(elem, "foo"), undefined, "jQuery.removeData removes single properties" );

	jQuery.removeData(elem);
	strictEqual( jQuery._data(elem), internalDataObj, "jQuery.removeData does not remove internal data if it exists" );

	jQuery.data(elem, "foo", "foo1");
	jQuery._data(elem, "foo", "foo2");

	equal( jQuery.data(elem, "foo"), "foo1", "(sanity check) Ensure data is set in user data object" );
	equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );

	strictEqual( jQuery._data(elem, jQuery.expando), undefined, "Removing the last item in internal data destroys the internal data object" );

	jQuery._data(elem, "foo", "foo2");
	equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) Ensure data is set in internal data object" );

	jQuery.removeData(elem, "foo");
	equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" );
}

test("jQuery.data(div)", 25, function() {
	var div = document.createElement("div");

	dataTests(div);

	// We stored one key in the private data
	// assert that nothing else was put in there, and that that
	// one stayed there.
	QUnit.expectJqData(div, "foo");
});

test("jQuery.data({})", 25, function() {
	dataTests({});
});

test("jQuery.data(window)", 25, function() {
	// remove bound handlers from window object to stop potential false positives caused by fix for #5280 in
	// transports/xhr.js
	jQuery(window).off("unload");

	dataTests(window);
});

test("jQuery.data(document)", 25, function() {
	dataTests(document);

	QUnit.expectJqData(document, "foo");
});

test("jQuery.data(<embed>)", 25, function() {
	dataTests( document.createElement("embed") );
});

test("jQuery.data(<applet>)", 25, function() {
	dataTests( document.createElement("applet") );
});

test("jQuery.data(object/flash)", 25, function() {
	var flash = document.createElement("object");
	flash.setAttribute( "classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" );

	dataTests( flash );
});

test("jQuery.data(comment)", 25, function() {
	dataTests( document.createComment("") );
});

test("jQuery.data(text)", 25, function() {
	dataTests( document.createTextNode("") );
});

test(".data()", function() {
	expect(5);

	var div = jQuery("#foo");
	strictEqual( div.data("foo"), undefined, "Make sure that missing result is undefined" );
	div.data("test", "success");
{'fraction_non_alphanumeric': 0.1676300578034682, 'fraction_numerical': 0.011639876474780268, 'mean_word_length': 5.098503138580396, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7175313', 'n_tokens_mistral': 4199, 'n_tokens_neox': 4011, 'n_words': 1243}