a11y-dialog
Advanced tools
Comparing version 5.5.1 to 5.5.2
@@ -466,11 +466,11 @@ /* global NodeList, Element, Event, define */ | ||
function instantiateDialogs() { | ||
$$('[data-a11y-dialog]').forEach(function (node) { | ||
new A11yDialog(node, node.getAttribute('data-a11y-dialog') || undefined) | ||
}) | ||
} | ||
if (typeof global.document !== 'undefined') { | ||
var document = global.document | ||
function instantiateDialogs() { | ||
$$('[data-a11y-dialog]').forEach(function (node) { | ||
new A11yDialog(node, node.getAttribute('data-a11y-dialog') || undefined) | ||
}) | ||
} | ||
if (document.readyState === 'loading') { | ||
@@ -477,0 +477,0 @@ document.addEventListener('DOMContentLoaded', instantiateDialogs) |
@@ -1,2 +0,2 @@ | ||
/*! a11y-dialog 5.5.1 — © Edenspiekermann */ | ||
/*! a11y-dialog 5.5.2 — © Edenspiekermann */ | ||
!function(t){"use strict";var i,n,e=['a[href]:not([tabindex^="-"]):not([inert])','area[href]:not([tabindex^="-"]):not([inert])',"input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])",'iframe:not([tabindex^="-"]):not([inert])','audio:not([tabindex^="-"]):not([inert])','video:not([tabindex^="-"]):not([inert])','[contenteditable]:not([tabindex^="-"]):not([inert])','[tabindex]:not([tabindex^="-"]):not([inert])'];function o(t,i){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.container=t,this.dialog=t.querySelector('dialog, [role="dialog"], [role="alertdialog"]'),this.role=this.dialog.getAttribute("role")||"dialog",this.useDialog="show"in n.createElement("dialog")&&"DIALOG"===this.dialog.nodeName,this._listeners={},this.create(i)}function s(t){return Array.prototype.slice.call(t)}function r(t,i){return s((i||n).querySelectorAll(t))}function a(t){var i=h(t),i=t.querySelector("[autofocus]")||i[0];i&&i.focus()}function h(t){return r(e.join(","),t).filter(function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)})}function d(){r("[data-a11y-dialog]").forEach(function(t){new o(t,t.getAttribute("data-a11y-dialog")||void 0)})}o.prototype.create=function(t){var i;return this._targets=this._targets||function(t){if(NodeList.prototype.isPrototypeOf(t))return s(t);if(Element.prototype.isPrototypeOf(t))return[t];if("string"==typeof t)return r(t)}(t)||(i=this.container,(t=s(i.parentNode.childNodes).filter(function(t){return 1===t.nodeType})).splice(t.indexOf(i),1),t),this.shown=this.dialog.hasAttribute("open"),this.dialog.setAttribute("role",this.role),this.useDialog?(this.container.setAttribute("data-a11y-dialog-native",""),this.container.removeAttribute("aria-hidden")):this.shown?this.container.removeAttribute("aria-hidden"):this.container.setAttribute("aria-hidden",!0),this._openers=r('[data-a11y-dialog-show="'+this.container.id+'"]'),this._openers.forEach(function(t){t.addEventListener("click",this._show)}.bind(this)),this._closers=r("[data-a11y-dialog-hide]",this.container).concat(r('[data-a11y-dialog-hide="'+this.container.id+'"]')),this._closers.forEach(function(t){t.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},o.prototype.show=function(t){return this.shown||(this.shown=!0,i=n.activeElement,this.useDialog?this.dialog.showModal(t instanceof Event?void 0:t):(this.dialog.setAttribute("open",""),this.container.removeAttribute("aria-hidden"),this._targets.forEach(function(t){t.hasAttribute("aria-hidden")&&t.setAttribute("data-a11y-dialog-original-aria-hidden",t.getAttribute("aria-hidden")),t.setAttribute("aria-hidden","true")})),a(this.dialog),n.body.addEventListener("focus",this._maintainFocus,!0),n.addEventListener("keydown",this._bindKeypress),this._fire("show",t)),this},o.prototype.hide=function(t){return this.shown&&(this.shown=!1,this.useDialog?this.dialog.close(t instanceof Event?void 0:t):(this.dialog.removeAttribute("open"),this.container.setAttribute("aria-hidden","true"),this._targets.forEach(function(t){t.hasAttribute("data-a11y-dialog-original-aria-hidden")?(t.setAttribute("aria-hidden",t.getAttribute("data-a11y-dialog-original-aria-hidden")),t.removeAttribute("data-a11y-dialog-original-aria-hidden")):t.removeAttribute("aria-hidden")})),i&&i.focus&&i.focus(),n.body.removeEventListener("focus",this._maintainFocus,!0),n.removeEventListener("keydown",this._bindKeypress),this._fire("hide",t)),this},o.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},o.prototype.on=function(t,i){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(i),this},o.prototype.off=function(t,i){i=this._listeners[t].indexOf(i);return-1<i&&this._listeners[t].splice(i,1),this},o.prototype._fire=function(t,i){(this._listeners[t]||[]).forEach(function(t){t(this.container,i)}.bind(this))},o.prototype._bindKeypress=function(t){var i,e;this.shown&&27===t.which&&"alertdialog"!==this.role&&(t.preventDefault(),this.hide(t)),this.shown&&9===t.which&&(i=this.dialog,e=t,t=h(i),i=t.indexOf(n.activeElement),e.shiftKey&&0===i?(t[t.length-1].focus(),e.preventDefault()):e.shiftKey||i!==t.length-1||(t[0].focus(),e.preventDefault()))},o.prototype._maintainFocus=function(t){this.shown&&!this.container.contains(t.target)&&a(this.dialog)},void 0!==t.document&&("loading"===(n=t.document).readyState?n.addEventListener("DOMContentLoaded",d):t.requestAnimationFrame?t.requestAnimationFrame(d):t.setTimeout(d,16)),"undefined"!=typeof module&&void 0!==module.exports?module.exports=o:"function"==typeof define&&define.amd?define("A11yDialog",[],function(){return o}):"object"==typeof t&&(t.A11yDialog=o)}("undefined"!=typeof global?global:window); |
{ | ||
"name": "a11y-dialog", | ||
"version": "5.5.1", | ||
"version": "5.5.2", | ||
"description": "A tiny script to make dialog windows accessible to assistive technology users.", | ||
@@ -27,7 +27,8 @@ "homepage": "https://github.com/edenspiekermann/a11y-dialog", | ||
"scripts": { | ||
"copy": "cp a11y-dialog.js example/main.js", | ||
"copy": "cp a11y-dialog.js example", | ||
"minify": "uglifyjs a11y-dialog.js -o a11y-dialog.min.js -c -m", | ||
"build": "npm run minify && npm run copy", | ||
"postbuild": "npm run add-version", | ||
"test": "open tests/index.html", | ||
"serve": "npx serve example", | ||
"test": "cypress run", | ||
"extract-version": "cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'", | ||
@@ -54,2 +55,4 @@ "add-version": "echo \"/*! a11y-dialog $(npm run extract-version --silent) — © Edenspiekermann */\n$(cat a11y-dialog.min.js)\" > a11y-dialog.min.js", | ||
"devDependencies": { | ||
"cypress": "^6.4.0", | ||
"cypress-plugin-tab": "^1.0.5", | ||
"gitbook-cli": "^2.3.2", | ||
@@ -59,4 +62,4 @@ "husky": "^4.3.8", | ||
"prettier": "^2.2.1", | ||
"uglify-js": "^3.12.6" | ||
"uglify-js": "^3.12.8" | ||
} | ||
} |
@@ -54,3 +54,3 @@ # [A11y Dialog](http://edenspiekermann.github.io/a11y-dialog/) | ||
- It doesn’t have to have the `data-a11y-dialog-hide` attribute, however this is recommended. It hides the dialog when clicking outside of it. | ||
- It should not have the `data-a11y-dialog-hide` if the dialog window has the `alertdialog`role (see below). | ||
- It should not have the `data-a11y-dialog-hide` if the dialog window has the `alertdialog` role (see below). | ||
--> | ||
@@ -57,0 +57,0 @@ <div tabindex="-1" data-a11y-dialog-hide></div> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38451
7