tbo47 / dagre-es

The dagrejs library exported as ES modules.
Other
32 stars 14 forks source link

position function not working properly when a node is named ´length´. #19

Closed Pr0dt0s closed 1 year ago

Pr0dt0s commented 1 year ago

Since PositionX returns an object, if a property is named length the forEach treats the object as an array.

https://github.com/tbo47/dagre-es/blob/761b78f220466cda021ae2af81a788bf38b5e185/src/dagre/position/index.js#L7-L14

This should be changed to a forOwn according to lodash.

https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/forEach.js#L5-L11

Note: As with other "Collections" methods, objects with a "length" property are iterated like arrays. To avoid this behavior use forIn or forOwn for object iteration.