diff --git a/4chan_x.user.js b/4chan_x.user.js index df548664e..1f026ffe7 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2445,10 +2445,10 @@ }; imgHover = { init: function() { - imgHover.img = $.el('img', { + imgHover.el = $.el('div', { id: 'iHover' }); - $.append(d.body, imgHover.img); + $.append(d.body, imgHover.el); return g.callbacks.push(imgHover.node); }, node: function(root) { @@ -2458,14 +2458,23 @@ } $.bind(thumb, 'mouseover', imgHover.mouseover); $.bind(thumb, 'mousemove', ui.hover); - return $.bind(thumb, 'mouseout', ui.hoverend); + return $.bind(thumb, 'mouseout', imgHover.mouseout); }, mouseover: function(e) { /* - `img.src = null` doesn't actually null the previous image on chrom. - */ imgHover.img.src = null; - imgHover.img.src = this.parentNode.href; - return ui.el = imgHover.img; + http://code.google.com/p/chromium/issues/detail?id=36142 + manipulating img src via javascript will generate a massive memory leak + + instead of manipulating src, we manipulate the entire img + */ var img; + img = $.el('img', { + src: this.parentNode.href + }); + $.append(imgHover.el, img); + return ui.el = imgHover.el; + }, + mouseout: function(e) { + return $.rm(imgHover.el.firstChild); } }; imgPreloading = { diff --git a/script.coffee b/script.coffee index 0498f6f8a..a3f58bd3a 100644 --- a/script.coffee +++ b/script.coffee @@ -1847,21 +1847,26 @@ nodeInserted = (e) -> imgHover = init: -> - imgHover.img = $.el 'img', id: 'iHover' - $.append d.body, imgHover.img + imgHover.el = $.el 'div', id: 'iHover' + $.append d.body, imgHover.el g.callbacks.push imgHover.node node: (root) -> return unless thumb = $ 'img[md5]', root $.bind thumb, 'mouseover', imgHover.mouseover $.bind thumb, 'mousemove', ui.hover - $.bind thumb, 'mouseout', ui.hoverend + $.bind thumb, 'mouseout', imgHover.mouseout mouseover: (e) -> ### - `img.src = null` doesn't actually null the previous image on chrom. + http://code.google.com/p/chromium/issues/detail?id=36142 + manipulating img src via javascript will generate a massive memory leak + + instead of manipulating src, we manipulate the entire img ### - imgHover.img.src = null - imgHover.img.src = @parentNode.href - ui.el = imgHover.img + img = $.el 'img', src: @parentNode.href + $.append imgHover.el, img + ui.el = imgHover.el + mouseout: (e) -> + $.rm imgHover.el.firstChild imgPreloading = init: ->