Skip to content

Commit

Permalink
Merge pull request #14820 from intercom/gj/root-element
Browse files Browse the repository at this point in the history
[performance] avoid a `get` if `rootElement` is known
  • Loading branch information
rwjblue authored Jan 12, 2017
2 parents e56dcbe + 6a208c2 commit 5ea34e5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/ember-views/lib/system/event_dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,13 @@ export default EmberObject.extend({
let event;
let events = this._finalEvents = assign({}, get(this, 'events'), addedEvents);

if (!isNone(rootElement)) {
if (isNone(rootElement)) {
rootElement = get(this, 'rootElement');
} else {
set(this, 'rootElement', rootElement);
}

rootElement = jQuery(get(this, 'rootElement'));
rootElement = jQuery(rootElement);

assert(`You cannot use the same root element (${rootElement.selector || rootElement[0].tagName}) multiple times in an Ember.Application`, !rootElement.is(ROOT_ELEMENT_SELECTOR));
assert('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest(ROOT_ELEMENT_SELECTOR).length);
Expand Down

0 comments on commit 5ea34e5

Please sign in to comment.