Skip to content

Commit

Permalink
fix build-effect error (cocos#11496)
Browse files Browse the repository at this point in the history
  • Loading branch information
SantyWang authored Jun 14, 2022
1 parent 7dd8582 commit e9e89fc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cocos/core/data/garbage-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ declare class FinalizationRegistry {
const targetSymbol = Symbol('[[target]]');

class GarbageCollectionManager {
private _finalizationRegistry: FinalizationRegistry | null = EDITOR ? new FinalizationRegistry(this.finalizationRegistryCallback.bind(this)) : null;
private _finalizationRegistry: FinalizationRegistry | null = EDITOR && FinalizationRegistry ? new FinalizationRegistry(this.finalizationRegistryCallback.bind(this)) : null;
private _gcObjects: WeakMap<any, GCObject> = new WeakMap();

public registerGCObject (gcObject: GCObject): GCObject {
if (EDITOR) {
if (EDITOR && this._finalizationRegistry) {
const token = {};
const proxy = new Proxy(gcObject, {
get (target, property, receiver) {
Expand All @@ -57,7 +57,7 @@ class GarbageCollectionManager {
},
});
this._gcObjects.set(token, gcObject);
this._finalizationRegistry!.register(proxy, token, token);
this._finalizationRegistry.register(proxy, token, token);
return proxy;
} else {
return gcObject;
Expand Down

0 comments on commit e9e89fc

Please sign in to comment.