@@ -17,7 +17,7 @@ const configurable = true;
1717/* -------------------------------------------------------------------------- */
1818
1919const getItems = ( nodes : unObject [ ] , node ?: unObject ) =>
20- nodes . toReversed ( ) . map ( ( child ) => ( {
20+ [ ... nodes ] . reverse ( ) . map ( ( child ) => ( {
2121 node : child ,
2222 parent : { configurable, value : node } ,
2323 siblings : { configurable, value : nodes } ,
@@ -90,11 +90,12 @@ export default (
9090 while ( stack . length ) {
9191 const { node, parent, siblings } = stack . pop ( ) ?? { } ;
9292 if ( node && parent && siblings ) {
93- Object . defineProperties ( node , {
94- ...properties ,
95- [ keyParent ] : parent ,
96- [ keySiblings ] : siblings ,
97- } ) ;
93+ if ( node [ keyParent ] !== parent )
94+ Object . defineProperty ( node , keyParent , { value : parent } ) ;
95+ if ( node [ keySiblings ] !== parent )
96+ Object . defineProperty ( node , keySiblings , { value : siblings } ) ;
97+ if ( Object . keys ( properties ) . some ( ( key ) => ! ( key in node ) ) )
98+ Object . defineProperties ( node , properties ) ;
9899 yield node ;
99100 stack . push (
100101 ...getItems ( ( node [ keyChildren ] ?? [ ] ) as unObject [ ] , node ) ,
0 commit comments