From 0b7a31e761fc8d99c9badb35fe651471912ab5c5 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 23 Sep 2016 17:25:40 +0200 Subject: [PATCH] Fix for Firefox/Safari ignoring initial srcset attribute --- .../3rdParty/redactor2/plugins/WoltLabSmiley.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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; } } }; -- 2.20.1