jquery/jquery — pull request #1107 by rwldrn (2012-12-31 20:12:02+00:00)
Title: 2.0: Rewrite data.js

r2 (no manipulation.js changes in history; based on https://github.com/jquery/jquery/pull/1096/commits)

This re-write puts us in position to replace the internal data system with a `WeakMap`.

```bash
Sizes - compared to master @ 963c47f9ed5a79f2a75d925bba017c61f0419609
263923 (-1980) dist/jquery.js
92205 (-531) dist/jquery.min.js
32574 (-264) dist/jquery.min.js.gz
```

NOTE: The following changes will need to be made to other modules:

## core.js

The array `core_deletedIds` can be deleted, it is no longer necessary. The saved references to array methods that are relying on `core_deletedIds` can be replaced by any empty array reference.

## css.js

```js
values[ index ] = jQuery._data( elem, "olddisplay", css_defaultDisplay(elem.nodeName) );
```

This is the only place where a call to _set_ internal data is also expecting the value being set to be returned. There were no tests supporting this. Change to something like...

```js
values[ index ] = css_defaultDisplay( elem.nodeName );

jQuery._data( elem, "olddisplay", values[ index ] );`
```

## manipulation.js

In `cleanData`, direct access to the cache needs to be updated to use API. To remove all data cache references, use: `data_discard( owner )`

## events.js

Direct access to cache needs to be update to use API

## Notable

Since `Data` is a constructor, each of the above could

## Ideal

Ideally we'd replace all calls to `jQuery._data` and `jQuery._removeData` with `priv.access( elem, name );`, `priv.access( elem, name, data );` and `priv.remove( elem, name );`—ultimately to eliminate them from the exposed jQuery surface.

Signed-off-by: Rick Waldron