uswds
Version:
Open source UI components and visual style guide for U.S. government websites
19 lines (16 loc) • 354 B
JavaScript
const elproto = window.HTMLElement.prototype;
const HIDDEN = 'hidden';
if (!(HIDDEN in elproto)) {
Object.defineProperty(elproto, HIDDEN, {
get() {
return this.hasAttribute(HIDDEN);
},
set(value) {
if (value) {
this.setAttribute(HIDDEN, '');
} else {
this.removeAttribute(HIDDEN);
}
},
});
}