davidmarkclements / rfdc

Really Fast Deep Clone
MIT License
634 stars 24 forks source link

The exclusive use of "constructorHandlers" for checking the type may not be optimal. #44

Open fangyeqing123 opened 2 months ago

fangyeqing123 commented 2 months ago

Is it possible to handle Element and HTMLElement uniformly based on "instanceof" when handling all DOM elements, as currently handling them one by one based on their constructors is cumbersome? When there are HTMLElement elements in the input object, it can cause rfdc to freeze. It would be helpful if internal memory leak handling could be implemented, and if the depth of the object hierarchy is too deep, a warning could be given, with the option to only copy specified depths of objects.

fangyeqing123 commented 2 months ago

When "circles" is enabled, having DOM elements in the object can cause the process to freeze.

fangyeqing123 commented 2 months ago

The attributes of a DOM element cannot be copied as well.

mcollina commented 2 months ago

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.