Skip to content

Commit

Permalink
Merge pull request #1013 from LibraryOfCongress/activity-ui-ms-edge-p…
Browse files Browse the repository at this point in the history
…olyfills

Polyfill Element.toggleAttribute for MS Edge < 18
  • Loading branch information
rstorey committed May 28, 2019
2 parents a87b53b + 76cd2ad commit f22f831
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions concordia/templates/action-app.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
document.head.appendChild(s);
})();
</script>
<script>
// Used from https://developer.mozilla.org/en-US/docs/Web/API/Element/toggleAttribute#Polyfill under the MDN license
if (!Element.prototype.toggleAttribute) {
Element.prototype.toggleAttribute = function(name, force) {
if (force !== void 0) force = !!force;

if (this.getAttribute(name) !== null) {
if (force) return true;
this.removeAttribute(name);
return false;
} else {
if (force === false) return false;
this.setAttribute(name, '');
return true;
}
};
}
</script>
{% endblock head_content %}

{% block body_scripts %}
Expand Down

0 comments on commit f22f831

Please sign in to comment.