mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-02 21:21:37 +02:00
Plug memory leak in raw tag editor / d3.combobox
This commit is contained in:
@@ -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(),
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user