( elem, name, data, pvt /* Internal Use Only */ )
| 1549 | rmultiDash = /([A-Z])/g; |
| 1550 | |
| 1551 | function internalData( elem, name, data, pvt /* Internal Use Only */ ){ |
| 1552 | if ( !jQuery.acceptData( elem ) ) { |
| 1553 | return; |
| 1554 | } |
| 1555 | |
| 1556 | var thisCache, ret, |
| 1557 | internalKey = jQuery.expando, |
| 1558 | getByName = typeof name === "string", |
| 1559 | |
| 1560 | // We have to handle DOM nodes and JS objects differently because IE6-7 |
| 1561 | // can't GC object references properly across the DOM-JS boundary |
| 1562 | isNode = elem.nodeType, |
| 1563 | |
| 1564 | // Only DOM nodes need the global jQuery cache; JS object data is |
| 1565 | // attached directly to the object so GC can occur automatically |
| 1566 | cache = isNode ? jQuery.cache : elem, |
| 1567 | |
| 1568 | // Only defining an ID for JS objects if its cache already exists allows |
| 1569 | // the code to shortcut on the same path as a DOM node with no cache |
| 1570 | id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey; |
| 1571 | |
| 1572 | // Avoid doing any more work than we need to when trying to get data on an |
| 1573 | // object that has no data at all |
| 1574 | if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && getByName && data === undefined ) { |
| 1575 | return; |
| 1576 | } |
| 1577 | |
| 1578 | if ( !id ) { |
| 1579 | // Only DOM nodes need a new unique ID for each element since their data |
| 1580 | // ends up in the global cache |
| 1581 | if ( isNode ) { |
| 1582 | elem[ internalKey ] = id = core_deletedIds.pop() || jQuery.guid++; |
| 1583 | } else { |
| 1584 | id = internalKey; |
| 1585 | } |
| 1586 | } |
| 1587 | |
| 1588 | if ( !cache[ id ] ) { |
| 1589 | cache[ id ] = {}; |
| 1590 | |
| 1591 | // Avoids exposing jQuery metadata on plain JS objects when the object |
| 1592 | // is serialized using JSON.stringify |
| 1593 | if ( !isNode ) { |
| 1594 | cache[ id ].toJSON = jQuery.noop; |
| 1595 | } |
| 1596 | } |
| 1597 | |
| 1598 | // An object can be passed to jQuery.data instead of a key/value pair; this gets |
| 1599 | // shallow copied over onto the existing cache |
| 1600 | if ( typeof name === "object" || typeof name === "function" ) { |
| 1601 | if ( pvt ) { |
| 1602 | cache[ id ] = jQuery.extend( cache[ id ], name ); |
| 1603 | } else { |
| 1604 | cache[ id ].data = jQuery.extend( cache[ id ].data, name ); |
| 1605 | } |
| 1606 | } |
| 1607 | |
| 1608 | thisCache = cache[ id ]; |
no outgoing calls
no test coverage detected
searching dependent graphs…