DEV: Remove the <details> polyfill (#10260)

Per the linked site (http://mths.be/details) and https://caniuse.com/#feat=details the <details> element is supported since Chrome 12/Safari 6/Firefox 49/Edge 79. IE 11 doesn't handle them, but we dropped the support for that browser.
This commit is contained in:
Jarek Radosz 2020-07-20 13:18:00 +02:00 committed by GitHub
parent 5f3dfce4eb
commit 8f2f9e6afa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1 additions and 60 deletions

View File

@ -1,58 +0,0 @@
(function(document, $) {
// cf. http://mths.be/details
var hasNativeSupport = (function(doc) {
var fake, el = doc.createElement("details");
// fail-fast
if (!("open" in el)) { return false; }
// figure out a root node
var root = doc.body || (function() {
var de = doc.documentElement;
fake = true;
return de.insertBefore(doc.createElement("body"), de.firstElementChild || de.firstChild);
})();
// setup test element
el.innerHTML = "<summary>a</summary>b";
el.style.display = "block";
// add test element to the root node
root.appendChild(el);
// can we open it?
var diff = el.offsetHeight;
el.open = true;
diff = diff !== el.offsetHeight;
// cleanup
root.removeChild(el);
if (fake) { root.parentNode.removeChild(root); }
// return the result
return diff;
})(document);
function toggleOpen($details) {
$details.toggleClass("open");
}
$.fn.details = function() {
if (hasNativeSupport) { return this; }
return this.each(function() {
var $details = $(this),
$firstSummary = $("summary", $details).first();
$firstSummary.prop("tabIndex", 0);
$firstSummary.on("keydown", function(event) {
if (event.keyCode === 32 /* SPACE */ || event.keyCode === 13 /* ENTER */) {
toggleOpen($details);
return false;
}
});
$firstSummary.on("click", function() {
$firstSummary.focus();
toggleOpen($details);
});
});
};
})(document, jQuery);

View File

@ -2,7 +2,7 @@ import I18n from "I18n";
import { withPluginApi } from "discourse/lib/plugin-api";
function initializeDetails(api) {
api.decorateCooked($elem => $("details", $elem).details(), {
api.decorateCooked($elem => $("details", $elem), {
id: "discourse-details"
});

View File

@ -9,7 +9,6 @@
enabled_site_setting :details_enabled
hide_plugin if self.respond_to?(:hide_plugin)
register_asset "javascripts/details.js"
register_asset "stylesheets/details.scss"
after_initialize do