Skip to content

Commit

Permalink
Ensure global view registry is aliased when view registry is used.
Browse files Browse the repository at this point in the history
In Ember 1.12.0 and 1.12.1 the `-view-registry:main` was introduced as a
mechanism to track views without mutating the global `Ember.View.views`
registry (needed for fastboot work), unfortunately the
`Ember.EventDispatcher` was not updated to use the new view registry and
therefore any views added in a view registry other than
`Ember.View.views` will not be able to handle DOM events. The event
dispatcher was fixed in emberjs/ember.js#11290.

This change ensures that `-view-registry:main` is the same as
`Ember.View.views` on Ember versions where `Ember.View.views` exists
(Ember < 1.13.0).
  • Loading branch information
rwjblue committed Jul 30, 2015
1 parent f0e8752 commit bec1ba6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions lib/ember-test-helpers/test-module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,24 @@ export default TestModule.extend({
this.setupSteps.push(this.setupComponentIntegrationTest);
this.teardownSteps.push(this.teardownComponent);
}

if (Ember.View && Ember.View.views) {
this.setupSteps.push(this._aliasViewRegistry);
this.teardownSteps.push(this._resetViewRegistry);
}
},

_aliasViewRegistry: function() {
this._originalGlobalViewRegistry = Ember.View.views;
var viewRegistry = this.container.lookup('-view-registry:main');

if (viewRegistry) {
Ember.View.views = viewRegistry;
}
},

_resetViewRegistry: function() {
Ember.View.views = this._originalGlobalViewRegistry;
},

setupComponentUnitTest: function() {
Expand Down
2 changes: 1 addition & 1 deletion lib/ember-test-helpers/test-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default Klass.extend({

// Ember 2.0.0 removed Ember.View as public API, so only do this when
// Ember.View is present
if (Ember.View) {
if (Ember.View && Ember.View.views) {
Ember.View.views = {};
}
},
Expand Down

0 comments on commit bec1ba6

Please sign in to comment.