Polyfill WeakRef (#34025)

Fix #33407
This commit is contained in:
wxiaoguang authored and GitHub committed 2025-03-26 23:56:25 +08:00
1 parent d28a7f9fea
commit d70be9d0fe
2 files changed
+23

No files matched your search

+16
View File
@@ -16,3 +16,19 @@ try {
return intlNumberFormat(locales, options);
};
}
export function weakRefClass() {
const weakMap = new WeakMap();
return class {
constructor(target: any) {
weakMap.set(this, target);
}
deref() {
return weakMap.get(this);
}
};
}
if (!window.WeakRef) {
window.WeakRef = weakRefClass() as any;
}