fix tournament JS memory leak by destroying powertips on unload

This commit is contained in:
Thibault Duplessis 2016-01-24 00:35:59 +07:00
parent 88b30af146
commit 1ba4aa2201
3 changed files with 17 additions and 2 deletions

View file

@ -23,7 +23,12 @@ module.exports = function(ctrl) {
attrs: {
key: p.id,
href: '/' + p.id,
class: 'glpt'
class: 'glpt',
config: function(el, isUpdate, ctx) {
if (!isUpdate) ctx.onunload = function() {
$.powerTip.destroy(el);
};
}
},
children: [
user(p, 0),

View file

@ -60,7 +60,12 @@ module.exports = function(ctrl) {
return m('tr', {
key: p.id,
'data-href': '/' + p.id + '/' + p.color,
class: 'glpt' + (res === '1' ? ' win' : (res === '0' ? ' loss' : ''))
class: 'glpt' + (res === '1' ? ' win' : (res === '0' ? ' loss' : '')),
config: function(el, isUpdate, ctx) {
if (!isUpdate) ctx.onunload = function() {
$.powerTip.destroy(el);
};
}
}, [
m('th', Math.max(nb.game, pairingsLen) - i),
m('td', (p.op.title ? p.op.title + ' ' : '') + p.op.name),

View file

@ -71,6 +71,11 @@ module.exports = {
var fullName = (p.title ? p.title + ' ' : '') + p.name;
var attrs = {
class: 'ulpt user_link' + (fullName.length > 15 ? ' long' : ''),
config: function(el, isUpdate, ctx) {
if (!isUpdate) ctx.onunload = function() {
$.powerTip.destroy(el);
};
}
};
attrs[tag === 'a' ? 'href' : 'data-href'] = '/@/' + p.name;
return {