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

Commit a4faa5c

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 32cb40b commit a4faa5c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/jqLite.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@
9898
* @returns {Object} jQuery object.
9999
*/
100100

101+
JQLite.expando = 'ng';
102+
101103
var jqCache = JQLite.cache = {},
102-
jqName = JQLite.expando = 'ng' + new Date().getTime(),
103104
jqId = 1,
104105
addEventListenerFn = (window.document.addEventListener
105106
? function(element, type, fn) {element.addEventListener(type, fn, false);}
@@ -309,7 +310,7 @@ function jqLiteOff(element, type, fn, unsupported) {
309310
}
310311

311312
function jqLiteRemoveData(element, name) {
312-
var expandoId = element[jqName],
313+
var expandoId = element.ng,
313314
expandoStore = jqCache[expandoId];
314315

315316
if (expandoStore) {
@@ -323,17 +324,17 @@ function jqLiteRemoveData(element, name) {
323324
jqLiteOff(element);
324325
}
325326
delete jqCache[expandoId];
326-
element[jqName] = undefined; // ie does not allow deletion of attributes on elements.
327+
element.ng = undefined; // don't delete DOM expandos. IE and Chrome don't like it
327328
}
328329
}
329330

330331
function jqLiteExpandoStore(element, key, value) {
331-
var expandoId = element[jqName],
332+
var expandoId = element.ng,
332333
expandoStore = jqCache[expandoId || -1];
333334

334335
if (isDefined(value)) {
335336
if (!expandoStore) {
336-
element[jqName] = expandoId = jqNextId();
337+
element.ng = expandoId = jqNextId();
337338
expandoStore = jqCache[expandoId] = {};
338339
}
339340
expandoStore[key] = value;

0 commit comments

Comments
 (0)