Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit ea9a130

Browse files
IgorMinarrodyhaddad
authored andcommitted
perf(jqLite): don't use reflection to access expandoId
Since we allow only one copy of Angular to be loaded at a time it doesn't make much sense randomly generate the expando property name and then be forced to use slow reflective calles to retrieve the IDs.
1 parent 04468db commit ea9a130

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/jqLite.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,9 @@
9999
* @returns {Object} jQuery object.
100100
*/
101101

102+
JQLite.expando = 'ng';
103+
102104
var jqCache = JQLite.cache = {},
103-
jqName = JQLite.expando = 'ng' + new Date().getTime(),
104105
jqId = 1,
105106
addEventListenerFn = (window.document.addEventListener
106107
? function(element, type, fn) {element.addEventListener(type, fn, false);}
@@ -271,7 +272,7 @@ function jqLiteOff(element, type, fn, unsupported) {
271272
}
272273

273274
function jqLiteRemoveData(element, name) {
274-
var expandoId = element[jqName],
275+
var expandoId = element.ng,
275276
expandoStore = jqCache[expandoId];
276277

277278
if (expandoStore) {
@@ -285,17 +286,17 @@ function jqLiteRemoveData(element, name) {
285286
jqLiteOff(element);
286287
}
287288
delete jqCache[expandoId];
288-
element[jqName] = undefined; // ie does not allow deletion of attributes on elements.
289+
element.ng = undefined; // don't delete DOM expandos. IE and Chrome don't like it
289290
}
290291
}
291292

292293
function jqLiteExpandoStore(element, key, value) {
293-
var expandoId = element[jqName],
294+
var expandoId = element.ng,
294295
expandoStore = jqCache[expandoId || -1];
295296

296297
if (isDefined(value)) {
297298
if (!expandoStore) {
298-
element[jqName] = expandoId = jqNextId();
299+
element.ng = expandoId = jqNextId();
299300
expandoStore = jqCache[expandoId] = {};
300301
}
301302
expandoStore[key] = value;

0 commit comments

Comments
 (0)