Skip to content

Commit

Permalink
deprecate misc.isPlainEmptyObj_DEV, use js.isEmptyObject instead (#…
Browse files Browse the repository at this point in the history
…16341)

* fix: deprecate `isPlainEmptyObj_DEV`
  • Loading branch information
PPpro authored Oct 8, 2023
1 parent 945d8a6 commit 99965c9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 9 additions & 0 deletions cocos/base/utils/src/internal-index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
import { js } from './js';

export { ScalableContainer, scalableContainerManager } from './memop/scalable-container';

export function isPlainEmptyObj (obj): boolean {
if (!obj || obj.constructor !== Object) {
return false;
}
return js.isEmptyObject(obj);
}
4 changes: 2 additions & 2 deletions cocos/core/data/utils/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { EDITOR } from 'internal:constants';
import { log, warnID } from '@base/debug';
import { cclegacy } from '@base/global';
import { js } from '@base/utils';
import { isPlainEmptyObj_DEV } from '../../utils/misc';
import { isPlainEmptyObj } from '@base/utils/internal';

const { formatStr, get, getClassName, isChildClassOf, value } = js;

Expand Down Expand Up @@ -228,7 +228,7 @@ export function getTypeChecker_ET (type: string, attributeName: string) {
if (typeof defaultVal === 'undefined') {
return;
}
const isContainer = Array.isArray(defaultVal) || isPlainEmptyObj_DEV(defaultVal);
const isContainer = Array.isArray(defaultVal) || isPlainEmptyObj(defaultVal);
if (isContainer) {
return;
}
Expand Down
9 changes: 6 additions & 3 deletions cocos/core/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { setTimeoutRAF } from '@pal/utils';
import { cclegacy } from '@base/global';
import { warnID } from '@base/debug';
import { js } from '@base/utils';
import { isPlainEmptyObj } from '@base/utils/internal';
import { macro } from '../platform/macro';

const { getClassName, getset, isEmptyObject } = js;
Expand Down Expand Up @@ -205,12 +206,14 @@ export function tryCatchFunctor_EDITOR (funcName: string): (comp: unknown) => vo
* @param obj @en The object to check. @zh 要检查的对象。
* @returns @en True if it is an empty object. False if it is not an empty object, not Object type, null or undefined.
* @ 如果是空对象,返回 true。如果不是空对象,不是Object类型,空或未定义,则为假。
*
* @deprecated `misc.isPlainEmptyObj_DEV` is deprecated since v3.9.0, please use `js.isEmptyObject` instead.
*/
export function isPlainEmptyObj_DEV (obj): boolean {
if (!obj || obj.constructor !== Object) {
return false;
if (DEBUG) {
warnID(16001, 'misc.isPlainEmptyObj_DEV', '3.9.0', 'js.isEmptyObject');
}
return isEmptyObject(obj);
return isPlainEmptyObj(obj);
}

/**
Expand Down

0 comments on commit 99965c9

Please sign in to comment.