diff --git a/packages/ember-htmlbars/lib/node-managers/component-node-manager.js b/packages/ember-htmlbars/lib/node-managers/component-node-manager.js index 3c1d03b455e..cf3c0e2df5e 100644 --- a/packages/ember-htmlbars/lib/node-managers/component-node-manager.js +++ b/packages/ember-htmlbars/lib/node-managers/component-node-manager.js @@ -253,7 +253,7 @@ export function createComponent(_component, isAngleBracket, _props, renderNode, } props.renderer = props.parentView ? props.parentView.renderer : env.container.lookup('renderer:-dom'); - props._viewRegistry = props.parentView ? props.parentView._viewRegistry : props.container && props.container.lookup('-view-registry:main'); + props._viewRegistry = props.parentView ? props.parentView._viewRegistry : env.container.lookup('-view-registry:main'); let component = _component.create(props); diff --git a/packages/ember-views/lib/mixins/view_child_views_support.js b/packages/ember-views/lib/mixins/view_child_views_support.js index 3acc930fffa..ace268e7412 100644 --- a/packages/ember-views/lib/mixins/view_child_views_support.js +++ b/packages/ember-views/lib/mixins/view_child_views_support.js @@ -89,6 +89,7 @@ var ViewChildViewsSupport = Mixin.create({ var attrs = _attrs || {}; var view; attrs.renderer = this.renderer; + attrs._viewRegistry = this._viewRegistry; if (maybeViewClass.isViewFactory) { attrs.container = this.container; diff --git a/packages/ember-views/lib/system/event_dispatcher.js b/packages/ember-views/lib/system/event_dispatcher.js index 17e7831196d..e0b902b67a1 100644 --- a/packages/ember-views/lib/system/event_dispatcher.js +++ b/packages/ember-views/lib/system/event_dispatcher.js @@ -15,9 +15,6 @@ import ActionManager from "ember-views/system/action_manager"; import View from "ember-views/views/view"; import merge from "ember-metal/merge"; -//ES6TODO: -// find a better way to do Ember.View.views without global state - /** `Ember.EventDispatcher` handles delegating browser events to their corresponding `Ember.Views.` For example, when you click on a view, @@ -174,7 +171,8 @@ export default EmberObject.extend({ var self = this; rootElement.on(event + '.ember', '.ember-view', function(evt, triggeringManager) { - var view = View.views[this.id]; + var viewRegistry = self.container && self.container.lookup('-view-registry:main') || View.views; + var view = viewRegistry[this.id]; var result = true; var manager = self.canDispatchToEventManager ? self._findNearestEventManager(view, eventName) : null; diff --git a/packages/ember/tests/integration/multiple-app-test.js b/packages/ember/tests/integration/multiple-app-test.js new file mode 100644 index 00000000000..6d3b41166e0 --- /dev/null +++ b/packages/ember/tests/integration/multiple-app-test.js @@ -0,0 +1,67 @@ +import compile from "ember-template-compiler/system/compile"; +import run from "ember-metal/run_loop"; + +var App1, App2, actions; + +function startApp(rootElement) { + var application; + + run(function() { + application = Ember.Application.create({ + rootElement + }); + application.deferReadiness(); + + application.Router.reopen({ + location: 'none' + }); + + var registry = application.__container__._registry; + + registry.register('component:special-button', Ember.Component.extend({ + actions: { + doStuff: function() { + actions.push(rootElement); + } + } + })); + registry.register('template:application', compile("{{outlet}}", { moduleName: 'application' })); + registry.register('template:index', compile("