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

memory leak in tests with jQuery 2 #8532

Closed
@IgorMinar

Description

@IgorMinar

I don't think that we properly considered the impact of the jQuery 2 upgrade on angular-mocks.

relevant code:

angular.mock.clearDataCache = function() {
// jQuery 2.x doesn't expose data attached to elements. We could use jQuery.cleanData
// to clean up after elements but we'd first need to know which elements to clean up after.
// Skip it then.
if (window.jQuery) {
return;
}
var key,
cache = angular.element.cache;
for(key in cache) {
if (Object.prototype.hasOwnProperty.call(cache,key)) {
var handle = cache[key].handle;
handle && angular.element(handle.elem).off();
delete cache[key];
}
}
};

this means that if a test doesn't trigger jQuery data/event handler deallocation, these objects will remain in the jQuery cache forever or at least until karma captured browser window doesn't crash.

I'm unsure how to fix this without patching jQuery :-/

@mzgol any ideas? :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions