Skip to content

Commit

Permalink
Remove <details> shim
Browse files Browse the repository at this point in the history
It was for EdgeHTML, but it's OK to not support that anymore.
  • Loading branch information
domenic committed Nov 2, 2022
1 parent f0eecd9 commit 46509ab
Showing 1 changed file with 0 additions and 104 deletions.
104 changes: 0 additions & 104 deletions views/agreement.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,6 @@ summary, label, input[type="submit"] {
cursor: pointer;
}
/* <details> needs some polyfill styles for Edge */
details {
display: block;
margin: 1em 0;
}
details > div {
display: none;
}
details[open] > div {
display: block;
}
summary::-webkit-details-marker {
display: none;
}
summary {
display: block;
}
summary::before {
font-size: .8em;
margin-right: .4em;
content: "";
}
details[open] > summary::before {
content: "";
}
dfn {
font-style: inherit;
font-weight: bold;
Expand Down Expand Up @@ -455,74 +422,3 @@ input[type="submit"] {

<input type="submit" value="Submit">
</form>

<script>
// Details shim for Edge
'use strict';
(() => {
const supportsDetails = 'open' in document.createElement('details');
if (!supportsDetails) {
registerEvents();
setUpDetailsA11yAttributes();
}
function setUpDetailsA11yAttributes() {
const allDetails = Array.from(document.querySelectorAll('details'));
for (const details of allDetails) {
details.setAttribute('role', 'group');
const summary = details.querySelector('summary');
summary.setAttribute('role', 'button');
summary.setAttribute('tabindex', '0');
}
}
function registerEvents() {
document.addEventListener('click', e => {
onActivation(e);
});
document.addEventListener('keydown', e => {
if (e.keyCode === 32 || e.keyCode === 13) {
onActivation(e);
}
});
}
function onActivation(e) {
const summary = findSummary(e.target);
if (!summary) {
return;
}
e.preventDefault();
const details = summary.parentElement;
toggleDetails(details, summary);
}
function toggleDetails(details, summary) {
if (details.hasAttribute('open')) {
details.removeAttribute('open');
summary.setAttribute('aria-expanded', 'false');
} else {
details.setAttribute('open', '');
summary.setAttribute('aria-expanded', 'true');
}
details.dispatchEvent(new Event('toggle'));
}
function findSummary(element) {
if (element.localName === 'summary') {
return element;
}
if (element.parentElement) {
return findSummary(element.parentElement);
}
return null;
}
})();
</script>

0 comments on commit 46509ab

Please sign in to comment.