fix(composed-modal): perform null check before focusing element

Fixes error in Sapper
This commit is contained in:
Eric Liu 2020-10-21 06:19:23 -07:00
commit 05932065dc

View file

@ -71,7 +71,7 @@
function focus(element) { function focus(element) {
const node = const node =
(element || innerModal).querySelector(selectorPrimaryFocus) || buttonRef; (element || innerModal).querySelector(selectorPrimaryFocus) || buttonRef;
node.focus(); if (node != null) node.focus();
} }
$: opened = false; $: opened = false;
@ -84,7 +84,7 @@
onDestroy(() => { onDestroy(() => {
document.body.classList.remove("bx--body--with-modal-open"); document.body.classList.remove("bx--body--with-modal-open");
}) });
afterUpdate(() => { afterUpdate(() => {
if (opened) { if (opened) {