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 fa0e6ed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addon/services/resize-detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default Ember.Service.extend({
},

setup(selector, callback) {
let element = document.querySelector(selector)
let element = (selector instanceof HTMLElement) ? selector : document.querySelector(selector);

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

teardown(selector, callback) {
let element = document.querySelector(selector)
let element = (selector instanceof HTMLElement) ? selector : document.querySelector(selector);

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

0 comments on commit fa0e6ed

Please sign in to comment.