ソースを参照

NodeUtils: Ignore private sub properties in `getNodeChildren()`. (#31523)

* NoteUtils: Ignore private sub properties in `getNodeChildren()`.

* check just pure objects

---------

Co-authored-by: sunag <sunagbrasil@gmail.com>
Michael Herzog 7 ヶ月 前
コミット
21550804d2
1 ファイル変更4 行追加1 行削除
  1. 4 1
      src/nodes/core/NodeUtils.js

+ 4 - 1
src/nodes/core/NodeUtils.js

@@ -138,10 +138,13 @@ export function* getNodeChildren( node, toJSON = false ) {
 
 			yield { property, childNode: object };
 
-		} else if ( typeof object === 'object' ) {
+		} else if ( object && Object.getPrototypeOf( object ) === Object.prototype ) {
 
 			for ( const subProperty in object ) {
 
+				// Ignore private properties.
+				if ( subProperty.startsWith( '_' ) === true ) continue;
+
 				const child = object[ subProperty ];
 
 				if ( child && ( child.isNode === true || toJSON && typeof child.toJSON === 'function' ) ) {

粤ICP备19079148号