MCPcopy Index your code
hub / github.com/TruthHun/BookStack / internalData

Function internalData

static/jquery/1.12.4/jquery.js:3829–3919  ·  view source on GitHub ↗
( elem, name, data, pvt /* Internal Use Only */ )

Source from the content-addressed store, hash-verified

3827}
3828
3829function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
3830 if ( !acceptData( elem ) ) {
3831 return;
3832 }
3833
3834 var ret, thisCache,
3835 internalKey = jQuery.expando,
3836
3837 // We have to handle DOM nodes and JS objects differently because IE6-7
3838 // can't GC object references properly across the DOM-JS boundary
3839 isNode = elem.nodeType,
3840
3841 // Only DOM nodes need the global jQuery cache; JS object data is
3842 // attached directly to the object so GC can occur automatically
3843 cache = isNode ? jQuery.cache : elem,
3844
3845 // Only defining an ID for JS objects if its cache already exists allows
3846 // the code to shortcut on the same path as a DOM node with no cache
3847 id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
3848
3849 // Avoid doing any more work than we need to when trying to get data on an
3850 // object that has no data at all
3851 if ( ( !id || !cache[ id ] || ( !pvt && !cache[ id ].data ) ) &&
3852 data === undefined && typeof name === "string" ) {
3853 return;
3854 }
3855
3856 if ( !id ) {
3857
3858 // Only DOM nodes need a new unique ID for each element since their data
3859 // ends up in the global cache
3860 if ( isNode ) {
3861 id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
3862 } else {
3863 id = internalKey;
3864 }
3865 }
3866
3867 if ( !cache[ id ] ) {
3868
3869 // Avoid exposing jQuery metadata on plain JS objects when the object
3870 // is serialized using JSON.stringify
3871 cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
3872 }
3873
3874 // An object can be passed to jQuery.data instead of a key/value pair; this gets
3875 // shallow copied over onto the existing cache
3876 if ( typeof name === "object" || typeof name === "function" ) {
3877 if ( pvt ) {
3878 cache[ id ] = jQuery.extend( cache[ id ], name );
3879 } else {
3880 cache[ id ].data = jQuery.extend( cache[ id ].data, name );
3881 }
3882 }
3883
3884 thisCache = cache[ id ];
3885
3886 // jQuery data() is stored in a separate object inside the object's internal data

Callers 1

jquery.jsFile · 0.85

Calls 2

extendMethod · 0.80
acceptDataFunction · 0.70

Tested by

no test coverage detected