From: Alexander Ebert Date: Fri, 23 Sep 2016 15:25:40 +0000 (+0200) Subject: Fix for Firefox/Safari ignoring initial srcset attribute X-Git-Tag: 3.0.0_Beta_1~16 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0b7a31e761fc8d99c9badb35fe651471912ab5c5;p=GitHub%2FWoltLab%2FWCF.git Fix for Firefox/Safari ignoring initial srcset attribute --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js index 3b82fdc12a..5fb8c2544c 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabSmiley.js @@ -1,6 +1,8 @@ $.Redactor.prototype.WoltLabSmiley = function() { "use strict"; + var _index = 0; + return { init: function() { require(['EventHandler'], (function(EventHandler) { @@ -11,7 +13,18 @@ $.Redactor.prototype.WoltLabSmiley = function() { _insert: function(data) { this.buffer.set(); - this.insert.html(data.img.cloneNode().outerHTML); + var id = 'wscSmiley_' + this.uuid + '_' + _index++; + + var smiley = data.img.cloneNode(); + smiley.id = id; + this.insert.html(smiley.outerHTML); + + // Firefox and Safari tend to ignore the `srcset` attribute, all though + // it is clearly present in the DOM. Overwriting the element with itself + // is somehow fixing that issue, yay! + smiley = elById(id); + //noinspection SillyAssignmentJS + smiley.outerHTML = smiley.outerHTML; } } };