Skip to content

Commit

Permalink
Allowing elements to be passed to service.
Browse files Browse the repository at this point in the history
  • Loading branch information
Garrett Murphey committed Dec 31, 2018
1 parent 258d3ed commit 0be3b99
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions addon/services/resize-detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ export default Ember.Service.extend({
},

setup(selector, callback) {
let element = document.querySelector(selector)
let element;

if (selector instanceof HTMLElement) {
element = selector;
} else {
element = document.querySelector(selector);
}

if (!element) {
error(`service:resize-detector - could not find an element matching ${selector}`);
return;
Expand All @@ -25,7 +32,14 @@ export default Ember.Service.extend({
},

teardown(selector, callback) {
let element = document.querySelector(selector)
let element;

if (selector instanceof HTMLElement) {
element = selector;
} else {
element = document.querySelector(selector);
}

if (element) {
this.detector.removeListener(element, callback);
}
Expand Down

0 comments on commit 0be3b99

Please sign in to comment.