Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MockInteractions Keyboard Interactions on document.body #102

Open
thuoe opened this issue Aug 15, 2018 · 0 comments
Open

MockInteractions Keyboard Interactions on document.body #102

thuoe opened this issue Aug 15, 2018 · 0 comments

Comments

@thuoe
Copy link

thuoe commented Aug 15, 2018

Description

I am currently creating keyboard video control shortcuts similar to YouTube which involves adding a keypress event listener bound to the <body>. The event handler

ready() {
  super.ready();
  document.body.addEventListener('keypress', this._handleKeyPress.bind(this)); 
}

Behaviorally, it works as intended, however in my unit tests, the event handler doesn't seem to be invoked when using MockInteractions.pressSpace or any other keyboard interaction functions. Debugging through I noticed that the document.activeElement is in fact the <body> so I am unsure what the issue is.

window.focus();
MockInteractions.pressSpace(document.body);

Any ideas how to solve this problem?

I am using Polymer 2 with "iron-test-helpers": "PolymerElements/iron-test-helpers#^2.0.0" as a devDependency

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant