Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix: improve property access handling in FUniver class proxy (#5010)

白熱97f95ab4c84d
diff --git a/packages/core/src/facade/f-univer.ts b/packages/core/src/facade/f-univer.ts
index 0bddf08bfb..7d0fa35894 100644
--- a/packages/core/src/facade/f-univer.ts
+++ b/packages/core/src/facade/f-univer.ts
@@ -63,10 +63,15 @@ export class FUniver extends Disposable {
* Uses Proxy to intercept method calls and check if the method exists.
*/
return new Proxy(instance, {
- get(target, prop, receiver): FUniver {
- const value = Reflect.get(target, prop, receiver);
- if (typeof value !== 'undefined') {
- return value;
+ get(target, prop): FUniver {
+ if (prop in Object.prototype ||
+ typeof prop === 'symbol' ||
+ ['toString', 'valueOf', 'toJSON', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'inspect', 'then', 'catch', 'finally'].includes(String(prop))) {
+ return Reflect.get(target, prop);
+ }
+
+ if (prop in target) {
+ return Reflect.get(target, prop);
} else {
throw new TypeError(
`[FUniver]: The method '${String(prop)}' does not exist on the FUniver instance. ` +