Skip to content

Commit

Permalink
Fixes #14754 deprecate canDispatchToEventMAnager
Browse files Browse the repository at this point in the history
  • Loading branch information
Hassan Abdel-Rahman committed Mar 27, 2017
1 parent 6edfda7 commit f470f89
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
20 changes: 20 additions & 0 deletions packages/ember-glimmer/tests/integration/event-dispatcher-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@ moduleFor('EventDispatcher#setup', class extends RenderingTest {
this.$('div').trigger('myevent');
}

['@test canDispatchToEventManager is deprecated'](assert) {
this.dispatcher.canDispatchToEventManager = null;
this.registerComponent('x-foo', {
ComponentClass: Component.extend({
eventManager: {
myEvent() {
assert.ok(true, 'custom event was triggered');
}
}
}),
template: `<p>Hello!</p>`
});

expectDeprecation(() => {
this.render(`{{x-foo}}`);
}, '[DEPERECATED] `canDispatchToEventManager` has been deprecated.');

this.$('div').trigger('myevent');
}

['@test a rootElement can be specified'](assert) {
this.$().append('<div id="app"></div>');
this.dispatcher.setup({ myevent: 'myEvent' }, '#app');
Expand Down
11 changes: 10 additions & 1 deletion packages/ember-views/lib/mixins/view_support.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,16 @@ export default Mixin.create({
let owner = getOwner(this);
let dispatcher = owner && owner.lookup('event_dispatcher:main');

if (dispatcher && dispatcher.canDispatchToEventManager === null) {
deprecate(
`[DEPERECATED] \`canDispatchToEventManager\` has been deprecated.`,
!('canDispatchToEventManager' in dispatcher),
{
id: 'ember-views.event-dispatcher.canDispatchToEventManager',
until: '3.0.0'
}
);

if (dispatcher && !('canDispatchToEventManager' in dispatcher)) {
dispatcher.canDispatchToEventManager = true;
}
}
Expand Down
12 changes: 11 additions & 1 deletion packages/ember-views/lib/system/event_dispatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { assign, getOwner } from 'ember-utils';
import { assert } from 'ember-debug';
import { get, set, isNone, run } from 'ember-metal';
import { deprecate } from 'ember-debug';
import { Object as EmberObject } from 'ember-runtime';
import jQuery from './jquery';
import ActionManager from './action_manager';
Expand Down Expand Up @@ -129,13 +130,22 @@ export default EmberObject.extend({
@type boolean
@default false
@since 1.7.0
@deprecated
@private
*/
canDispatchToEventManager: null,

init() {
this._super();
assert('EventDispatcher should never be instantiated in fastboot mode. Please report this as an Ember bug.', environment.hasDOM);

deprecate(
`[DEPRECATED] \`canDispatchToEventManager\` has been deprecated.`,
!('canDispatchToEventManager' in this),
{
id: 'ember-views.event-dispatcher.canDispatchToEventManager',
until: '3.0.0'
}
);
},

/**
Expand Down

0 comments on commit f470f89

Please sign in to comment.