Skip to content

Commit 2155080

Browse files
Mugen87sunag
andauthored
NodeUtils: Ignore private sub properties in getNodeChildren(). (#31523)
* NoteUtils: Ignore private sub properties in `getNodeChildren()`. * check just pure objects --------- Co-authored-by: sunag <[email protected]>
1 parent 37763dc commit 2155080

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/nodes/core/NodeUtils.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ export function* getNodeChildren( node, toJSON = false ) {
138138

139139
yield { property, childNode: object };
140140

141-
} else if ( typeof object === 'object' ) {
141+
} else if ( object && Object.getPrototypeOf( object ) === Object.prototype ) {
142142

143143
for ( const subProperty in object ) {
144144

145+
// Ignore private properties.
146+
if ( subProperty.startsWith( '_' ) === true ) continue;
147+
145148
const child = object[ subProperty ];
146149

147150
if ( child && ( child.isNode === true || toJSON && typeof child.toJSON === 'function' ) ) {

0 commit comments

Comments
 (0)