diff --git a/iron-a11y-keys-behavior.html b/iron-a11y-keys-behavior.html
index cc18d99..0e7d7ec 100644
--- a/iron-a11y-keys-behavior.html
+++ b/iron-a11y-keys-behavior.html
@@ -391,12 +391,15 @@
_resetKeyEventListeners: function() {
this._unlistenKeyEventListeners();
- if (this.isAttached && this.keyEventTarget) {
+ if (this.isAttached) {
this._listenKeyEventListeners();
}
},
_listenKeyEventListeners: function() {
+ if (!this.keyEventTarget) {
+ return;
+ }
Object.keys(this._keyBindings).forEach(function(eventName) {
var keyBindings = this._keyBindings[eventName];
var boundKeyHandler = this._onKeyBindingEvent.bind(this, keyBindings);
diff --git a/test/basic-test.html b/test/basic-test.html
index 3253e23..d0c2dc3 100644
--- a/test/basic-test.html
+++ b/test/basic-test.html
@@ -431,6 +431,15 @@
});
});
+ suite('remove key behavior with null target', function () {
+ test('add and remove a iron-a11y-keys-behavior', function () {
+ var element = document.createElement('x-a11y-basic-keys');
+ element.keyEventTarget = null;
+ document.body.appendChild(element);
+ document.body.removeChild(element);
+ });
+ });
+
});