Skip to content

Commit 2f07c6c

Browse files
committed
Add workaround for jsdom missing HTMLDialogElement support
1 parent d4ac4be commit 2f07c6c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

configs/mocha-config-compass/register/jsdom-extra-mocks-register.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,25 @@ Object.assign(tabbable, {
3535
origTabbable.isTabbable(node, { ...options, displayCheck: 'none' }),
3636
});
3737

38+
// Workaround for missing HTMLDialogElement in jsdom
39+
// See https://github.com/jsdom/jsdom/issues/3294
40+
41+
Object.assign(HTMLDialogElement.prototype, {
42+
show() {
43+
this.open = true;
44+
this.style.display = '';
45+
},
46+
showModal() {
47+
this.open = true;
48+
this.style.display = '';
49+
},
50+
close(returnValue) {
51+
this.open = false;
52+
this.returnValue = returnValue;
53+
this.style.display = 'none';
54+
},
55+
});
56+
3857
// leafygreen (through `clipboard` library) uses deprecated API check that is
3958
// not working in jsdom if copy / paste APIs are supported
4059
if (!window.document.queryCommandSupported) {

0 commit comments

Comments
 (0)