Plug memory leak in raw tag editor / d3.combobox

This commit is contained in:
Bryan Housel
2016-01-05 01:33:16 -05:00
parent 56e97ba256
commit f2a8f7181b
2 changed files with 31 additions and 0 deletions
+11
View File
@@ -114,6 +114,7 @@ iD.ui.RawTagEditor = function(context) {
.on('click', removeTag);
$items.exit()
.each(unbind)
.remove();
function pushMore() {
@@ -165,6 +166,16 @@ iD.ui.RawTagEditor = function(context) {
}));
}
function unbind() {
var row = d3.select(this);
row.selectAll('input.key')
.call(d3.combobox.off);
row.selectAll('input.value')
.call(d3.combobox.off);
}
function keyChange(d) {
var kOld = d.key,
kNew = this.value.trim(),
+20
View File
@@ -271,3 +271,23 @@ d3.combobox = function() {
return d3.rebind(combobox, event, 'on');
};
d3.combobox.off = function(input) {
data = null;
fetcher = null;
input
.on('focus.typeahead', null)
.on('blur.typeahead', null)
.on('keydown.typeahead', null)
.on('keyup.typeahead', null)
.on('input.typeahead', null)
.each(function() {
d3.select(this.parentNode).selectAll('.combobox-caret')
.filter(function(d) { return d === input.node(); })
.on('mousedown', null);
});
d3.select(document.body)
.on('scroll.combobox', null);
};