From acbac1035fa51e0821a38aa3bd6774deed054dbf Mon Sep 17 00:00:00 2001 From: Adam Petrie Date: Fri, 9 Oct 2015 11:15:23 -0400 Subject: [PATCH] Allow scoped to be a selector and bind mousetrap to that selector instead of the current node. --- addon/create-mixin.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addon/create-mixin.js b/addon/create-mixin.js index 0b48e60..d846966 100644 --- a/addon/create-mixin.js +++ b/addon/create-mixin.js @@ -40,7 +40,11 @@ export default function(bindEvent, unbindEvent) { if (actionObject.global === false) { mousetrap = new Mousetrap(document); } else if (actionObject.scoped) { - mousetrap = new Mousetrap(self.get('element')); + if (Ember.typeOf(actionObject.scoped) === 'boolean') { + mousetrap = new Mousetrap(self.get('element')); + } else if (Ember.typeOf(actionObject.scoped) === 'string') { + mousetrap = new Mousetrap(document.querySelector(actionObject.scoped)); + } } else if (actionObject.targetElement) { mousetrap = new Mousetrap(actionObject.targetElement); }