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

Commit ef7116f

Browse files
committed
fix(memory): Add protection against excessive patching
This caused memory leaks in Jest JSDOM environment
1 parent 0a2f6ff commit ef7116f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/common/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ export function patchProperty(obj: any, prop: string, prototype?: any) {
239239
return null;
240240
};
241241

242-
ObjectDefineProperty(obj, prop, desc);
242+
if (!obj[zoneSymbol(`on` + prop + 'patched')]) {
243+
obj[zoneSymbol(`on` + prop + 'patched')] = true;
244+
245+
ObjectDefineProperty(obj, prop, desc);
246+
}
243247
}
244248

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

0 commit comments

Comments
 (0)