svelte-accessible-dialog
Advanced tools
Comparing version 2.0.1 to 2.1.1
@@ -505,4 +505,4 @@ (function (global, factory) { | ||
let current; | ||
const default_slot_template = /*$$slots*/ ctx[4].default; | ||
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[3], null); | ||
const default_slot_template = /*$$slots*/ ctx[5].default; | ||
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[4], null); | ||
@@ -522,4 +522,4 @@ return { | ||
if (default_slot) { | ||
if (default_slot.p && dirty & /*$$scope*/ 8) { | ||
default_slot.p(get_slot_context(default_slot_template, ctx, /*$$scope*/ ctx[3], null), get_slot_changes(default_slot_template, /*$$scope*/ ctx[3], dirty, null)); | ||
if (default_slot.p && dirty & /*$$scope*/ 16) { | ||
default_slot.p(get_slot_context(default_slot_template, ctx, /*$$scope*/ ctx[4], null), get_slot_changes(default_slot_template, /*$$scope*/ ctx[4], dirty, null)); | ||
} | ||
@@ -545,30 +545,26 @@ } | ||
let { enabled } = $$props; | ||
let originalAttributes = []; | ||
const hideFromScreenReader = element => { | ||
if (element.hasAttribute("aria-hidden")) { | ||
element.setAttribute("data-keep-hidden", element.getAttribute("aria-hidden")); | ||
} | ||
const hideFromScreenReader = node => { | ||
originalAttributes.push({ | ||
ariaHidden: node.getAttribute("aria-hidden"), | ||
inert: node.getAttribute("inert") | ||
}); | ||
element.setAttribute("aria-hidden", "true"); | ||
if (element.getAttribute("inert")) { | ||
element.setAttribute("data-keep-inert", ""); | ||
} | ||
element.setAttribute("inert", "true"); | ||
node.setAttribute("aria-hidden", "true"); | ||
node.setAttribute("inert", "true"); | ||
}; | ||
const exposeToScreenReader = element => { | ||
if (!element.hasAttribute("data-keep-inert")) { | ||
element.removeAttribute("inert"); | ||
} | ||
const exposeToScreenReader = (node, i) => { | ||
const { ariaHidden, inert } = originalAttributes[i]; | ||
element.removeAttribute("data-keep-inert"); | ||
if (element.getAttribute("data-keep-hidden")) { | ||
element.setAttribute("aria-hidden", element.getAttribute("data-keep-hidden")); | ||
element.removeAttribute("data-keep-hidden"); | ||
if (!ariaHidden) { | ||
node.removeAttribute("aria-hidden"); | ||
} else { | ||
element.removeAttribute("aria-hidden"); | ||
node.setAttribute("aria-hidden", ariaHidden); | ||
} | ||
if (!inert) { | ||
node.removeAttribute("inert"); | ||
} | ||
}; | ||
@@ -599,6 +595,13 @@ | ||
if ("enabled" in $$props) $$invalidate(0, enabled = $$props.enabled); | ||
if ("$$scope" in $$props) $$invalidate(3, $$scope = $$props.$$scope); | ||
if ("$$scope" in $$props) $$invalidate(4, $$scope = $$props.$$scope); | ||
}; | ||
return [enabled, hideFromScreenReader, exposeToScreenReader, $$scope, $$slots]; | ||
return [ | ||
enabled, | ||
originalAttributes, | ||
hideFromScreenReader, | ||
exposeToScreenReader, | ||
$$scope, | ||
$$slots | ||
]; | ||
} | ||
@@ -685,3 +688,3 @@ | ||
} else { | ||
const initialFocusElem = ref.querySelector("[autofocus]") || firstTabbableChild; | ||
const initialFocusElem = ref.querySelector("[autofocus]") || firstTabbableChild || ref.querySelector("[data-svelte-dialog-content]"); | ||
initialFocusElem.focus(); | ||
@@ -702,2 +705,6 @@ } | ||
if (tabbableChildren.length === 0) { | ||
event.preventDefault(); | ||
} | ||
if (event.shiftKey) { | ||
@@ -1386,3 +1393,3 @@ // Handle shift + tab | ||
{ role: "dialog" }, | ||
{ "tab-index": "-1" } | ||
{ tabindex: "-1" } | ||
]; | ||
@@ -1424,3 +1431,3 @@ | ||
{ role: "dialog" }, | ||
{ "tab-index": "-1" } | ||
{ tabindex: "-1" } | ||
])); | ||
@@ -1427,0 +1434,0 @@ |
{ | ||
"name": "svelte-accessible-dialog", | ||
"version": "2.0.1", | ||
"version": "2.1.1", | ||
"description": "An accessible dialog component for Svelte apps", | ||
@@ -5,0 +5,0 @@ "author": "Reece Lucas <reecelucas@sky.com>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2648
102698