"./core",
"./var/deletedIds",
"./data/support",
- "./data/accepts"
-], function( jQuery, deletedIds, support ) {
+ "./data/var/acceptData"
+], function( jQuery, deletedIds, support, acceptData ) {
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash = /([A-Z])/g;
}
function internalData( elem, key, data, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
+ if ( !acceptData( elem ) ) {
return;
}
}
function internalRemoveData( elem, key, pvt ) {
- if ( !jQuery.acceptData( elem ) ) {
+ if ( !acceptData( elem ) ) {
return;
}
+++ /dev/null
-define( [
- "../core"
-], function( jQuery ) {
-
-/**
- * Determines whether an object can have data
- */
-jQuery.acceptData = function( elem ) {
- var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
- nodeType = +elem.nodeType || 1;
-
- // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
- return nodeType !== 1 && nodeType !== 9 ?
- false :
-
- // Nodes accept data unless otherwise specified; rejection can be conditional
- !noData || noData !== true && elem.getAttribute( "classid" ) === noData;
-};
-
-return jQuery.acceptData;
-} );
--- /dev/null
+define( function() {
+
+/**
+ * Determines whether an object can have data
+ */
+return function( elem ) {
+ var noData = jQuery.noData[ ( elem.nodeName + " " ).toLowerCase() ],
+ nodeType = +elem.nodeType || 1;
+
+ // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
+ return nodeType !== 1 && nodeType !== 9 ?
+ false :
+
+ // Nodes accept data unless otherwise specified; rejection can be conditional
+ !noData || noData !== true && elem.getAttribute( "classid" ) === noData;
+};
+
+} );
"./var/hasOwn",
"./var/slice",
"./event/support",
+ "./data/var/acceptData",
"./core/init",
"./data",
"./selector"
-], function( jQuery, document, rnotwhite, hasOwn, slice, support ) {
+], function( jQuery, document, rnotwhite, hasOwn, slice, support, acceptData ) {
var rformElems = /^(?:input|select|textarea)$/i,
rkeyEvent = /^key/,
// Native handler
handle = ontype && cur[ ontype ];
- if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
+ if ( handle && handle.apply && acceptData( cur ) ) {
event.result = handle.apply( cur, data );
if ( event.result === false ) {
event.preventDefault();
if (
( !special._default ||
special._default.apply( eventPath.pop(), data ) === false
- ) && jQuery.acceptData( elem )
+ ) && acceptData( elem )
) {
// Call a native DOM method on the target with the same name name as the event.
"./manipulation/setGlobalEval",
"./manipulation/buildFragment",
"./manipulation/support",
+ "./data/var/acceptData",
"./core/init",
- "./data/accepts",
"./traversing",
"./selector",
"./event"
], function( jQuery, document, concat, push, deletedIds, access,
rcheckableType, rtagName, rscriptType, rleadingWhitespace, nodeNames,
createSafeFragment, wrapMap, getAll, setGlobalEval,
- buildFragment, support ) {
+ buildFragment, support, acceptData ) {
var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
rnoshimcache = new RegExp( "<(?:" + nodeNames + ")[\\s/>]", "i" ),
return clone;
},
- cleanData: function( elems, /* internal */ acceptData ) {
+ cleanData: function( elems, /* internal */ forceAcceptData ) {
var elem, type, id, data,
i = 0,
internalKey = jQuery.expando,
special = jQuery.event.special;
for ( ; ( elem = elems[ i ] ) != null; i++ ) {
- if ( acceptData || jQuery.acceptData( elem ) ) {
+ if ( forceAcceptData || acceptData( elem ) ) {
id = elem[ internalKey ];
data = id && cache[ id ];
} );
-QUnit.test( "jQuery.acceptData", function( assert ) {
+QUnit.test( "acceptData", function( assert ) {
assert.expect( 10 );
- var flash, pdf;
+ var flash, pdf, form;
- assert.ok(
- jQuery.acceptData( document ), "document"
- );
- assert.ok(
- jQuery.acceptData( document.documentElement ), "documentElement"
- );
- assert.ok(
- jQuery.acceptData( {} ), "object"
- );
- assert.ok(
- !jQuery.acceptData( document.createElement( "embed" ) ), "embed"
- );
+ assert.equal( 42, jQuery( document ).data( "test", 42 ).data( "test" ), "document" );
+ assert.equal( 42, jQuery( document.documentElement ).data( "test", 42 ).data( "test" ), "documentElement" );
+ assert.equal( 42, jQuery( {} ).data( "test", 42 ).data( "test" ), "object" );
+ assert.equal( undefined, jQuery( document.createElement( "embed" ) ).data( "test", 42 ).data( "test" ), "embed" );
flash = document.createElement( "object" );
flash.setAttribute( "classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" );
- assert.ok(
- jQuery.acceptData( flash ), "flash"
- );
+ assert.equal( 42, jQuery( flash ).data( "test", 42 ).data( "test" ), "flash" );
pdf = document.createElement( "object" );
pdf.setAttribute( "classid", "clsid:CA8A9780-280D-11CF-A24D-444553540000" );
- assert.ok(
- !jQuery.acceptData( pdf ), "pdf"
- );
+ assert.equal( undefined, jQuery( pdf ).data( "test", 42 ).data( "test" ), "pdf" );
- assert.ok(
- !jQuery.acceptData( document.createComment( "" ) ), "comment"
- );
- assert.ok(
- !jQuery.acceptData( document.createTextNode( "" ) ), "text"
- );
- assert.ok(
- !jQuery.acceptData( document.createDocumentFragment() ), "documentFragment"
- );
+ assert.equal( undefined, jQuery( document.createComment( "" ) ).data( "test", 42 ).data( "test" ), "comment" );
+ assert.equal( undefined, jQuery( document.createTextNode( "" ) ).data( "test", 42 ).data( "test" ), "text" );
+ assert.equal( undefined, jQuery( document.createDocumentFragment() ).data( "test", 42 ).data( "test" ), "documentFragment" );
- assert.ok(
- jQuery.acceptData(
- jQuery( "#form" ).append( "<input id='nodeType'/><input id='nodeName'/>" )[ 0 ]
- ),
- "form with aliased DOM properties"
- );
+ form = jQuery( "#form" ).append( "<input id='nodeType'/><input id='nodeName'/>" )[ 0 ];
+ assert.equal( 42, jQuery( form ) .data( "test", 42 ).data( "test" ), "form with aliased DOM properties" );
+
+ // Clean up.
+ jQuery.removeData( document );
+ jQuery.removeData( document.documentElement );
+ jQuery.removeData( flash );
+ jQuery.removeData( form );
} );
// attempting to access the data of an undefined jQuery element should be undefined