From df3ae44d3b6ca9b36507ebffd43f71adde07ce2f Mon Sep 17 00:00:00 2001 From: Kitty Giraudel Date: Fri, 25 Mar 2022 09:37:21 +0100 Subject: [PATCH] Prepare version 7.4.0 --- cypress/fixtures/a11y-dialog.js | 10 +++++----- dist/a11y-dialog.esm.js | 6 +++--- dist/a11y-dialog.esm.min.js | 2 +- dist/a11y-dialog.js | 10 +++++----- dist/a11y-dialog.min.js | 2 +- package-lock.json | 5 +++-- package.json | 2 +- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/cypress/fixtures/a11y-dialog.js b/cypress/fixtures/a11y-dialog.js index 5192346b..655418ef 100644 --- a/cypress/fixtures/a11y-dialog.js +++ b/cypress/fixtures/a11y-dialog.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.A11yDialog = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var focusableSelectors = [ 'a[href]:not([tabindex^="-"])', @@ -92,7 +92,7 @@ * current focus within it, listen for some specific key presses and fire all * registered callbacks for `show` event * - * @param {Event} event + * @param {CustomEvent} event * @return {this} */ A11yDialog.prototype.show = function (event) { @@ -127,7 +127,7 @@ * focus to the previously active element, stop listening for some specific * key presses and fire all registered callbacks for `hide` event * - * @param {Event} event + * @param {CustomEvent} event * @return {this} */ A11yDialog.prototype.hide = function (event) { @@ -230,7 +230,7 @@ * * @access private * @param {string} type - * @param {Event} event + * @param {CustomEvent} event */ A11yDialog.prototype._fire = function (type, event) { var listeners = this._listeners[type] || []; @@ -396,4 +396,4 @@ return A11yDialog; -}))); +})); diff --git a/dist/a11y-dialog.esm.js b/dist/a11y-dialog.esm.js index e76cd8dc..d5134bf0 100644 --- a/dist/a11y-dialog.esm.js +++ b/dist/a11y-dialog.esm.js @@ -86,7 +86,7 @@ A11yDialog.prototype.create = function () { * current focus within it, listen for some specific key presses and fire all * registered callbacks for `show` event * - * @param {Event} event + * @param {CustomEvent} event * @return {this} */ A11yDialog.prototype.show = function (event) { @@ -121,7 +121,7 @@ A11yDialog.prototype.show = function (event) { * focus to the previously active element, stop listening for some specific * key presses and fire all registered callbacks for `hide` event * - * @param {Event} event + * @param {CustomEvent} event * @return {this} */ A11yDialog.prototype.hide = function (event) { @@ -224,7 +224,7 @@ A11yDialog.prototype.off = function (type, handler) { * * @access private * @param {string} type - * @param {Event} event + * @param {CustomEvent} event */ A11yDialog.prototype._fire = function (type, event) { var listeners = this._listeners[type] || []; diff --git a/dist/a11y-dialog.esm.min.js b/dist/a11y-dialog.esm.min.js index 54c1a0cd..1757bd22 100644 --- a/dist/a11y-dialog.esm.min.js +++ b/dist/a11y-dialog.esm.min.js @@ -1,2 +1,2 @@ -/*! a11y-dialog 7.3.0 — © Kitty Giraudel */ +/*! a11y-dialog 7.4.0 — © Kitty Giraudel */ var t=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function e(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function i(t,e){return i=(e||document).querySelectorAll(t),Array.prototype.slice.call(i);var i}function n(t){(t.querySelector("[autofocus]")||t).focus()}function s(){i("[data-a11y-dialog]").forEach((function(t){new e(t)}))}e.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=i('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=i("[data-a11y-dialog-hide]",this.$el).concat(i('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},e.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,n(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},e.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},e.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},e.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},e.prototype.off=function(t,e){var i=(this._listeners[t]||[]).indexOf(e);return i>-1&&this._listeners[t].splice(i,1),this},e.prototype._fire=function(t,e){var i=this._listeners[t]||[],n=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(n),i.forEach(function(t){t(this.$el,e)}.bind(this))},e.prototype._bindKeypress=function(e){this.$el.contains(document.activeElement)&&(this.shown&&27===e.which&&"alertdialog"!==this.$el.getAttribute("role")&&(e.preventDefault(),this.hide(e)),this.shown&&9===e.which&&function(e,n){var s=function(e){return i(t.join(","),e).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(e),o=s.indexOf(document.activeElement);n.shiftKey&&0===o?(s[s.length-1].focus(),n.preventDefault()):n.shiftKey||o!==s.length-1||(s[0].focus(),n.preventDefault())}(this.$el,e))},e.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||n(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",s):window.requestAnimationFrame?window.requestAnimationFrame(s):window.setTimeout(s,16));export{e as default}; diff --git a/dist/a11y-dialog.js b/dist/a11y-dialog.js index 5192346b..655418ef 100644 --- a/dist/a11y-dialog.js +++ b/dist/a11y-dialog.js @@ -2,7 +2,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.A11yDialog = factory()); -}(this, (function () { 'use strict'; +})(this, (function () { 'use strict'; var focusableSelectors = [ 'a[href]:not([tabindex^="-"])', @@ -92,7 +92,7 @@ * current focus within it, listen for some specific key presses and fire all * registered callbacks for `show` event * - * @param {Event} event + * @param {CustomEvent} event * @return {this} */ A11yDialog.prototype.show = function (event) { @@ -127,7 +127,7 @@ * focus to the previously active element, stop listening for some specific * key presses and fire all registered callbacks for `hide` event * - * @param {Event} event + * @param {CustomEvent} event * @return {this} */ A11yDialog.prototype.hide = function (event) { @@ -230,7 +230,7 @@ * * @access private * @param {string} type - * @param {Event} event + * @param {CustomEvent} event */ A11yDialog.prototype._fire = function (type, event) { var listeners = this._listeners[type] || []; @@ -396,4 +396,4 @@ return A11yDialog; -}))); +})); diff --git a/dist/a11y-dialog.min.js b/dist/a11y-dialog.min.js index b5d90cc3..9c774eb5 100644 --- a/dist/a11y-dialog.min.js +++ b/dist/a11y-dialog.min.js @@ -1,2 +1,2 @@ -/*! a11y-dialog 7.3.0 — © Kitty Giraudel */ +/*! a11y-dialog 7.4.0 — © Kitty Giraudel */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).A11yDialog=e()}(this,(function(){"use strict";var t=['a[href]:not([tabindex^="-"])','area[href]:not([tabindex^="-"])','input:not([type="hidden"]):not([type="radio"]):not([disabled]):not([tabindex^="-"])','input[type="radio"]:not([disabled]):not([tabindex^="-"])','select:not([disabled]):not([tabindex^="-"])','textarea:not([disabled]):not([tabindex^="-"])','button:not([disabled]):not([tabindex^="-"])','iframe:not([tabindex^="-"])','audio[controls]:not([tabindex^="-"])','video[controls]:not([tabindex^="-"])','[contenteditable]:not([tabindex^="-"])','[tabindex]:not([tabindex^="-"])'];function e(t){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.$el=t,this.shown=!1,this._id=this.$el.getAttribute("data-a11y-dialog")||this.$el.id,this._previouslyFocused=null,this._listeners={},this.create()}function i(t,e){return i=(e||document).querySelectorAll(t),Array.prototype.slice.call(i);var i}function n(t){(t.querySelector("[autofocus]")||t).focus()}function s(){i("[data-a11y-dialog]").forEach((function(t){new e(t)}))}return e.prototype.create=function(){return this.$el.setAttribute("aria-hidden",!0),this.$el.setAttribute("aria-modal",!0),this.$el.setAttribute("tabindex",-1),this.$el.hasAttribute("role")||this.$el.setAttribute("role","dialog"),this._openers=i('[data-a11y-dialog-show="'+this._id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=i("[data-a11y-dialog-hide]",this.$el).concat(i('[data-a11y-dialog-hide="'+this._id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},e.prototype.show=function(t){return this.shown||(this._previouslyFocused=document.activeElement,this.$el.removeAttribute("aria-hidden"),this.shown=!0,n(this.$el),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},e.prototype.hide=function(t){return this.shown?(this.shown=!1,this.$el.setAttribute("aria-hidden","true"),this._previouslyFocused&&this._previouslyFocused.focus&&this._previouslyFocused.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t),this):this},e.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(t){t.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(t){t.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},e.prototype.on=function(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this},e.prototype.off=function(t,e){var i=(this._listeners[t]||[]).indexOf(e);return i>-1&&this._listeners[t].splice(i,1),this},e.prototype._fire=function(t,e){var i=this._listeners[t]||[],n=new CustomEvent(t,{detail:e});this.$el.dispatchEvent(n),i.forEach(function(t){t(this.$el,e)}.bind(this))},e.prototype._bindKeypress=function(e){this.$el.contains(document.activeElement)&&(this.shown&&27===e.which&&"alertdialog"!==this.$el.getAttribute("role")&&(e.preventDefault(),this.hide(e)),this.shown&&9===e.which&&function(e,n){var s=function(e){return i(t.join(","),e).filter((function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}))}(e),o=s.indexOf(document.activeElement);n.shiftKey&&0===o?(s[s.length-1].focus(),n.preventDefault()):n.shiftKey||o!==s.length-1||(s[0].focus(),n.preventDefault())}(this.$el,e))},e.prototype._maintainFocus=function(t){!this.shown||t.target.closest('[aria-modal="true"]')||t.target.closest("[data-a11y-dialog-ignore-focus-trap]")||n(this.$el)},"undefined"!=typeof document&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",s):window.requestAnimationFrame?window.requestAnimationFrame(s):window.setTimeout(s,16)),e})); diff --git a/package-lock.json b/package-lock.json index 63bf01da..37f6a5ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,12 @@ { "name": "a11y-dialog", - "version": "7.3.0", + "version": "7.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "7.3.0", + "name": "a11y-dialog", + "version": "7.4.0", "license": "MIT", "dependencies": { "focusable-selectors": "^0.3.1" diff --git a/package.json b/package.json index 45fe13e1..26cdd999 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "a11y-dialog", - "version": "7.3.0", + "version": "7.4.0", "description": "A tiny script to make dialog windows accessible to assistive technology users.", "homepage": "https://github.com/KittyGiraudel/a11y-dialog", "license": "MIT",