Skip to content

Commit

Permalink
check for body before attaching to body in response to error in build…
Browse files Browse the repository at this point in the history
… found on CT, see #1048
  • Loading branch information
jessegreenberg committed Apr 23, 2020
1 parent cdcfcd4 commit f814a09
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/accessibility/KeyStateTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,9 @@ class KeyStateTracker {
*/
attachToBody() {
assert && assert( !this.attachedToBody, 'KeyStateTracker is already attached to body.' );
if ( !document.body ) {
throw new Error( 'Cant access body element until it is declared, run script later or in a timeout.' );
}

this.bodyKeydownListener = event => {
if ( this.blockTrustedEvents && event.isTrusted ) {
Expand Down

0 comments on commit f814a09

Please sign in to comment.