Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not expose internal
children
array
Whenever Cheerio inserts a node as a child of a some other node, it explicitly removes it from its previous `children` array. This both avoids memory leaks and more faithfully matches the behavior of the W3C DOM, where a node may only be a child of one other node. When a user creates an array of node objects from a string using `$.parseHTML`, she most likely intends to insert the contents into some previously-existing DOM structure. If supplied with the `children` array directly, future insertion operations will modify the contents of that array. This is both unintuitive from an API design perspective and inconsistent with jQuery's behavior. To avoid silently changing the contents of arrays given to users, update `$.parseHTML` to return a shallow copy of the `children` structure.
- Loading branch information