Skip to content

Commit

Permalink
Make sure not to cause errors on the server
Browse files Browse the repository at this point in the history
  • Loading branch information
KittyGiraudel committed Jun 28, 2018
1 parent 6c13ef9 commit d2414c6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions a11y-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
];
var TAB_KEY = 9;
var ESCAPE_KEY = 27;
var isDialogSupported = 'show' in document.createElement('dialog');
var focusedBeforeDialog;

/**
Expand All @@ -39,7 +38,10 @@
// Keep a reference of the node and the actual dialog on the instance
this.container = node;
this.dialog = node.querySelector('dialog, [role="dialog"]');
this.useDialog = isDialogSupported && this.dialog.nodeName === 'DIALOG';
this.useDialog = (
'show' in document.createElement('dialog') &&
this.dialog.nodeName === 'DIALOG'
);

// Keep an object of listener types mapped to callback functions
this._listeners = {};
Expand Down
4 changes: 2 additions & 2 deletions a11y-dialog.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions example/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
];
var TAB_KEY = 9;
var ESCAPE_KEY = 27;
var isDialogSupported = 'show' in document.createElement('dialog');
var focusedBeforeDialog;

/**
Expand All @@ -39,7 +38,10 @@
// Keep a reference of the node and the actual dialog on the instance
this.container = node;
this.dialog = node.querySelector('dialog, [role="dialog"]');
this.useDialog = isDialogSupported && this.dialog.nodeName === 'DIALOG';
this.useDialog = (
'show' in document.createElement('dialog') &&
this.dialog.nodeName === 'DIALOG'
);

// Keep an object of listener types mapped to callback functions
this._listeners = {};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "a11y-dialog",
"version": "5.1.1",
"version": "5.1.2",
"description":
"A tiny script to make dialog windows accessible to assistive technology users.",
"homepage": "https://github.com/edenspiekermann/a11y-dialog",
Expand Down

0 comments on commit d2414c6

Please sign in to comment.