Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

fix(memory): reduce memory leaks in Jest JSDOM environment #1106

Merged
merged 1 commit into from
Jul 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ export function patchProperty(obj: any, prop: string, prototype?: any) {
return;
}

const onPropPatchedSymbol = zoneSymbol('on' + prop + 'patched');
if (obj.hasOwnProperty(onPropPatchedSymbol) && obj[onPropPatchedSymbol]) {
return;
}

// A property descriptor cannot have getter/setter and be writable
// deleting the writable and value properties avoids this error:
//
Expand Down Expand Up @@ -240,6 +245,8 @@ export function patchProperty(obj: any, prop: string, prototype?: any) {
};

ObjectDefineProperty(obj, prop, desc);

obj[onPropPatchedSymbol] = true;
}

export function patchOnProperties(obj: any, properties: string[]|null, prototype?: any) {
Expand Down