Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Hopefully fix memory leak with velocity #291

Merged
merged 3 commits into from
May 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Velociraptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ module.exports = React.createClass({
});

//console.log("enter: "+JSON.stringify(node.props._restingStyle));
} else if (node === null) {
// Velocity stores data on elements using the jQuery .data()
// method, and assumes you'll be using jQuery's .remove() to
// remove the element, but we don't use jQuery, so we need to
// blow away the element's data explicitly otherwise it will leak.
// This uses Velocity's internal jQuery compatible wrapper.
// See the bug at
// https://github.com/julianshapiro/velocity/issues/300
// and the FAQ entry, "Preventing memory leaks when
// creating/destroying large numbers of elements"
// (https://github.com/julianshapiro/velocity/issues/47)
Velocity.Utilities.removeData(this.nodes[k]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks plausible to me, but it's far from obvious from reading the linked bug. Could you add a more verbose comment - something along the lines of "Tell the Velocity jquery shim to forget about any data associated with this node"

}
this.nodes[k] = node;
},
Expand Down