Skip to content

Commit

Permalink
Fix IE double-execution bug by setting src before type
Browse files Browse the repository at this point in the history
  • Loading branch information
apeschar committed Jan 31, 2019
1 parent 1161efd commit 9b8568b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Filters/HTML/ScriptsDeferring/scripts-loader.js
Expand Up @@ -91,20 +91,23 @@ phast.ScriptsLoader.Utilities = function (document) {
}

function restoreOriginals(element) {
var shouldRemoveType = !element.hasAttribute('data-phast-original-type');
element.removeAttribute('data-phast-params');
var attrs = {};
Array.prototype
.map.call(element.attributes, function (attr) {
return attr.nodeName;
})
.forEach(function (attrName) {
.map(function (attrName) {
var matches = attrName.match(/^data-phast-original-(.*)/i);
if (matches) {
element.setAttribute(matches[1], element.getAttribute(attrName));
attrs[matches[1].toLowerCase()] = element.getAttribute(attrName);
element.removeAttribute(attrName);
}
});
if (shouldRemoveType) {
Object.keys(attrs).sort().map(function (attr) {
element.setAttribute(attr, attrs[attr]);
});
if (!('type' in attrs)) {
element.removeAttribute('type');
}
}
Expand Down

0 comments on commit 9b8568b

Please sign in to comment.